@dxos/client-services 0.1.56-main.83e9b8a → 0.1.56-main.a25bb93
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-P26UKXYR.mjs → chunk-MAHWP5I6.mjs} +970 -383
- package/dist/lib/browser/chunk-MAHWP5I6.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +50 -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 +12 -3
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +1113 -510
- 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 +1260 -667
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.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/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.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +4 -2
- 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-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.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/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/shell-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 +33 -33
- package/src/packlets/identity/authenticator.test.ts +2 -2
- package/src/packlets/identity/identity-manager.ts +1 -2
- package/src/packlets/identity/identity-service.ts +1 -2
- package/src/packlets/identity/identity.ts +1 -2
- package/src/packlets/invitations/device-invitation-protocol.ts +1 -2
- package/src/packlets/invitations/invitation-extension.ts +1 -2
- package/src/packlets/invitations/invitations-handler.ts +1 -2
- package/src/packlets/invitations/invitations-service.ts +1 -2
- package/src/packlets/invitations/space-invitation-protocol.ts +1 -2
- package/src/packlets/locks/node.ts +1 -1
- package/src/packlets/logging/logging-service.ts +17 -9
- 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.ts +3 -5
- package/src/packlets/services/service-host.test.ts +5 -5
- package/src/packlets/services/service-host.ts +23 -20
- package/src/packlets/services/service-registry.test.ts +1 -0
- package/src/packlets/services/util.ts +33 -0
- package/src/packlets/spaces/data-space-manager.ts +1 -2
- package/src/packlets/spaces/notarization-plugin.ts +1 -2
- package/src/packlets/system/system-service.test.ts +1 -0
- package/src/packlets/system/system-service.ts +34 -2
- package/src/packlets/testing/invitation-utils.ts +1 -2
- package/src/packlets/vault/shell-runtime.ts +1 -2
- package/src/packlets/vault/worker-session.ts +7 -3
- package/src/version.ts +1 -0
- package/dist/lib/browser/chunk-P26UKXYR.mjs.map +0 -7
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// packages/sdk/client-services/src/packlets/testing/index.ts
|
|
@@ -61,37 +51,203 @@ var createMockCredential = async ({ signer, issuer }) => (0, import_credentials.
|
|
|
61
51
|
});
|
|
62
52
|
|
|
63
53
|
// packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
|
|
64
|
-
var import_tiny_invariant14 = __toESM(require("tiny-invariant"));
|
|
65
54
|
var import_async18 = require("@dxos/async");
|
|
66
|
-
var
|
|
55
|
+
var import_invariant15 = require("@dxos/invariant");
|
|
56
|
+
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
67
57
|
|
|
68
58
|
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
69
59
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
70
60
|
var import_debug = require("@dxos/debug");
|
|
71
61
|
var import_rpc = require("@dxos/rpc");
|
|
72
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.a25bb93";
|
|
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
|
+
var _a, _b, _c;
|
|
108
|
+
const diagnostics = {
|
|
109
|
+
created: new Date().toISOString(),
|
|
110
|
+
platform: getPlatform(),
|
|
111
|
+
client: {
|
|
112
|
+
version: DXOS_VERSION,
|
|
113
|
+
storage: {
|
|
114
|
+
version: import_protocols.STORAGE_VERSION
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
{
|
|
119
|
+
(0, import_invariant.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
120
|
+
F: __dxlog_file,
|
|
121
|
+
L: 87,
|
|
122
|
+
S: void 0,
|
|
123
|
+
A: [
|
|
124
|
+
"clientServices.LoggingService",
|
|
125
|
+
"'SystemService is not available.'"
|
|
126
|
+
]
|
|
127
|
+
});
|
|
128
|
+
diagnostics.metrics = await (0, import_codec_protobuf2.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
|
|
129
|
+
timeout: DEFAULT_TIMEOUT
|
|
130
|
+
}).catch(() => void 0);
|
|
131
|
+
}
|
|
132
|
+
const identity = serviceContext.identityManager.identity;
|
|
133
|
+
if (identity) {
|
|
134
|
+
diagnostics.identity = {
|
|
135
|
+
identityKey: identity.identityKey,
|
|
136
|
+
spaceKey: identity.space.key,
|
|
137
|
+
profile: identity.profileDocument
|
|
138
|
+
};
|
|
139
|
+
const { devices } = (_a = await (0, import_codec_protobuf2.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
140
|
+
timeout: DEFAULT_TIMEOUT
|
|
141
|
+
}).catch(() => void 0)) != null ? _a : {};
|
|
142
|
+
diagnostics.devices = devices;
|
|
143
|
+
if (serviceContext.dataSpaceManager) {
|
|
144
|
+
diagnostics.spaces = await Promise.all((_b = Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space))) != null ? _b : []);
|
|
145
|
+
}
|
|
146
|
+
const { feeds = [] } = (_c = await (0, import_codec_protobuf2.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
147
|
+
timeout: DEFAULT_TIMEOUT
|
|
148
|
+
}).catch(() => void 0)) != null ? _c : {};
|
|
149
|
+
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
150
|
+
feedKey,
|
|
151
|
+
bytes,
|
|
152
|
+
length
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
diagnostics.config = config.values;
|
|
156
|
+
return diagnostics;
|
|
157
|
+
};
|
|
158
|
+
var getProperties = (space) => {
|
|
159
|
+
let properties = {};
|
|
160
|
+
try {
|
|
161
|
+
const propertiesItem = space.dataPipeline.itemManager.items.find((item) => {
|
|
162
|
+
var _a, _b;
|
|
163
|
+
return ((_a = item.modelMeta) == null ? void 0 : _a.type) === import_document_model.DocumentModel.meta.type && ((_b = item.state) == null ? void 0 : _b.type) === "dxos.sdk.client.Properties";
|
|
164
|
+
});
|
|
165
|
+
const state = propertiesItem == null ? void 0 : propertiesItem.state;
|
|
166
|
+
properties = state == null ? void 0 : state.data;
|
|
167
|
+
} catch (err) {
|
|
168
|
+
import_log.log.warn(err.message, void 0, {
|
|
169
|
+
F: __dxlog_file,
|
|
170
|
+
L: 144,
|
|
171
|
+
S: void 0,
|
|
172
|
+
C: (f, a) => f(...a)
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return properties;
|
|
176
|
+
};
|
|
177
|
+
var getSpaceStats = async (space) => {
|
|
178
|
+
var _a, _b, _c, _d, _e, _f;
|
|
179
|
+
const stats = {
|
|
180
|
+
key: space.key,
|
|
181
|
+
metrics: space.metrics,
|
|
182
|
+
epochs: space.inner.spaceState.credentials.filter((0, import_credentials2.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
183
|
+
...credential.subject.assertion,
|
|
184
|
+
id: credential.id
|
|
185
|
+
})),
|
|
186
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
187
|
+
var _a2;
|
|
188
|
+
return {
|
|
189
|
+
identity: {
|
|
190
|
+
identityKey: member.key,
|
|
191
|
+
profile: {
|
|
192
|
+
displayName: (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services.SpaceMember.PresenceState.ONLINE : import_services.SpaceMember.PresenceState.OFFLINE
|
|
196
|
+
};
|
|
197
|
+
}),
|
|
198
|
+
pipeline: {
|
|
199
|
+
// TODO(burdon): Pick properties from credentials if needed.
|
|
200
|
+
// currentEpoch: space.dataPipeline.currentEpoch,
|
|
201
|
+
// appliedEpoch: space.dataPipeline.appliedEpoch,
|
|
202
|
+
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
203
|
+
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
204
|
+
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
205
|
+
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
206
|
+
// TODO(burdon): Empty?
|
|
207
|
+
dataFeeds: (_b = (_a = space.dataPipeline.pipelineState) == null ? void 0 : _a.feeds.map((feed) => feed.key)) != null ? _b : [],
|
|
208
|
+
startDataTimeframe: (_c = space.dataPipeline.pipelineState) == null ? void 0 : _c.startTimeframe,
|
|
209
|
+
currentDataTimeframe: (_d = space.dataPipeline.pipelineState) == null ? void 0 : _d.timeframe,
|
|
210
|
+
targetDataTimeframe: (_e = space.dataPipeline.pipelineState) == null ? void 0 : _e.targetTimeframe,
|
|
211
|
+
totalDataTimeframe: (_f = space.dataPipeline.pipelineState) == null ? void 0 : _f.endTimeframe
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
if (space.dataPipeline.itemManager) {
|
|
215
|
+
Object.assign(stats, {
|
|
216
|
+
properties: getProperties(space),
|
|
217
|
+
db: {
|
|
218
|
+
objects: space.dataPipeline.itemManager.entities.size
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
if (stats.metrics) {
|
|
223
|
+
const { open, ready } = stats.metrics;
|
|
224
|
+
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
225
|
+
}
|
|
226
|
+
return stats;
|
|
227
|
+
};
|
|
228
|
+
|
|
73
229
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
74
|
-
var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
|
|
75
230
|
var import_async11 = require("@dxos/async");
|
|
76
|
-
var
|
|
231
|
+
var import_credentials15 = require("@dxos/credentials");
|
|
77
232
|
var import_debug7 = require("@dxos/debug");
|
|
78
233
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
79
234
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
235
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
80
236
|
var import_keyring = require("@dxos/keyring");
|
|
81
237
|
var import_keys8 = require("@dxos/keys");
|
|
82
|
-
var
|
|
83
|
-
var
|
|
84
|
-
var
|
|
238
|
+
var import_log13 = require("@dxos/log");
|
|
239
|
+
var import_protocols9 = require("@dxos/protocols");
|
|
240
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
85
241
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
86
242
|
|
|
87
243
|
// packages/sdk/client-services/src/packlets/identity/authenticator.ts
|
|
88
244
|
var import_async = require("@dxos/async");
|
|
89
245
|
var import_context = require("@dxos/context");
|
|
90
|
-
var
|
|
91
|
-
var
|
|
92
|
-
var
|
|
93
|
-
var
|
|
94
|
-
var Credential =
|
|
246
|
+
var import_credentials3 = require("@dxos/credentials");
|
|
247
|
+
var import_log2 = require("@dxos/log");
|
|
248
|
+
var import_protocols2 = require("@dxos/protocols");
|
|
249
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
|
|
250
|
+
var Credential = import_protocols2.schema.getCodecForType("dxos.halo.credentials.Credential");
|
|
95
251
|
var createAuthProvider = (signer) => async (nonce) => {
|
|
96
252
|
const credential = await signer.createCredential({
|
|
97
253
|
assertion: {
|
|
@@ -114,20 +270,20 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
114
270
|
get verifier() {
|
|
115
271
|
return async (nonce, auth) => {
|
|
116
272
|
const credential = Credential.decode(auth);
|
|
117
|
-
(0,
|
|
273
|
+
(0, import_log2.log)("authenticating...", {
|
|
118
274
|
credential
|
|
119
275
|
}, {
|
|
120
|
-
F:
|
|
276
|
+
F: __dxlog_file2,
|
|
121
277
|
L: 59,
|
|
122
278
|
S: this,
|
|
123
279
|
C: (f, a) => f(...a)
|
|
124
280
|
});
|
|
125
|
-
const result = await (0,
|
|
281
|
+
const result = await (0, import_credentials3.verifyCredential)(credential);
|
|
126
282
|
if (result.kind === "fail") {
|
|
127
|
-
(0,
|
|
283
|
+
(0, import_log2.log)("Invalid credential", {
|
|
128
284
|
result
|
|
129
285
|
}, {
|
|
130
|
-
F:
|
|
286
|
+
F: __dxlog_file2,
|
|
131
287
|
L: 63,
|
|
132
288
|
S: this,
|
|
133
289
|
C: (f, a) => f(...a)
|
|
@@ -135,11 +291,11 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
135
291
|
return false;
|
|
136
292
|
}
|
|
137
293
|
if (!credential.proof.nonce || !Buffer.from(nonce).equals(credential.proof.nonce)) {
|
|
138
|
-
(0,
|
|
294
|
+
(0, import_log2.log)("Invalid nonce", {
|
|
139
295
|
nonce,
|
|
140
296
|
credential
|
|
141
297
|
}, {
|
|
142
|
-
F:
|
|
298
|
+
F: __dxlog_file2,
|
|
143
299
|
L: 68,
|
|
144
300
|
S: this,
|
|
145
301
|
C: (f, a) => f(...a)
|
|
@@ -147,10 +303,10 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
147
303
|
return false;
|
|
148
304
|
}
|
|
149
305
|
if (this._isTrustedKey(credential.issuer)) {
|
|
150
|
-
(0,
|
|
306
|
+
(0, import_log2.log)("key is not currently in trusted set, waiting...", {
|
|
151
307
|
key: credential.issuer
|
|
152
308
|
}, {
|
|
153
|
-
F:
|
|
309
|
+
F: __dxlog_file2,
|
|
154
310
|
L: 73,
|
|
155
311
|
S: this,
|
|
156
312
|
C: (f, a) => f(...a)
|
|
@@ -163,20 +319,20 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
163
319
|
});
|
|
164
320
|
const clear = this._params.update.on(this._ctx, () => {
|
|
165
321
|
if (this._isTrustedKey(credential.issuer)) {
|
|
166
|
-
(0,
|
|
322
|
+
(0, import_log2.log)("auth success", {
|
|
167
323
|
key: credential.issuer
|
|
168
324
|
}, {
|
|
169
|
-
F:
|
|
325
|
+
F: __dxlog_file2,
|
|
170
326
|
L: 84,
|
|
171
327
|
S: this,
|
|
172
328
|
C: (f, a) => f(...a)
|
|
173
329
|
});
|
|
174
330
|
trigger.wake(true);
|
|
175
331
|
} else {
|
|
176
|
-
(0,
|
|
332
|
+
(0, import_log2.log)("key is not currently in trusted set, waiting...", {
|
|
177
333
|
key: credential.issuer
|
|
178
334
|
}, {
|
|
179
|
-
F:
|
|
335
|
+
F: __dxlog_file2,
|
|
180
336
|
L: 87,
|
|
181
337
|
S: this,
|
|
182
338
|
C: (f, a) => f(...a)
|
|
@@ -201,15 +357,15 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
201
357
|
};
|
|
202
358
|
|
|
203
359
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
204
|
-
var import_tiny_invariant = __toESM(require("tiny-invariant"));
|
|
205
360
|
var import_async2 = require("@dxos/async");
|
|
206
361
|
var import_client_protocol = require("@dxos/client-protocol");
|
|
207
|
-
var
|
|
362
|
+
var import_credentials4 = require("@dxos/credentials");
|
|
208
363
|
var import_debug2 = require("@dxos/debug");
|
|
209
364
|
var import_feed_store = require("@dxos/feed-store");
|
|
210
|
-
var
|
|
211
|
-
var
|
|
212
|
-
var
|
|
365
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
366
|
+
var import_log3 = require("@dxos/log");
|
|
367
|
+
var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
368
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
213
369
|
var Identity = class {
|
|
214
370
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
215
371
|
this.stateUpdate = new import_async2.Event();
|
|
@@ -217,12 +373,12 @@ var Identity = class {
|
|
|
217
373
|
this._signer = signer;
|
|
218
374
|
this.identityKey = identityKey;
|
|
219
375
|
this.deviceKey = deviceKey;
|
|
220
|
-
this._deviceStateMachine = new
|
|
376
|
+
this._deviceStateMachine = new import_credentials4.DeviceStateMachine({
|
|
221
377
|
identityKey: this.identityKey,
|
|
222
378
|
deviceKey: this.deviceKey,
|
|
223
379
|
onUpdate: () => this.stateUpdate.emit()
|
|
224
380
|
});
|
|
225
|
-
this._profileStateMachine = new
|
|
381
|
+
this._profileStateMachine = new import_credentials4.ProfileStateMachine({
|
|
226
382
|
identityKey: this.identityKey,
|
|
227
383
|
onUpdate: () => this.stateUpdate.emit()
|
|
228
384
|
});
|
|
@@ -284,25 +440,33 @@ var Identity = class {
|
|
|
284
440
|
* Requires identity to be ready.
|
|
285
441
|
*/
|
|
286
442
|
getIdentityCredentialSigner() {
|
|
287
|
-
(0,
|
|
288
|
-
|
|
443
|
+
(0, import_invariant2.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
444
|
+
F: __dxlog_file3,
|
|
445
|
+
L: 134,
|
|
446
|
+
S: this,
|
|
447
|
+
A: [
|
|
448
|
+
"this._deviceStateMachine.deviceCredentialChain",
|
|
449
|
+
"'Device credential chain is not ready.'"
|
|
450
|
+
]
|
|
451
|
+
});
|
|
452
|
+
return (0, import_credentials4.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
|
|
289
453
|
}
|
|
290
454
|
/**
|
|
291
455
|
* Issues credentials as device.
|
|
292
456
|
*/
|
|
293
457
|
getDeviceCredentialSigner() {
|
|
294
|
-
return (0,
|
|
458
|
+
return (0, import_credentials4.createCredentialSignerWithKey)(this._signer, this.deviceKey);
|
|
295
459
|
}
|
|
296
460
|
async admitDevice({ deviceKey, controlFeedKey, dataFeedKey }) {
|
|
297
|
-
(0,
|
|
461
|
+
(0, import_log3.log)("Admitting device:", {
|
|
298
462
|
identityKey: this.identityKey,
|
|
299
463
|
hostDevice: this.deviceKey,
|
|
300
464
|
deviceKey,
|
|
301
465
|
controlFeedKey,
|
|
302
466
|
dataFeedKey
|
|
303
467
|
}, {
|
|
304
|
-
F:
|
|
305
|
-
L:
|
|
468
|
+
F: __dxlog_file3,
|
|
469
|
+
L: 150,
|
|
306
470
|
S: this,
|
|
307
471
|
C: (f, a) => f(...a)
|
|
308
472
|
});
|
|
@@ -323,7 +487,7 @@ var Identity = class {
|
|
|
323
487
|
spaceKey: this.haloSpaceKey,
|
|
324
488
|
deviceKey,
|
|
325
489
|
identityKey: this.identityKey,
|
|
326
|
-
designation:
|
|
490
|
+
designation: import_credentials5.AdmittedFeed.Designation.CONTROL
|
|
327
491
|
}
|
|
328
492
|
}),
|
|
329
493
|
await signer.createCredential({
|
|
@@ -333,7 +497,7 @@ var Identity = class {
|
|
|
333
497
|
spaceKey: this.haloSpaceKey,
|
|
334
498
|
deviceKey,
|
|
335
499
|
identityKey: this.identityKey,
|
|
336
|
-
designation:
|
|
500
|
+
designation: import_credentials5.AdmittedFeed.Designation.DATA
|
|
337
501
|
}
|
|
338
502
|
})
|
|
339
503
|
].map((credential) => ({
|
|
@@ -345,15 +509,15 @@ var Identity = class {
|
|
|
345
509
|
};
|
|
346
510
|
|
|
347
511
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
348
|
-
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
349
512
|
var import_async3 = require("@dxos/async");
|
|
350
|
-
var
|
|
513
|
+
var import_credentials6 = require("@dxos/credentials");
|
|
514
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
351
515
|
var import_keys2 = require("@dxos/keys");
|
|
352
|
-
var
|
|
353
|
-
var
|
|
354
|
-
var
|
|
516
|
+
var import_log4 = require("@dxos/log");
|
|
517
|
+
var import_protocols3 = require("@dxos/protocols");
|
|
518
|
+
var import_credentials7 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
355
519
|
var import_util = require("@dxos/util");
|
|
356
|
-
var
|
|
520
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
357
521
|
var IdentityManager = class {
|
|
358
522
|
// TODO(burdon): IdentityManagerParams.
|
|
359
523
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
@@ -370,21 +534,21 @@ var IdentityManager = class {
|
|
|
370
534
|
async open() {
|
|
371
535
|
var _a;
|
|
372
536
|
const traceId = import_keys2.PublicKey.random().toHex();
|
|
373
|
-
|
|
537
|
+
import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.begin({
|
|
374
538
|
id: traceId
|
|
375
539
|
}), {
|
|
376
|
-
F:
|
|
377
|
-
L:
|
|
540
|
+
F: __dxlog_file4,
|
|
541
|
+
L: 69,
|
|
378
542
|
S: this,
|
|
379
543
|
C: (f, a) => f(...a)
|
|
380
544
|
});
|
|
381
545
|
await this._metadataStore.load();
|
|
382
546
|
const identityRecord = this._metadataStore.getIdentityRecord();
|
|
383
|
-
(0,
|
|
547
|
+
(0, import_log4.log)("identity record", {
|
|
384
548
|
identityRecord
|
|
385
549
|
}, {
|
|
386
|
-
F:
|
|
387
|
-
L:
|
|
550
|
+
F: __dxlog_file4,
|
|
551
|
+
L: 73,
|
|
388
552
|
S: this,
|
|
389
553
|
C: (f, a) => f(...a)
|
|
390
554
|
});
|
|
@@ -392,22 +556,22 @@ var IdentityManager = class {
|
|
|
392
556
|
this._identity = await this._constructIdentity(identityRecord);
|
|
393
557
|
await this._identity.open();
|
|
394
558
|
await this._identity.ready();
|
|
395
|
-
|
|
559
|
+
import_log4.log.trace("dxos.halo.identity", {
|
|
396
560
|
identityKey: identityRecord.identityKey,
|
|
397
561
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
398
562
|
}, {
|
|
399
|
-
F:
|
|
400
|
-
L:
|
|
563
|
+
F: __dxlog_file4,
|
|
564
|
+
L: 78,
|
|
401
565
|
S: this,
|
|
402
566
|
C: (f, a) => f(...a)
|
|
403
567
|
});
|
|
404
568
|
this.stateUpdate.emit();
|
|
405
569
|
}
|
|
406
|
-
|
|
570
|
+
import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.end({
|
|
407
571
|
id: traceId
|
|
408
572
|
}), {
|
|
409
|
-
F:
|
|
410
|
-
L:
|
|
573
|
+
F: __dxlog_file4,
|
|
574
|
+
L: 84,
|
|
411
575
|
S: this,
|
|
412
576
|
C: (f, a) => f(...a)
|
|
413
577
|
});
|
|
@@ -418,10 +582,18 @@ var IdentityManager = class {
|
|
|
418
582
|
}
|
|
419
583
|
async createIdentity({ displayName } = {}) {
|
|
420
584
|
var _a;
|
|
421
|
-
(0,
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
585
|
+
(0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
|
|
586
|
+
F: __dxlog_file4,
|
|
587
|
+
L: 92,
|
|
588
|
+
S: this,
|
|
589
|
+
A: [
|
|
590
|
+
"!this._identity",
|
|
591
|
+
"'Identity already exists.'"
|
|
592
|
+
]
|
|
593
|
+
});
|
|
594
|
+
(0, import_log4.log)("creating identity...", void 0, {
|
|
595
|
+
F: __dxlog_file4,
|
|
596
|
+
L: 93,
|
|
425
597
|
S: this,
|
|
426
598
|
C: (f, a) => f(...a)
|
|
427
599
|
});
|
|
@@ -439,14 +611,30 @@ var IdentityManager = class {
|
|
|
439
611
|
const identity = await this._constructIdentity(identityRecord);
|
|
440
612
|
await identity.open();
|
|
441
613
|
{
|
|
442
|
-
const generator = new
|
|
443
|
-
(0,
|
|
444
|
-
|
|
614
|
+
const generator = new import_credentials6.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
615
|
+
(0, import_invariant3.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
|
|
616
|
+
F: __dxlog_file4,
|
|
617
|
+
L: 112,
|
|
618
|
+
S: this,
|
|
619
|
+
A: [
|
|
620
|
+
"identityRecord.haloSpace.genesisFeedKey",
|
|
621
|
+
"'Genesis feed key is required.'"
|
|
622
|
+
]
|
|
623
|
+
});
|
|
624
|
+
(0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
|
|
625
|
+
F: __dxlog_file4,
|
|
626
|
+
L: 113,
|
|
627
|
+
S: this,
|
|
628
|
+
A: [
|
|
629
|
+
"identityRecord.haloSpace.dataFeedKey",
|
|
630
|
+
"'Data feed key is required.'"
|
|
631
|
+
]
|
|
632
|
+
});
|
|
445
633
|
const credentials = [
|
|
446
634
|
// Space genesis.
|
|
447
635
|
...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
|
|
448
636
|
// Feed admission.
|
|
449
|
-
await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey,
|
|
637
|
+
await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, import_credentials7.AdmittedFeed.Designation.DATA)
|
|
450
638
|
];
|
|
451
639
|
if (displayName) {
|
|
452
640
|
credentials.push(await generator.createProfileCredential({
|
|
@@ -465,22 +653,22 @@ var IdentityManager = class {
|
|
|
465
653
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
466
654
|
this._identity = identity;
|
|
467
655
|
await this._identity.ready();
|
|
468
|
-
|
|
656
|
+
import_log4.log.trace("dxos.halo.identity", {
|
|
469
657
|
identityKey: identityRecord.identityKey,
|
|
470
658
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
471
659
|
}, {
|
|
472
|
-
F:
|
|
473
|
-
L:
|
|
660
|
+
F: __dxlog_file4,
|
|
661
|
+
L: 148,
|
|
474
662
|
S: this,
|
|
475
663
|
C: (f, a) => f(...a)
|
|
476
664
|
});
|
|
477
665
|
this.stateUpdate.emit();
|
|
478
|
-
(0,
|
|
666
|
+
(0, import_log4.log)("created identity", {
|
|
479
667
|
identityKey: identity.identityKey,
|
|
480
668
|
deviceKey: identity.deviceKey
|
|
481
669
|
}, {
|
|
482
|
-
F:
|
|
483
|
-
L:
|
|
670
|
+
F: __dxlog_file4,
|
|
671
|
+
L: 154,
|
|
484
672
|
S: this,
|
|
485
673
|
C: (f, a) => f(...a)
|
|
486
674
|
});
|
|
@@ -491,15 +679,23 @@ var IdentityManager = class {
|
|
|
491
679
|
*/
|
|
492
680
|
async acceptIdentity(params) {
|
|
493
681
|
var _a;
|
|
494
|
-
(0,
|
|
682
|
+
(0, import_log4.log)("accepting identity", {
|
|
495
683
|
params
|
|
496
684
|
}, {
|
|
497
|
-
F:
|
|
498
|
-
L:
|
|
685
|
+
F: __dxlog_file4,
|
|
686
|
+
L: 162,
|
|
499
687
|
S: this,
|
|
500
688
|
C: (f, a) => f(...a)
|
|
501
689
|
});
|
|
502
|
-
(0,
|
|
690
|
+
(0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
|
|
691
|
+
F: __dxlog_file4,
|
|
692
|
+
L: 163,
|
|
693
|
+
S: this,
|
|
694
|
+
A: [
|
|
695
|
+
"!this._identity",
|
|
696
|
+
"'Identity already exists.'"
|
|
697
|
+
]
|
|
698
|
+
});
|
|
503
699
|
const identityRecord = {
|
|
504
700
|
identityKey: params.identityKey,
|
|
505
701
|
deviceKey: params.deviceKey,
|
|
@@ -516,42 +712,66 @@ var IdentityManager = class {
|
|
|
516
712
|
this._identity = identity;
|
|
517
713
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
518
714
|
await this._identity.ready();
|
|
519
|
-
|
|
715
|
+
import_log4.log.trace("dxos.halo.identity", {
|
|
520
716
|
identityKey: identityRecord.identityKey,
|
|
521
717
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
522
718
|
}, {
|
|
523
|
-
F:
|
|
524
|
-
L:
|
|
719
|
+
F: __dxlog_file4,
|
|
720
|
+
L: 182,
|
|
525
721
|
S: this,
|
|
526
722
|
C: (f, a) => f(...a)
|
|
527
723
|
});
|
|
528
724
|
this.stateUpdate.emit();
|
|
529
|
-
(0,
|
|
725
|
+
(0, import_log4.log)("accepted identity", {
|
|
530
726
|
identityKey: identity.identityKey,
|
|
531
727
|
deviceKey: identity.deviceKey
|
|
532
728
|
}, {
|
|
533
|
-
F:
|
|
534
|
-
L:
|
|
729
|
+
F: __dxlog_file4,
|
|
730
|
+
L: 188,
|
|
535
731
|
S: this,
|
|
536
732
|
C: (f, a) => f(...a)
|
|
537
733
|
});
|
|
538
734
|
return identity;
|
|
539
735
|
}
|
|
540
736
|
async _constructIdentity(identityRecord) {
|
|
541
|
-
(0,
|
|
542
|
-
|
|
737
|
+
(0, import_invariant3.invariant)(!this._identity, void 0, {
|
|
738
|
+
F: __dxlog_file4,
|
|
739
|
+
L: 193,
|
|
740
|
+
S: this,
|
|
741
|
+
A: [
|
|
742
|
+
"!this._identity",
|
|
743
|
+
""
|
|
744
|
+
]
|
|
745
|
+
});
|
|
746
|
+
(0, import_log4.log)("constructing identity", {
|
|
543
747
|
identityRecord
|
|
544
748
|
}, {
|
|
545
|
-
F:
|
|
546
|
-
L:
|
|
749
|
+
F: __dxlog_file4,
|
|
750
|
+
L: 194,
|
|
547
751
|
S: this,
|
|
548
752
|
C: (f, a) => f(...a)
|
|
549
753
|
});
|
|
550
|
-
(0,
|
|
754
|
+
(0, import_invariant3.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
755
|
+
F: __dxlog_file4,
|
|
756
|
+
L: 197,
|
|
757
|
+
S: this,
|
|
758
|
+
A: [
|
|
759
|
+
"identityRecord.haloSpace.controlFeedKey",
|
|
760
|
+
""
|
|
761
|
+
]
|
|
762
|
+
});
|
|
551
763
|
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
|
|
552
764
|
writable: true
|
|
553
765
|
});
|
|
554
|
-
(0,
|
|
766
|
+
(0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
767
|
+
F: __dxlog_file4,
|
|
768
|
+
L: 201,
|
|
769
|
+
S: this,
|
|
770
|
+
A: [
|
|
771
|
+
"identityRecord.haloSpace.dataFeedKey",
|
|
772
|
+
""
|
|
773
|
+
]
|
|
774
|
+
});
|
|
555
775
|
const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
|
|
556
776
|
writable: true,
|
|
557
777
|
sparse: true
|
|
@@ -560,7 +780,7 @@ var IdentityManager = class {
|
|
|
560
780
|
spaceRecord: identityRecord.haloSpace,
|
|
561
781
|
swarmIdentity: {
|
|
562
782
|
peerKey: identityRecord.deviceKey,
|
|
563
|
-
credentialProvider: createAuthProvider((0,
|
|
783
|
+
credentialProvider: createAuthProvider((0, import_credentials6.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
|
|
564
784
|
credentialAuthenticator: (0, import_util.deferFunction)(() => identity.authVerifier.verifier)
|
|
565
785
|
},
|
|
566
786
|
identityKey: identityRecord.identityKey
|
|
@@ -573,11 +793,11 @@ var IdentityManager = class {
|
|
|
573
793
|
identityKey: identityRecord.identityKey,
|
|
574
794
|
deviceKey: identityRecord.deviceKey
|
|
575
795
|
});
|
|
576
|
-
(0,
|
|
796
|
+
(0, import_log4.log)("done", {
|
|
577
797
|
identityKey: identityRecord.identityKey
|
|
578
798
|
}, {
|
|
579
|
-
F:
|
|
580
|
-
L:
|
|
799
|
+
F: __dxlog_file4,
|
|
800
|
+
L: 225,
|
|
581
801
|
S: this,
|
|
582
802
|
C: (f, a) => f(...a)
|
|
583
803
|
});
|
|
@@ -596,9 +816,9 @@ var IdentityManager = class {
|
|
|
596
816
|
onNetworkConnection: () => {
|
|
597
817
|
},
|
|
598
818
|
onAuthFailure: () => {
|
|
599
|
-
|
|
600
|
-
F:
|
|
601
|
-
L:
|
|
819
|
+
import_log4.log.warn("auth failure", void 0, {
|
|
820
|
+
F: __dxlog_file4,
|
|
821
|
+
L: 244,
|
|
602
822
|
S: this,
|
|
603
823
|
C: (f, a) => f(...a)
|
|
604
824
|
});
|
|
@@ -609,10 +829,11 @@ var IdentityManager = class {
|
|
|
609
829
|
};
|
|
610
830
|
|
|
611
831
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
612
|
-
var
|
|
613
|
-
var
|
|
614
|
-
var import_credentials7 = require("@dxos/credentials");
|
|
832
|
+
var import_codec_protobuf3 = require("@dxos/codec-protobuf");
|
|
833
|
+
var import_credentials8 = require("@dxos/credentials");
|
|
615
834
|
var import_debug3 = require("@dxos/debug");
|
|
835
|
+
var import_invariant4 = require("@dxos/invariant");
|
|
836
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
616
837
|
var IdentityServiceImpl = class {
|
|
617
838
|
// TODO(wittjosiah): Remove dependency on service context.
|
|
618
839
|
constructor(_serviceContext) {
|
|
@@ -626,7 +847,7 @@ var IdentityServiceImpl = class {
|
|
|
626
847
|
return (0, import_debug3.todo)();
|
|
627
848
|
}
|
|
628
849
|
queryIdentity() {
|
|
629
|
-
return new
|
|
850
|
+
return new import_codec_protobuf3.Stream(({ next }) => {
|
|
630
851
|
const emitNext = () => next({
|
|
631
852
|
identity: this._getIdentity()
|
|
632
853
|
});
|
|
@@ -645,8 +866,16 @@ var IdentityServiceImpl = class {
|
|
|
645
866
|
};
|
|
646
867
|
}
|
|
647
868
|
async signPresentation({ presentation, nonce }) {
|
|
648
|
-
(0,
|
|
649
|
-
|
|
869
|
+
(0, import_invariant4.invariant)(this._serviceContext.identityManager.identity, "Identity not initialized.", {
|
|
870
|
+
F: __dxlog_file5,
|
|
871
|
+
L: 56,
|
|
872
|
+
S: this,
|
|
873
|
+
A: [
|
|
874
|
+
"this._serviceContext.identityManager.identity",
|
|
875
|
+
"'Identity not initialized.'"
|
|
876
|
+
]
|
|
877
|
+
});
|
|
878
|
+
return await (0, import_credentials8.signPresentation)({
|
|
650
879
|
presentation,
|
|
651
880
|
signer: this._serviceContext.keyring,
|
|
652
881
|
signerKey: this._serviceContext.identityManager.identity.deviceKey,
|
|
@@ -657,8 +886,9 @@ var IdentityServiceImpl = class {
|
|
|
657
886
|
};
|
|
658
887
|
|
|
659
888
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
660
|
-
var
|
|
661
|
-
var
|
|
889
|
+
var import_invariant5 = require("@dxos/invariant");
|
|
890
|
+
var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
891
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
|
|
662
892
|
var DeviceInvitationProtocol = class {
|
|
663
893
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
664
894
|
this._keyring = _keyring;
|
|
@@ -670,11 +900,19 @@ var DeviceInvitationProtocol = class {
|
|
|
670
900
|
}
|
|
671
901
|
getInvitationContext() {
|
|
672
902
|
return {
|
|
673
|
-
kind:
|
|
903
|
+
kind: import_services2.Invitation.Kind.DEVICE
|
|
674
904
|
};
|
|
675
905
|
}
|
|
676
906
|
async admit(request) {
|
|
677
|
-
(0,
|
|
907
|
+
(0, import_invariant5.invariant)(request.device, void 0, {
|
|
908
|
+
F: __dxlog_file6,
|
|
909
|
+
L: 31,
|
|
910
|
+
S: this,
|
|
911
|
+
A: [
|
|
912
|
+
"request.device",
|
|
913
|
+
""
|
|
914
|
+
]
|
|
915
|
+
});
|
|
678
916
|
const identity = this._getIdentity();
|
|
679
917
|
await identity.admitDevice(request.device);
|
|
680
918
|
return {
|
|
@@ -702,9 +940,25 @@ var DeviceInvitationProtocol = class {
|
|
|
702
940
|
};
|
|
703
941
|
}
|
|
704
942
|
async accept(response, request) {
|
|
705
|
-
(0,
|
|
943
|
+
(0, import_invariant5.invariant)(response.device, void 0, {
|
|
944
|
+
F: __dxlog_file6,
|
|
945
|
+
L: 64,
|
|
946
|
+
S: this,
|
|
947
|
+
A: [
|
|
948
|
+
"response.device",
|
|
949
|
+
""
|
|
950
|
+
]
|
|
951
|
+
});
|
|
706
952
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
707
|
-
(0,
|
|
953
|
+
(0, import_invariant5.invariant)(request.device, void 0, {
|
|
954
|
+
F: __dxlog_file6,
|
|
955
|
+
L: 67,
|
|
956
|
+
S: this,
|
|
957
|
+
A: [
|
|
958
|
+
"request.device",
|
|
959
|
+
""
|
|
960
|
+
]
|
|
961
|
+
});
|
|
708
962
|
const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
|
|
709
963
|
await this._acceptIdentity({
|
|
710
964
|
identityKey,
|
|
@@ -722,41 +976,41 @@ var DeviceInvitationProtocol = class {
|
|
|
722
976
|
};
|
|
723
977
|
|
|
724
978
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
725
|
-
var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
|
|
726
979
|
var import_async5 = require("@dxos/async");
|
|
727
980
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
728
981
|
var import_context3 = require("@dxos/context");
|
|
729
|
-
var
|
|
982
|
+
var import_credentials9 = require("@dxos/credentials");
|
|
730
983
|
var import_errors2 = require("@dxos/errors");
|
|
984
|
+
var import_invariant7 = require("@dxos/invariant");
|
|
731
985
|
var import_keys4 = require("@dxos/keys");
|
|
732
|
-
var
|
|
986
|
+
var import_log6 = require("@dxos/log");
|
|
733
987
|
var import_network_manager = require("@dxos/network-manager");
|
|
734
|
-
var
|
|
735
|
-
var
|
|
988
|
+
var import_protocols5 = require("@dxos/protocols");
|
|
989
|
+
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
736
990
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
737
991
|
|
|
738
992
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
739
|
-
var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
|
|
740
993
|
var import_async4 = require("@dxos/async");
|
|
741
994
|
var import_context2 = require("@dxos/context");
|
|
742
995
|
var import_errors = require("@dxos/errors");
|
|
996
|
+
var import_invariant6 = require("@dxos/invariant");
|
|
743
997
|
var import_keys3 = require("@dxos/keys");
|
|
744
|
-
var
|
|
745
|
-
var
|
|
746
|
-
var
|
|
998
|
+
var import_log5 = require("@dxos/log");
|
|
999
|
+
var import_protocols4 = require("@dxos/protocols");
|
|
1000
|
+
var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
747
1001
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
748
1002
|
var import_teleport = require("@dxos/teleport");
|
|
749
|
-
var
|
|
1003
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
|
|
750
1004
|
var OPTIONS_TIMEOUT = 1e4;
|
|
751
1005
|
var MAX_OTP_ATTEMPTS = 3;
|
|
752
1006
|
var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
753
1007
|
constructor(_callbacks) {
|
|
754
1008
|
super({
|
|
755
1009
|
requested: {
|
|
756
|
-
InvitationHostService:
|
|
1010
|
+
InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
757
1011
|
},
|
|
758
1012
|
exposed: {
|
|
759
|
-
InvitationHostService:
|
|
1013
|
+
InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
760
1014
|
}
|
|
761
1015
|
});
|
|
762
1016
|
this._callbacks = _callbacks;
|
|
@@ -774,88 +1028,104 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
774
1028
|
// Perhaps in the future we will have more complex logic here.
|
|
775
1029
|
InvitationHostService: {
|
|
776
1030
|
options: async (options) => {
|
|
777
|
-
(0,
|
|
1031
|
+
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1032
|
+
F: __dxlog_file7,
|
|
1033
|
+
L: 88,
|
|
1034
|
+
S: this,
|
|
1035
|
+
A: [
|
|
1036
|
+
"!this._remoteOptions",
|
|
1037
|
+
"'Remote options already set.'"
|
|
1038
|
+
]
|
|
1039
|
+
});
|
|
778
1040
|
this._remoteOptions = options;
|
|
779
1041
|
this._remoteOptionsTrigger.wake();
|
|
780
1042
|
},
|
|
781
1043
|
introduce: async (request) => {
|
|
782
1044
|
const { profile, invitationId } = request;
|
|
783
1045
|
const traceId = import_keys3.PublicKey.random().toHex();
|
|
784
|
-
|
|
1046
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols4.trace.begin({
|
|
785
1047
|
id: traceId
|
|
786
1048
|
}), {
|
|
787
|
-
F:
|
|
788
|
-
L:
|
|
1049
|
+
F: __dxlog_file7,
|
|
1050
|
+
L: 97,
|
|
789
1051
|
S: this,
|
|
790
1052
|
C: (f, a) => f(...a)
|
|
791
1053
|
});
|
|
792
1054
|
const invitation = await this._callbacks.resolveInvitation(request);
|
|
793
1055
|
if (!invitation) {
|
|
794
|
-
|
|
1056
|
+
import_log5.log.warn("invitation not found", {
|
|
795
1057
|
invitationId
|
|
796
1058
|
}, {
|
|
797
|
-
F:
|
|
798
|
-
L:
|
|
1059
|
+
F: __dxlog_file7,
|
|
1060
|
+
L: 101,
|
|
799
1061
|
S: this,
|
|
800
1062
|
C: (f, a) => f(...a)
|
|
801
1063
|
});
|
|
802
1064
|
this._callbacks.onError(new Error("Invitation not found."));
|
|
803
1065
|
return {
|
|
804
|
-
authMethod:
|
|
1066
|
+
authMethod: import_services3.Invitation.AuthMethod.NONE
|
|
805
1067
|
};
|
|
806
1068
|
}
|
|
807
1069
|
this.invitation = invitation;
|
|
808
|
-
(0,
|
|
1070
|
+
(0, import_log5.log)("guest introduced itself", {
|
|
809
1071
|
guestProfile: profile
|
|
810
1072
|
}, {
|
|
811
|
-
F:
|
|
812
|
-
L:
|
|
1073
|
+
F: __dxlog_file7,
|
|
1074
|
+
L: 110,
|
|
813
1075
|
S: this,
|
|
814
1076
|
C: (f, a) => f(...a)
|
|
815
1077
|
});
|
|
816
1078
|
this.guestProfile = profile;
|
|
817
1079
|
this._callbacks.onStateUpdate({
|
|
818
1080
|
...this.invitation,
|
|
819
|
-
state:
|
|
1081
|
+
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
820
1082
|
});
|
|
821
|
-
|
|
1083
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols4.trace.end({
|
|
822
1084
|
id: traceId
|
|
823
1085
|
}), {
|
|
824
|
-
F:
|
|
825
|
-
L:
|
|
1086
|
+
F: __dxlog_file7,
|
|
1087
|
+
L: 117,
|
|
826
1088
|
S: this,
|
|
827
1089
|
C: (f, a) => f(...a)
|
|
828
1090
|
});
|
|
829
1091
|
return {
|
|
830
|
-
spaceKey: this.invitation.authMethod ===
|
|
1092
|
+
spaceKey: this.invitation.authMethod === import_services3.Invitation.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
|
|
831
1093
|
authMethod: this.invitation.authMethod
|
|
832
1094
|
};
|
|
833
1095
|
},
|
|
834
1096
|
authenticate: async ({ authCode: code }) => {
|
|
835
1097
|
const traceId = import_keys3.PublicKey.random().toHex();
|
|
836
|
-
|
|
1098
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols4.trace.begin({
|
|
837
1099
|
id: traceId
|
|
838
1100
|
}), {
|
|
839
|
-
F:
|
|
840
|
-
L:
|
|
1101
|
+
F: __dxlog_file7,
|
|
1102
|
+
L: 126,
|
|
841
1103
|
S: this,
|
|
842
1104
|
C: (f, a) => f(...a)
|
|
843
1105
|
});
|
|
844
|
-
(0,
|
|
1106
|
+
(0, import_log5.log)("received authentication request", {
|
|
845
1107
|
authCode: code
|
|
846
1108
|
}, {
|
|
847
|
-
F:
|
|
848
|
-
L:
|
|
1109
|
+
F: __dxlog_file7,
|
|
1110
|
+
L: 127,
|
|
849
1111
|
S: this,
|
|
850
1112
|
C: (f, a) => f(...a)
|
|
851
1113
|
});
|
|
852
1114
|
let status = import_invitations.AuthenticationResponse.Status.OK;
|
|
853
|
-
(0,
|
|
1115
|
+
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1116
|
+
F: __dxlog_file7,
|
|
1117
|
+
L: 130,
|
|
1118
|
+
S: this,
|
|
1119
|
+
A: [
|
|
1120
|
+
"this.invitation",
|
|
1121
|
+
"'Invitation is not set.'"
|
|
1122
|
+
]
|
|
1123
|
+
});
|
|
854
1124
|
switch (this.invitation.authMethod) {
|
|
855
|
-
case
|
|
856
|
-
(0,
|
|
857
|
-
F:
|
|
858
|
-
L:
|
|
1125
|
+
case import_services3.Invitation.AuthMethod.NONE: {
|
|
1126
|
+
(0, import_log5.log)("authentication not required", void 0, {
|
|
1127
|
+
F: __dxlog_file7,
|
|
1128
|
+
L: 133,
|
|
859
1129
|
S: this,
|
|
860
1130
|
C: (f, a) => f(...a)
|
|
861
1131
|
});
|
|
@@ -863,7 +1133,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
863
1133
|
status: import_invitations.AuthenticationResponse.Status.OK
|
|
864
1134
|
};
|
|
865
1135
|
}
|
|
866
|
-
case
|
|
1136
|
+
case import_services3.Invitation.AuthMethod.SHARED_SECRET: {
|
|
867
1137
|
if (this.invitation.authCode) {
|
|
868
1138
|
if (this.authenticationRetry++ > MAX_OTP_ATTEMPTS) {
|
|
869
1139
|
status = import_invitations.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
|
|
@@ -876,11 +1146,11 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
876
1146
|
break;
|
|
877
1147
|
}
|
|
878
1148
|
default: {
|
|
879
|
-
|
|
1149
|
+
import_log5.log.error("invalid authentication method", {
|
|
880
1150
|
authMethod: this.invitation.authMethod
|
|
881
1151
|
}, {
|
|
882
|
-
F:
|
|
883
|
-
L:
|
|
1152
|
+
F: __dxlog_file7,
|
|
1153
|
+
L: 151,
|
|
884
1154
|
S: this,
|
|
885
1155
|
C: (f, a) => f(...a)
|
|
886
1156
|
});
|
|
@@ -888,14 +1158,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
888
1158
|
break;
|
|
889
1159
|
}
|
|
890
1160
|
}
|
|
891
|
-
|
|
1161
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols4.trace.end({
|
|
892
1162
|
id: traceId,
|
|
893
1163
|
data: {
|
|
894
1164
|
status
|
|
895
1165
|
}
|
|
896
1166
|
}), {
|
|
897
|
-
F:
|
|
898
|
-
L:
|
|
1167
|
+
F: __dxlog_file7,
|
|
1168
|
+
L: 157,
|
|
899
1169
|
S: this,
|
|
900
1170
|
C: (f, a) => f(...a)
|
|
901
1171
|
});
|
|
@@ -905,25 +1175,33 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
905
1175
|
},
|
|
906
1176
|
admit: async (request) => {
|
|
907
1177
|
const traceId = import_keys3.PublicKey.random().toHex();
|
|
908
|
-
|
|
1178
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols4.trace.begin({
|
|
909
1179
|
id: traceId
|
|
910
1180
|
}), {
|
|
911
|
-
F:
|
|
912
|
-
L:
|
|
1181
|
+
F: __dxlog_file7,
|
|
1182
|
+
L: 163,
|
|
913
1183
|
S: this,
|
|
914
1184
|
C: (f, a) => f(...a)
|
|
915
1185
|
});
|
|
916
1186
|
try {
|
|
917
|
-
(0,
|
|
1187
|
+
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1188
|
+
F: __dxlog_file7,
|
|
1189
|
+
L: 166,
|
|
1190
|
+
S: this,
|
|
1191
|
+
A: [
|
|
1192
|
+
"this.invitation",
|
|
1193
|
+
"'Invitation is not set.'"
|
|
1194
|
+
]
|
|
1195
|
+
});
|
|
918
1196
|
if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
|
|
919
1197
|
throw new Error("Not authenticated");
|
|
920
1198
|
}
|
|
921
1199
|
const response = await this._callbacks.admit(request);
|
|
922
|
-
|
|
1200
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols4.trace.end({
|
|
923
1201
|
id: traceId
|
|
924
1202
|
}), {
|
|
925
|
-
F:
|
|
926
|
-
L:
|
|
1203
|
+
F: __dxlog_file7,
|
|
1204
|
+
L: 174,
|
|
927
1205
|
S: this,
|
|
928
1206
|
C: (f, a) => f(...a)
|
|
929
1207
|
});
|
|
@@ -965,10 +1243,10 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
965
1243
|
constructor(_callbacks) {
|
|
966
1244
|
super({
|
|
967
1245
|
requested: {
|
|
968
|
-
InvitationHostService:
|
|
1246
|
+
InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
969
1247
|
},
|
|
970
1248
|
exposed: {
|
|
971
|
-
InvitationHostService:
|
|
1249
|
+
InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
972
1250
|
}
|
|
973
1251
|
});
|
|
974
1252
|
this._callbacks = _callbacks;
|
|
@@ -979,7 +1257,15 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
979
1257
|
return {
|
|
980
1258
|
InvitationHostService: {
|
|
981
1259
|
options: async (options) => {
|
|
982
|
-
(0,
|
|
1260
|
+
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1261
|
+
F: __dxlog_file7,
|
|
1262
|
+
L: 241,
|
|
1263
|
+
S: this,
|
|
1264
|
+
A: [
|
|
1265
|
+
"!this._remoteOptions",
|
|
1266
|
+
"'Remote options already set.'"
|
|
1267
|
+
]
|
|
1268
|
+
});
|
|
983
1269
|
this._remoteOptions = options;
|
|
984
1270
|
this._remoteOptionsTrigger.wake();
|
|
985
1271
|
},
|
|
@@ -999,9 +1285,9 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
999
1285
|
var _a;
|
|
1000
1286
|
await super.onOpen(context);
|
|
1001
1287
|
try {
|
|
1002
|
-
(0,
|
|
1003
|
-
F:
|
|
1004
|
-
L:
|
|
1288
|
+
(0, import_log5.log)("begin options", void 0, {
|
|
1289
|
+
F: __dxlog_file7,
|
|
1290
|
+
L: 262,
|
|
1005
1291
|
S: this,
|
|
1006
1292
|
C: (f, a) => f(...a)
|
|
1007
1293
|
});
|
|
@@ -1011,9 +1297,9 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1011
1297
|
await (0, import_context2.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1012
1298
|
timeout: OPTIONS_TIMEOUT
|
|
1013
1299
|
}));
|
|
1014
|
-
(0,
|
|
1015
|
-
F:
|
|
1016
|
-
L:
|
|
1300
|
+
(0, import_log5.log)("end options", void 0, {
|
|
1301
|
+
F: __dxlog_file7,
|
|
1302
|
+
L: 265,
|
|
1017
1303
|
S: this,
|
|
1018
1304
|
C: (f, a) => f(...a)
|
|
1019
1305
|
});
|
|
@@ -1025,9 +1311,9 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1025
1311
|
}
|
|
1026
1312
|
this._callbacks.onOpen(this._ctx);
|
|
1027
1313
|
} catch (err) {
|
|
1028
|
-
(0,
|
|
1029
|
-
F:
|
|
1030
|
-
L:
|
|
1314
|
+
(0, import_log5.log)("openError", err, {
|
|
1315
|
+
F: __dxlog_file7,
|
|
1316
|
+
L: 275,
|
|
1031
1317
|
S: this,
|
|
1032
1318
|
C: (f, a) => f(...a)
|
|
1033
1319
|
});
|
|
@@ -1035,19 +1321,19 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1035
1321
|
}
|
|
1036
1322
|
}
|
|
1037
1323
|
async onClose() {
|
|
1038
|
-
(0,
|
|
1039
|
-
F:
|
|
1040
|
-
L:
|
|
1324
|
+
(0, import_log5.log)("onClose", void 0, {
|
|
1325
|
+
F: __dxlog_file7,
|
|
1326
|
+
L: 281,
|
|
1041
1327
|
S: this,
|
|
1042
1328
|
C: (f, a) => f(...a)
|
|
1043
1329
|
});
|
|
1044
1330
|
await this._ctx.dispose();
|
|
1045
1331
|
}
|
|
1046
1332
|
};
|
|
1047
|
-
var isAuthenticationRequired = (invitation) => invitation.authMethod !==
|
|
1333
|
+
var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services3.Invitation.AuthMethod.NONE;
|
|
1048
1334
|
|
|
1049
1335
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1050
|
-
var
|
|
1336
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
1051
1337
|
var InvitationsHandler = class {
|
|
1052
1338
|
/**
|
|
1053
1339
|
* @internal
|
|
@@ -1057,9 +1343,17 @@ var InvitationsHandler = class {
|
|
|
1057
1343
|
}
|
|
1058
1344
|
createInvitation(protocol, options) {
|
|
1059
1345
|
var _a;
|
|
1060
|
-
const { invitationId = import_keys4.PublicKey.random().toHex(), type =
|
|
1061
|
-
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod ===
|
|
1062
|
-
(0,
|
|
1346
|
+
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 != null ? options : {};
|
|
1347
|
+
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services4.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials9.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
|
|
1348
|
+
(0, import_invariant7.invariant)(protocol, void 0, {
|
|
1349
|
+
F: __dxlog_file8,
|
|
1350
|
+
L: 76,
|
|
1351
|
+
S: this,
|
|
1352
|
+
A: [
|
|
1353
|
+
"protocol",
|
|
1354
|
+
""
|
|
1355
|
+
]
|
|
1356
|
+
});
|
|
1063
1357
|
const invitation = {
|
|
1064
1358
|
invitationId,
|
|
1065
1359
|
type,
|
|
@@ -1078,11 +1372,11 @@ var InvitationsHandler = class {
|
|
|
1078
1372
|
}
|
|
1079
1373
|
});
|
|
1080
1374
|
ctx.onDispose(() => {
|
|
1081
|
-
(0,
|
|
1375
|
+
(0, import_log6.log)("complete", {
|
|
1082
1376
|
...protocol.toJSON()
|
|
1083
1377
|
}, {
|
|
1084
|
-
F:
|
|
1085
|
-
L:
|
|
1378
|
+
F: __dxlog_file8,
|
|
1379
|
+
L: 98,
|
|
1086
1380
|
S: this,
|
|
1087
1381
|
C: (f, a) => f(...a)
|
|
1088
1382
|
});
|
|
@@ -1093,7 +1387,7 @@ var InvitationsHandler = class {
|
|
|
1093
1387
|
onStateUpdate: (invitation2) => {
|
|
1094
1388
|
stream.next({
|
|
1095
1389
|
...invitation2,
|
|
1096
|
-
state:
|
|
1390
|
+
state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1097
1391
|
});
|
|
1098
1392
|
},
|
|
1099
1393
|
resolveInvitation: async ({ invitationId: invitationId2 }) => {
|
|
@@ -1106,7 +1400,15 @@ var InvitationsHandler = class {
|
|
|
1106
1400
|
var _a2, _b, _c;
|
|
1107
1401
|
try {
|
|
1108
1402
|
const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
|
|
1109
|
-
(0,
|
|
1403
|
+
(0, import_invariant7.invariant)(deviceKey, void 0, {
|
|
1404
|
+
F: __dxlog_file8,
|
|
1405
|
+
L: 119,
|
|
1406
|
+
S: this,
|
|
1407
|
+
A: [
|
|
1408
|
+
"deviceKey",
|
|
1409
|
+
""
|
|
1410
|
+
]
|
|
1411
|
+
});
|
|
1110
1412
|
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1111
1413
|
extension.completedTrigger.wake(deviceKey);
|
|
1112
1414
|
return admissionResponse;
|
|
@@ -1119,84 +1421,84 @@ var InvitationsHandler = class {
|
|
|
1119
1421
|
(0, import_async5.scheduleTask)(ctx, async () => {
|
|
1120
1422
|
const traceId = import_keys4.PublicKey.random().toHex();
|
|
1121
1423
|
try {
|
|
1122
|
-
|
|
1424
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.begin({
|
|
1123
1425
|
id: traceId
|
|
1124
1426
|
}), {
|
|
1125
|
-
F:
|
|
1126
|
-
L:
|
|
1427
|
+
F: __dxlog_file8,
|
|
1428
|
+
L: 137,
|
|
1127
1429
|
S: this,
|
|
1128
1430
|
C: (f, a) => f(...a)
|
|
1129
1431
|
});
|
|
1130
|
-
(0,
|
|
1432
|
+
(0, import_log6.log)("connected", {
|
|
1131
1433
|
...protocol.toJSON()
|
|
1132
1434
|
}, {
|
|
1133
|
-
F:
|
|
1134
|
-
L:
|
|
1435
|
+
F: __dxlog_file8,
|
|
1436
|
+
L: 138,
|
|
1135
1437
|
S: this,
|
|
1136
1438
|
C: (f, a) => f(...a)
|
|
1137
1439
|
});
|
|
1138
1440
|
stream.next({
|
|
1139
1441
|
...invitation,
|
|
1140
|
-
state:
|
|
1442
|
+
state: import_services4.Invitation.State.CONNECTED
|
|
1141
1443
|
});
|
|
1142
1444
|
const deviceKey = await extension.completedTrigger.wait({
|
|
1143
1445
|
timeout
|
|
1144
1446
|
});
|
|
1145
|
-
(0,
|
|
1447
|
+
(0, import_log6.log)("admitted guest", {
|
|
1146
1448
|
guest: deviceKey,
|
|
1147
1449
|
...protocol.toJSON()
|
|
1148
1450
|
}, {
|
|
1149
|
-
F:
|
|
1150
|
-
L:
|
|
1451
|
+
F: __dxlog_file8,
|
|
1452
|
+
L: 141,
|
|
1151
1453
|
S: this,
|
|
1152
1454
|
C: (f, a) => f(...a)
|
|
1153
1455
|
});
|
|
1154
1456
|
stream.next({
|
|
1155
1457
|
...invitation,
|
|
1156
|
-
state:
|
|
1458
|
+
state: import_services4.Invitation.State.SUCCESS
|
|
1157
1459
|
});
|
|
1158
|
-
|
|
1460
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.end({
|
|
1159
1461
|
id: traceId
|
|
1160
1462
|
}), {
|
|
1161
|
-
F:
|
|
1162
|
-
L:
|
|
1463
|
+
F: __dxlog_file8,
|
|
1464
|
+
L: 143,
|
|
1163
1465
|
S: this,
|
|
1164
1466
|
C: (f, a) => f(...a)
|
|
1165
1467
|
});
|
|
1166
1468
|
} catch (err) {
|
|
1167
1469
|
if (err instanceof import_async5.TimeoutError) {
|
|
1168
|
-
(0,
|
|
1470
|
+
(0, import_log6.log)("timeout", {
|
|
1169
1471
|
...protocol.toJSON()
|
|
1170
1472
|
}, {
|
|
1171
|
-
F:
|
|
1172
|
-
L:
|
|
1473
|
+
F: __dxlog_file8,
|
|
1474
|
+
L: 146,
|
|
1173
1475
|
S: this,
|
|
1174
1476
|
C: (f, a) => f(...a)
|
|
1175
1477
|
});
|
|
1176
1478
|
stream.next({
|
|
1177
1479
|
...invitation,
|
|
1178
|
-
state:
|
|
1480
|
+
state: import_services4.Invitation.State.TIMEOUT
|
|
1179
1481
|
});
|
|
1180
1482
|
} else {
|
|
1181
|
-
|
|
1182
|
-
F:
|
|
1183
|
-
L:
|
|
1483
|
+
import_log6.log.error("failed", err, {
|
|
1484
|
+
F: __dxlog_file8,
|
|
1485
|
+
L: 149,
|
|
1184
1486
|
S: this,
|
|
1185
1487
|
C: (f, a) => f(...a)
|
|
1186
1488
|
});
|
|
1187
1489
|
stream.error(err);
|
|
1188
1490
|
}
|
|
1189
|
-
|
|
1491
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.error({
|
|
1190
1492
|
id: traceId,
|
|
1191
1493
|
error: err
|
|
1192
1494
|
}), {
|
|
1193
|
-
F:
|
|
1194
|
-
L:
|
|
1495
|
+
F: __dxlog_file8,
|
|
1496
|
+
L: 152,
|
|
1195
1497
|
S: this,
|
|
1196
1498
|
C: (f, a) => f(...a)
|
|
1197
1499
|
});
|
|
1198
1500
|
} finally {
|
|
1199
|
-
if (type !==
|
|
1501
|
+
if (type !== import_services4.Invitation.Type.MULTIUSE) {
|
|
1200
1502
|
await swarmConnection.close();
|
|
1201
1503
|
await ctx.dispose();
|
|
1202
1504
|
}
|
|
@@ -1208,22 +1510,22 @@ var InvitationsHandler = class {
|
|
|
1208
1510
|
return;
|
|
1209
1511
|
}
|
|
1210
1512
|
if (err instanceof import_async5.TimeoutError) {
|
|
1211
|
-
(0,
|
|
1513
|
+
(0, import_log6.log)("timeout", {
|
|
1212
1514
|
...protocol.toJSON()
|
|
1213
1515
|
}, {
|
|
1214
|
-
F:
|
|
1215
|
-
L:
|
|
1516
|
+
F: __dxlog_file8,
|
|
1517
|
+
L: 167,
|
|
1216
1518
|
S: this,
|
|
1217
1519
|
C: (f, a) => f(...a)
|
|
1218
1520
|
});
|
|
1219
1521
|
stream.next({
|
|
1220
1522
|
...invitation,
|
|
1221
|
-
state:
|
|
1523
|
+
state: import_services4.Invitation.State.TIMEOUT
|
|
1222
1524
|
});
|
|
1223
1525
|
} else {
|
|
1224
|
-
|
|
1225
|
-
F:
|
|
1226
|
-
L:
|
|
1526
|
+
import_log6.log.error("failed", err, {
|
|
1527
|
+
F: __dxlog_file8,
|
|
1528
|
+
L: 170,
|
|
1227
1529
|
S: this,
|
|
1228
1530
|
C: (f, a) => f(...a)
|
|
1229
1531
|
});
|
|
@@ -1247,7 +1549,7 @@ var InvitationsHandler = class {
|
|
|
1247
1549
|
ctx.onDispose(() => swarmConnection.close());
|
|
1248
1550
|
stream.next({
|
|
1249
1551
|
...invitation,
|
|
1250
|
-
state:
|
|
1552
|
+
state: import_services4.Invitation.State.CONNECTING
|
|
1251
1553
|
});
|
|
1252
1554
|
});
|
|
1253
1555
|
const observable = new import_client_protocol2.CancellableInvitationObservable({
|
|
@@ -1256,7 +1558,7 @@ var InvitationsHandler = class {
|
|
|
1256
1558
|
onCancel: async () => {
|
|
1257
1559
|
stream.next({
|
|
1258
1560
|
...invitation,
|
|
1259
|
-
state:
|
|
1561
|
+
state: import_services4.Invitation.State.CANCELLED
|
|
1260
1562
|
});
|
|
1261
1563
|
await ctx.dispose();
|
|
1262
1564
|
}
|
|
@@ -1265,13 +1567,29 @@ var InvitationsHandler = class {
|
|
|
1265
1567
|
}
|
|
1266
1568
|
acceptInvitation(protocol, invitation) {
|
|
1267
1569
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
1268
|
-
(0,
|
|
1570
|
+
(0, import_invariant7.invariant)(protocol, void 0, {
|
|
1571
|
+
F: __dxlog_file8,
|
|
1572
|
+
L: 210,
|
|
1573
|
+
S: this,
|
|
1574
|
+
A: [
|
|
1575
|
+
"protocol",
|
|
1576
|
+
""
|
|
1577
|
+
]
|
|
1578
|
+
});
|
|
1269
1579
|
const authenticated = new import_async5.Trigger();
|
|
1270
1580
|
let admitted = false;
|
|
1271
1581
|
let currentState;
|
|
1272
1582
|
const stream = new import_async5.PushStream();
|
|
1273
1583
|
const setState = (newData) => {
|
|
1274
|
-
(0,
|
|
1584
|
+
(0, import_invariant7.invariant)(newData.state !== void 0, void 0, {
|
|
1585
|
+
F: __dxlog_file8,
|
|
1586
|
+
L: 221,
|
|
1587
|
+
S: this,
|
|
1588
|
+
A: [
|
|
1589
|
+
"newData.state !== undefined",
|
|
1590
|
+
""
|
|
1591
|
+
]
|
|
1592
|
+
});
|
|
1275
1593
|
currentState = newData.state;
|
|
1276
1594
|
stream.next({
|
|
1277
1595
|
...invitation,
|
|
@@ -1281,21 +1599,21 @@ var InvitationsHandler = class {
|
|
|
1281
1599
|
const ctx = new import_context3.Context({
|
|
1282
1600
|
onError: (err) => {
|
|
1283
1601
|
if (err instanceof import_async5.TimeoutError) {
|
|
1284
|
-
(0,
|
|
1602
|
+
(0, import_log6.log)("timeout", {
|
|
1285
1603
|
...protocol.toJSON()
|
|
1286
1604
|
}, {
|
|
1287
|
-
F:
|
|
1288
|
-
L:
|
|
1605
|
+
F: __dxlog_file8,
|
|
1606
|
+
L: 229,
|
|
1289
1607
|
S: this,
|
|
1290
1608
|
C: (f, a) => f(...a)
|
|
1291
1609
|
});
|
|
1292
1610
|
setState({
|
|
1293
|
-
state:
|
|
1611
|
+
state: import_services4.Invitation.State.TIMEOUT
|
|
1294
1612
|
});
|
|
1295
1613
|
} else {
|
|
1296
|
-
|
|
1297
|
-
F:
|
|
1298
|
-
L:
|
|
1614
|
+
import_log6.log.warn("auth failed", err, {
|
|
1615
|
+
F: __dxlog_file8,
|
|
1616
|
+
L: 232,
|
|
1299
1617
|
S: this,
|
|
1300
1618
|
C: (f, a) => f(...a)
|
|
1301
1619
|
});
|
|
@@ -1305,11 +1623,11 @@ var InvitationsHandler = class {
|
|
|
1305
1623
|
}
|
|
1306
1624
|
});
|
|
1307
1625
|
ctx.onDispose(() => {
|
|
1308
|
-
(0,
|
|
1626
|
+
(0, import_log6.log)("complete", {
|
|
1309
1627
|
...protocol.toJSON()
|
|
1310
1628
|
}, {
|
|
1311
|
-
F:
|
|
1312
|
-
L:
|
|
1629
|
+
F: __dxlog_file8,
|
|
1630
|
+
L: 240,
|
|
1313
1631
|
S: this,
|
|
1314
1632
|
C: (f, a) => f(...a)
|
|
1315
1633
|
});
|
|
@@ -1320,11 +1638,11 @@ var InvitationsHandler = class {
|
|
|
1320
1638
|
const extension = new InvitationGuestExtension({
|
|
1321
1639
|
onOpen: (extensionCtx) => {
|
|
1322
1640
|
extensionCtx.onDispose(async () => {
|
|
1323
|
-
(0,
|
|
1641
|
+
(0, import_log6.log)("extension disposed", {
|
|
1324
1642
|
currentState
|
|
1325
1643
|
}, {
|
|
1326
|
-
F:
|
|
1327
|
-
L:
|
|
1644
|
+
F: __dxlog_file8,
|
|
1645
|
+
L: 250,
|
|
1328
1646
|
S: this,
|
|
1329
1647
|
C: (f, a) => f(...a)
|
|
1330
1648
|
});
|
|
@@ -1335,11 +1653,11 @@ var InvitationsHandler = class {
|
|
|
1335
1653
|
(0, import_async5.scheduleTask)(ctx, async () => {
|
|
1336
1654
|
const traceId = import_keys4.PublicKey.random().toHex();
|
|
1337
1655
|
try {
|
|
1338
|
-
|
|
1656
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.begin({
|
|
1339
1657
|
id: traceId
|
|
1340
1658
|
}), {
|
|
1341
|
-
F:
|
|
1342
|
-
L:
|
|
1659
|
+
F: __dxlog_file8,
|
|
1660
|
+
L: 259,
|
|
1343
1661
|
S: this,
|
|
1344
1662
|
C: (f, a) => f(...a)
|
|
1345
1663
|
});
|
|
@@ -1347,32 +1665,32 @@ var InvitationsHandler = class {
|
|
|
1347
1665
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
1348
1666
|
}
|
|
1349
1667
|
(0, import_async5.scheduleTask)(ctx, () => ctx.raise(new import_async5.TimeoutError(timeout)), timeout);
|
|
1350
|
-
(0,
|
|
1668
|
+
(0, import_log6.log)("connected", {
|
|
1351
1669
|
...protocol.toJSON()
|
|
1352
1670
|
}, {
|
|
1353
|
-
F:
|
|
1354
|
-
L:
|
|
1671
|
+
F: __dxlog_file8,
|
|
1672
|
+
L: 267,
|
|
1355
1673
|
S: this,
|
|
1356
1674
|
C: (f, a) => f(...a)
|
|
1357
1675
|
});
|
|
1358
1676
|
setState({
|
|
1359
|
-
state:
|
|
1677
|
+
state: import_services4.Invitation.State.CONNECTED
|
|
1360
1678
|
});
|
|
1361
|
-
(0,
|
|
1679
|
+
(0, import_log6.log)("introduce", {
|
|
1362
1680
|
...protocol.toJSON()
|
|
1363
1681
|
}, {
|
|
1364
|
-
F:
|
|
1365
|
-
L:
|
|
1682
|
+
F: __dxlog_file8,
|
|
1683
|
+
L: 271,
|
|
1366
1684
|
S: this,
|
|
1367
1685
|
C: (f, a) => f(...a)
|
|
1368
1686
|
});
|
|
1369
1687
|
const introductionResponse = await extension.rpc.InvitationHostService.introduce(protocol.createIntroduction());
|
|
1370
|
-
(0,
|
|
1688
|
+
(0, import_log6.log)("introduce response", {
|
|
1371
1689
|
...protocol.toJSON(),
|
|
1372
1690
|
response: introductionResponse
|
|
1373
1691
|
}, {
|
|
1374
|
-
F:
|
|
1375
|
-
L:
|
|
1692
|
+
F: __dxlog_file8,
|
|
1693
|
+
L: 275,
|
|
1376
1694
|
S: this,
|
|
1377
1695
|
C: (f, a) => f(...a)
|
|
1378
1696
|
});
|
|
@@ -1382,26 +1700,26 @@ var InvitationsHandler = class {
|
|
|
1382
1700
|
}
|
|
1383
1701
|
if (isAuthenticationRequired(invitation)) {
|
|
1384
1702
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1385
|
-
(0,
|
|
1386
|
-
F:
|
|
1387
|
-
L:
|
|
1703
|
+
(0, import_log6.log)("guest waiting for authentication code...", void 0, {
|
|
1704
|
+
F: __dxlog_file8,
|
|
1705
|
+
L: 284,
|
|
1388
1706
|
S: this,
|
|
1389
1707
|
C: (f, a) => f(...a)
|
|
1390
1708
|
});
|
|
1391
1709
|
setState({
|
|
1392
|
-
state:
|
|
1710
|
+
state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1393
1711
|
});
|
|
1394
1712
|
const authCode = await authenticated.wait({
|
|
1395
1713
|
timeout
|
|
1396
1714
|
});
|
|
1397
|
-
(0,
|
|
1398
|
-
F:
|
|
1399
|
-
L:
|
|
1715
|
+
(0, import_log6.log)("sending authentication request", void 0, {
|
|
1716
|
+
F: __dxlog_file8,
|
|
1717
|
+
L: 288,
|
|
1400
1718
|
S: this,
|
|
1401
1719
|
C: (f, a) => f(...a)
|
|
1402
1720
|
});
|
|
1403
1721
|
setState({
|
|
1404
|
-
state:
|
|
1722
|
+
state: import_services4.Invitation.State.AUTHENTICATING
|
|
1405
1723
|
});
|
|
1406
1724
|
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
1407
1725
|
authCode
|
|
@@ -1413,11 +1731,11 @@ var InvitationsHandler = class {
|
|
|
1413
1731
|
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
1414
1732
|
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
1415
1733
|
} else {
|
|
1416
|
-
(0,
|
|
1734
|
+
(0, import_log6.log)("retrying invalid code", {
|
|
1417
1735
|
attempt
|
|
1418
1736
|
}, {
|
|
1419
|
-
F:
|
|
1420
|
-
L:
|
|
1737
|
+
F: __dxlog_file8,
|
|
1738
|
+
L: 299,
|
|
1421
1739
|
S: this,
|
|
1422
1740
|
C: (f, a) => f(...a)
|
|
1423
1741
|
});
|
|
@@ -1427,14 +1745,14 @@ var InvitationsHandler = class {
|
|
|
1427
1745
|
}
|
|
1428
1746
|
} else {
|
|
1429
1747
|
setState({
|
|
1430
|
-
state:
|
|
1748
|
+
state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1431
1749
|
});
|
|
1432
1750
|
}
|
|
1433
|
-
(0,
|
|
1751
|
+
(0, import_log6.log)("request admission", {
|
|
1434
1752
|
...protocol.toJSON()
|
|
1435
1753
|
}, {
|
|
1436
|
-
F:
|
|
1437
|
-
L:
|
|
1754
|
+
F: __dxlog_file8,
|
|
1755
|
+
L: 310,
|
|
1438
1756
|
S: this,
|
|
1439
1757
|
C: (f, a) => f(...a)
|
|
1440
1758
|
});
|
|
@@ -1442,54 +1760,54 @@ var InvitationsHandler = class {
|
|
|
1442
1760
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
1443
1761
|
admitted = true;
|
|
1444
1762
|
const result = await protocol.accept(admissionResponse, admissionRequest);
|
|
1445
|
-
(0,
|
|
1763
|
+
(0, import_log6.log)("admitted by host", {
|
|
1446
1764
|
...protocol.toJSON()
|
|
1447
1765
|
}, {
|
|
1448
|
-
F:
|
|
1449
|
-
L:
|
|
1766
|
+
F: __dxlog_file8,
|
|
1767
|
+
L: 321,
|
|
1450
1768
|
S: this,
|
|
1451
1769
|
C: (f, a) => f(...a)
|
|
1452
1770
|
});
|
|
1453
1771
|
setState({
|
|
1454
1772
|
...result,
|
|
1455
|
-
state:
|
|
1773
|
+
state: import_services4.Invitation.State.SUCCESS
|
|
1456
1774
|
});
|
|
1457
|
-
|
|
1775
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.end({
|
|
1458
1776
|
id: traceId
|
|
1459
1777
|
}), {
|
|
1460
|
-
F:
|
|
1461
|
-
L:
|
|
1778
|
+
F: __dxlog_file8,
|
|
1779
|
+
L: 323,
|
|
1462
1780
|
S: this,
|
|
1463
1781
|
C: (f, a) => f(...a)
|
|
1464
1782
|
});
|
|
1465
1783
|
} catch (err) {
|
|
1466
1784
|
if (err instanceof import_async5.TimeoutError) {
|
|
1467
|
-
(0,
|
|
1785
|
+
(0, import_log6.log)("timeout", {
|
|
1468
1786
|
...protocol.toJSON()
|
|
1469
1787
|
}, {
|
|
1470
|
-
F:
|
|
1471
|
-
L:
|
|
1788
|
+
F: __dxlog_file8,
|
|
1789
|
+
L: 326,
|
|
1472
1790
|
S: this,
|
|
1473
1791
|
C: (f, a) => f(...a)
|
|
1474
1792
|
});
|
|
1475
1793
|
setState({
|
|
1476
|
-
state:
|
|
1794
|
+
state: import_services4.Invitation.State.TIMEOUT
|
|
1477
1795
|
});
|
|
1478
1796
|
} else {
|
|
1479
|
-
(0,
|
|
1480
|
-
F:
|
|
1481
|
-
L:
|
|
1797
|
+
(0, import_log6.log)("auth failed", err, {
|
|
1798
|
+
F: __dxlog_file8,
|
|
1799
|
+
L: 329,
|
|
1482
1800
|
S: this,
|
|
1483
1801
|
C: (f, a) => f(...a)
|
|
1484
1802
|
});
|
|
1485
1803
|
stream.error(err);
|
|
1486
1804
|
}
|
|
1487
|
-
|
|
1805
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.error({
|
|
1488
1806
|
id: traceId,
|
|
1489
1807
|
error: err
|
|
1490
1808
|
}), {
|
|
1491
|
-
F:
|
|
1492
|
-
L:
|
|
1809
|
+
F: __dxlog_file8,
|
|
1810
|
+
L: 332,
|
|
1493
1811
|
S: this,
|
|
1494
1812
|
C: (f, a) => f(...a)
|
|
1495
1813
|
});
|
|
@@ -1503,21 +1821,21 @@ var InvitationsHandler = class {
|
|
|
1503
1821
|
return;
|
|
1504
1822
|
}
|
|
1505
1823
|
if (err instanceof import_async5.TimeoutError) {
|
|
1506
|
-
(0,
|
|
1824
|
+
(0, import_log6.log)("timeout", {
|
|
1507
1825
|
...protocol.toJSON()
|
|
1508
1826
|
}, {
|
|
1509
|
-
F:
|
|
1510
|
-
L:
|
|
1827
|
+
F: __dxlog_file8,
|
|
1828
|
+
L: 343,
|
|
1511
1829
|
S: this,
|
|
1512
1830
|
C: (f, a) => f(...a)
|
|
1513
1831
|
});
|
|
1514
1832
|
setState({
|
|
1515
|
-
state:
|
|
1833
|
+
state: import_services4.Invitation.State.TIMEOUT
|
|
1516
1834
|
});
|
|
1517
1835
|
} else {
|
|
1518
|
-
(0,
|
|
1519
|
-
F:
|
|
1520
|
-
L:
|
|
1836
|
+
(0, import_log6.log)("auth failed", err, {
|
|
1837
|
+
F: __dxlog_file8,
|
|
1838
|
+
L: 346,
|
|
1521
1839
|
S: this,
|
|
1522
1840
|
C: (f, a) => f(...a)
|
|
1523
1841
|
});
|
|
@@ -1528,7 +1846,15 @@ var InvitationsHandler = class {
|
|
|
1528
1846
|
return extension;
|
|
1529
1847
|
};
|
|
1530
1848
|
(0, import_async5.scheduleTask)(ctx, async () => {
|
|
1531
|
-
(0,
|
|
1849
|
+
(0, import_invariant7.invariant)(invitation.swarmKey, void 0, {
|
|
1850
|
+
F: __dxlog_file8,
|
|
1851
|
+
L: 356,
|
|
1852
|
+
S: this,
|
|
1853
|
+
A: [
|
|
1854
|
+
"invitation.swarmKey",
|
|
1855
|
+
""
|
|
1856
|
+
]
|
|
1857
|
+
});
|
|
1532
1858
|
const topic = invitation.swarmKey;
|
|
1533
1859
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1534
1860
|
topic,
|
|
@@ -1540,7 +1866,7 @@ var InvitationsHandler = class {
|
|
|
1540
1866
|
});
|
|
1541
1867
|
ctx.onDispose(() => swarmConnection.close());
|
|
1542
1868
|
setState({
|
|
1543
|
-
state:
|
|
1869
|
+
state: import_services4.Invitation.State.CONNECTING
|
|
1544
1870
|
});
|
|
1545
1871
|
});
|
|
1546
1872
|
const observable = new import_client_protocol2.AuthenticatingInvitationObservable({
|
|
@@ -1548,7 +1874,7 @@ var InvitationsHandler = class {
|
|
|
1548
1874
|
subscriber: stream.observable,
|
|
1549
1875
|
onCancel: async () => {
|
|
1550
1876
|
setState({
|
|
1551
|
-
state:
|
|
1877
|
+
state: import_services4.Invitation.State.CANCELLED
|
|
1552
1878
|
});
|
|
1553
1879
|
await ctx.dispose();
|
|
1554
1880
|
},
|
|
@@ -1561,12 +1887,12 @@ var InvitationsHandler = class {
|
|
|
1561
1887
|
};
|
|
1562
1888
|
|
|
1563
1889
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1564
|
-
var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
|
|
1565
1890
|
var import_async6 = require("@dxos/async");
|
|
1566
|
-
var
|
|
1567
|
-
var
|
|
1568
|
-
var
|
|
1569
|
-
var
|
|
1891
|
+
var import_codec_protobuf4 = require("@dxos/codec-protobuf");
|
|
1892
|
+
var import_invariant8 = require("@dxos/invariant");
|
|
1893
|
+
var import_log7 = require("@dxos/log");
|
|
1894
|
+
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1895
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
1570
1896
|
var InvitationsServiceImpl = class {
|
|
1571
1897
|
constructor(_invitationsHandler, _getHandler) {
|
|
1572
1898
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -1593,7 +1919,7 @@ var InvitationsServiceImpl = class {
|
|
|
1593
1919
|
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
1594
1920
|
this._invitationCreated.emit(invitation.get());
|
|
1595
1921
|
}
|
|
1596
|
-
return new
|
|
1922
|
+
return new import_codec_protobuf4.Stream(({ next, close }) => {
|
|
1597
1923
|
invitation.subscribe((invitation2) => {
|
|
1598
1924
|
next(invitation2);
|
|
1599
1925
|
}, (err) => {
|
|
@@ -1615,7 +1941,7 @@ var InvitationsServiceImpl = class {
|
|
|
1615
1941
|
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
1616
1942
|
this._invitationAccepted.emit(invitation.get());
|
|
1617
1943
|
}
|
|
1618
|
-
return new
|
|
1944
|
+
return new import_codec_protobuf4.Stream(({ next, close }) => {
|
|
1619
1945
|
invitation.subscribe((invitation2) => {
|
|
1620
1946
|
next(invitation2);
|
|
1621
1947
|
}, (err) => {
|
|
@@ -1627,20 +1953,28 @@ var InvitationsServiceImpl = class {
|
|
|
1627
1953
|
});
|
|
1628
1954
|
}
|
|
1629
1955
|
async authenticate({ invitationId, authCode }) {
|
|
1630
|
-
(0,
|
|
1631
|
-
F:
|
|
1632
|
-
L:
|
|
1956
|
+
(0, import_log7.log)("authenticating...", void 0, {
|
|
1957
|
+
F: __dxlog_file9,
|
|
1958
|
+
L: 102,
|
|
1633
1959
|
S: this,
|
|
1634
1960
|
C: (f, a) => f(...a)
|
|
1635
1961
|
});
|
|
1636
|
-
(0,
|
|
1962
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
1963
|
+
F: __dxlog_file9,
|
|
1964
|
+
L: 103,
|
|
1965
|
+
S: this,
|
|
1966
|
+
A: [
|
|
1967
|
+
"invitationId",
|
|
1968
|
+
""
|
|
1969
|
+
]
|
|
1970
|
+
});
|
|
1637
1971
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1638
1972
|
if (!observable) {
|
|
1639
|
-
|
|
1973
|
+
import_log7.log.warn("invalid invitation", {
|
|
1640
1974
|
invitationId
|
|
1641
1975
|
}, {
|
|
1642
|
-
F:
|
|
1643
|
-
L:
|
|
1976
|
+
F: __dxlog_file9,
|
|
1977
|
+
L: 106,
|
|
1644
1978
|
S: this,
|
|
1645
1979
|
C: (f, a) => f(...a)
|
|
1646
1980
|
});
|
|
@@ -1649,13 +1983,21 @@ var InvitationsServiceImpl = class {
|
|
|
1649
1983
|
}
|
|
1650
1984
|
}
|
|
1651
1985
|
async cancelInvitation({ invitationId }) {
|
|
1652
|
-
(0,
|
|
1653
|
-
F:
|
|
1654
|
-
L:
|
|
1986
|
+
(0, import_log7.log)("deleting...", void 0, {
|
|
1987
|
+
F: __dxlog_file9,
|
|
1988
|
+
L: 113,
|
|
1655
1989
|
S: this,
|
|
1656
1990
|
C: (f, a) => f(...a)
|
|
1657
1991
|
});
|
|
1658
|
-
(0,
|
|
1992
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
1993
|
+
F: __dxlog_file9,
|
|
1994
|
+
L: 114,
|
|
1995
|
+
S: this,
|
|
1996
|
+
A: [
|
|
1997
|
+
"invitationId",
|
|
1998
|
+
""
|
|
1999
|
+
]
|
|
2000
|
+
});
|
|
1659
2001
|
const created = this._createInvitations.get(invitationId);
|
|
1660
2002
|
const accepted = this._acceptInvitations.get(invitationId);
|
|
1661
2003
|
if (created) {
|
|
@@ -1667,22 +2009,22 @@ var InvitationsServiceImpl = class {
|
|
|
1667
2009
|
this._acceptInvitations.delete(invitationId);
|
|
1668
2010
|
this._removedAccepted.emit(accepted.get());
|
|
1669
2011
|
} else {
|
|
1670
|
-
|
|
2012
|
+
import_log7.log.warn("invalid invitation", {
|
|
1671
2013
|
invitationId
|
|
1672
2014
|
}, {
|
|
1673
|
-
F:
|
|
1674
|
-
L:
|
|
2015
|
+
F: __dxlog_file9,
|
|
2016
|
+
L: 126,
|
|
1675
2017
|
S: this,
|
|
1676
2018
|
C: (f, a) => f(...a)
|
|
1677
2019
|
});
|
|
1678
2020
|
}
|
|
1679
2021
|
}
|
|
1680
2022
|
queryInvitations() {
|
|
1681
|
-
return new
|
|
2023
|
+
return new import_codec_protobuf4.Stream(({ next, ctx }) => {
|
|
1682
2024
|
this._invitationCreated.on(ctx, (invitation) => {
|
|
1683
2025
|
next({
|
|
1684
|
-
action:
|
|
1685
|
-
type:
|
|
2026
|
+
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2027
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
1686
2028
|
invitations: [
|
|
1687
2029
|
invitation
|
|
1688
2030
|
]
|
|
@@ -1690,8 +2032,8 @@ var InvitationsServiceImpl = class {
|
|
|
1690
2032
|
});
|
|
1691
2033
|
this._invitationAccepted.on(ctx, (invitation) => {
|
|
1692
2034
|
next({
|
|
1693
|
-
action:
|
|
1694
|
-
type:
|
|
2035
|
+
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2036
|
+
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
1695
2037
|
invitations: [
|
|
1696
2038
|
invitation
|
|
1697
2039
|
]
|
|
@@ -1699,8 +2041,8 @@ var InvitationsServiceImpl = class {
|
|
|
1699
2041
|
});
|
|
1700
2042
|
this._removedCreated.on(ctx, (invitation) => {
|
|
1701
2043
|
next({
|
|
1702
|
-
action:
|
|
1703
|
-
type:
|
|
2044
|
+
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2045
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
1704
2046
|
invitations: [
|
|
1705
2047
|
invitation
|
|
1706
2048
|
]
|
|
@@ -1708,21 +2050,21 @@ var InvitationsServiceImpl = class {
|
|
|
1708
2050
|
});
|
|
1709
2051
|
this._removedAccepted.on(ctx, (invitation) => {
|
|
1710
2052
|
next({
|
|
1711
|
-
action:
|
|
1712
|
-
type:
|
|
2053
|
+
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2054
|
+
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
1713
2055
|
invitations: [
|
|
1714
2056
|
invitation
|
|
1715
2057
|
]
|
|
1716
2058
|
});
|
|
1717
2059
|
});
|
|
1718
2060
|
next({
|
|
1719
|
-
action:
|
|
1720
|
-
type:
|
|
2061
|
+
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2062
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
1721
2063
|
invitations: Array.from(this._createInvitations.values()).map((invitation) => invitation.get())
|
|
1722
2064
|
});
|
|
1723
2065
|
next({
|
|
1724
|
-
action:
|
|
1725
|
-
type:
|
|
2066
|
+
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2067
|
+
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
1726
2068
|
invitations: Array.from(this._acceptInvitations.values()).map((invitation) => invitation.get())
|
|
1727
2069
|
});
|
|
1728
2070
|
});
|
|
@@ -1730,12 +2072,12 @@ var InvitationsServiceImpl = class {
|
|
|
1730
2072
|
};
|
|
1731
2073
|
|
|
1732
2074
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
1733
|
-
var
|
|
1734
|
-
var import_credentials9 = require("@dxos/credentials");
|
|
2075
|
+
var import_credentials10 = require("@dxos/credentials");
|
|
1735
2076
|
var import_feed_store2 = require("@dxos/feed-store");
|
|
1736
|
-
var
|
|
1737
|
-
var
|
|
1738
|
-
var
|
|
2077
|
+
var import_invariant9 = require("@dxos/invariant");
|
|
2078
|
+
var import_log8 = require("@dxos/log");
|
|
2079
|
+
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2080
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
1739
2081
|
var SpaceInvitationProtocol = class {
|
|
1740
2082
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
1741
2083
|
this._spaceManager = _spaceManager;
|
|
@@ -1751,30 +2093,70 @@ var SpaceInvitationProtocol = class {
|
|
|
1751
2093
|
}
|
|
1752
2094
|
getInvitationContext() {
|
|
1753
2095
|
return {
|
|
1754
|
-
kind:
|
|
2096
|
+
kind: import_services6.Invitation.Kind.SPACE,
|
|
1755
2097
|
spaceKey: this._spaceKey
|
|
1756
2098
|
};
|
|
1757
2099
|
}
|
|
1758
2100
|
async admit(request, guestProfile) {
|
|
1759
2101
|
var _a;
|
|
1760
|
-
(0,
|
|
2102
|
+
(0, import_invariant9.invariant)(this._spaceKey, void 0, {
|
|
2103
|
+
F: __dxlog_file10,
|
|
2104
|
+
L: 42,
|
|
2105
|
+
S: this,
|
|
2106
|
+
A: [
|
|
2107
|
+
"this._spaceKey",
|
|
2108
|
+
""
|
|
2109
|
+
]
|
|
2110
|
+
});
|
|
1761
2111
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
1762
|
-
(0,
|
|
1763
|
-
|
|
2112
|
+
(0, import_invariant9.invariant)(space, void 0, {
|
|
2113
|
+
F: __dxlog_file10,
|
|
2114
|
+
L: 44,
|
|
2115
|
+
S: this,
|
|
2116
|
+
A: [
|
|
2117
|
+
"space",
|
|
2118
|
+
""
|
|
2119
|
+
]
|
|
2120
|
+
});
|
|
2121
|
+
(0, import_invariant9.invariant)(request.space, void 0, {
|
|
2122
|
+
F: __dxlog_file10,
|
|
2123
|
+
L: 46,
|
|
2124
|
+
S: this,
|
|
2125
|
+
A: [
|
|
2126
|
+
"request.space",
|
|
2127
|
+
""
|
|
2128
|
+
]
|
|
2129
|
+
});
|
|
1764
2130
|
const { identityKey, deviceKey } = request.space;
|
|
1765
|
-
(0,
|
|
2131
|
+
(0, import_log8.log)("writing guest credentials", {
|
|
1766
2132
|
host: this._signingContext.deviceKey,
|
|
1767
2133
|
guest: deviceKey
|
|
1768
2134
|
}, {
|
|
1769
|
-
F:
|
|
1770
|
-
L:
|
|
2135
|
+
F: __dxlog_file10,
|
|
2136
|
+
L: 49,
|
|
1771
2137
|
S: this,
|
|
1772
2138
|
C: (f, a) => f(...a)
|
|
1773
2139
|
});
|
|
1774
|
-
const credentials = await (0,
|
|
1775
|
-
(0,
|
|
2140
|
+
const credentials = await (0, import_credentials10.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2141
|
+
(0, import_invariant9.invariant)(credentials[0].credential, void 0, {
|
|
2142
|
+
F: __dxlog_file10,
|
|
2143
|
+
L: 60,
|
|
2144
|
+
S: this,
|
|
2145
|
+
A: [
|
|
2146
|
+
"credentials[0].credential",
|
|
2147
|
+
""
|
|
2148
|
+
]
|
|
2149
|
+
});
|
|
1776
2150
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
1777
|
-
(0,
|
|
2151
|
+
(0, import_invariant9.invariant)((0, import_credentials10.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2152
|
+
F: __dxlog_file10,
|
|
2153
|
+
L: 62,
|
|
2154
|
+
S: this,
|
|
2155
|
+
A: [
|
|
2156
|
+
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2157
|
+
""
|
|
2158
|
+
]
|
|
2159
|
+
});
|
|
1778
2160
|
await (0, import_feed_store2.writeMessages)(space.inner.controlPipeline.writer, credentials);
|
|
1779
2161
|
return {
|
|
1780
2162
|
space: {
|
|
@@ -1802,11 +2184,35 @@ var SpaceInvitationProtocol = class {
|
|
|
1802
2184
|
};
|
|
1803
2185
|
}
|
|
1804
2186
|
async accept(response) {
|
|
1805
|
-
(0,
|
|
2187
|
+
(0, import_invariant9.invariant)(response.space, void 0, {
|
|
2188
|
+
F: __dxlog_file10,
|
|
2189
|
+
L: 97,
|
|
2190
|
+
S: this,
|
|
2191
|
+
A: [
|
|
2192
|
+
"response.space",
|
|
2193
|
+
""
|
|
2194
|
+
]
|
|
2195
|
+
});
|
|
1806
2196
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
1807
|
-
const assertion = (0,
|
|
1808
|
-
(0,
|
|
1809
|
-
|
|
2197
|
+
const assertion = (0, import_credentials10.getCredentialAssertion)(credential);
|
|
2198
|
+
(0, import_invariant9.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2199
|
+
F: __dxlog_file10,
|
|
2200
|
+
L: 100,
|
|
2201
|
+
S: this,
|
|
2202
|
+
A: [
|
|
2203
|
+
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2204
|
+
"'Invalid credential'"
|
|
2205
|
+
]
|
|
2206
|
+
});
|
|
2207
|
+
(0, import_invariant9.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2208
|
+
F: __dxlog_file10,
|
|
2209
|
+
L: 101,
|
|
2210
|
+
S: this,
|
|
2211
|
+
A: [
|
|
2212
|
+
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
2213
|
+
""
|
|
2214
|
+
]
|
|
2215
|
+
});
|
|
1810
2216
|
await this._spaceManager.acceptSpace({
|
|
1811
2217
|
spaceKey: assertion.spaceKey,
|
|
1812
2218
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -1821,14 +2227,14 @@ var SpaceInvitationProtocol = class {
|
|
|
1821
2227
|
};
|
|
1822
2228
|
|
|
1823
2229
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
1824
|
-
var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
|
|
1825
2230
|
var import_async9 = require("@dxos/async");
|
|
1826
2231
|
var import_context6 = require("@dxos/context");
|
|
1827
|
-
var
|
|
2232
|
+
var import_credentials14 = require("@dxos/credentials");
|
|
2233
|
+
var import_invariant11 = require("@dxos/invariant");
|
|
1828
2234
|
var import_keys7 = require("@dxos/keys");
|
|
1829
|
-
var
|
|
1830
|
-
var
|
|
1831
|
-
var
|
|
2235
|
+
var import_log11 = require("@dxos/log");
|
|
2236
|
+
var import_protocols7 = require("@dxos/protocols");
|
|
2237
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1832
2238
|
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
1833
2239
|
var import_util4 = require("@dxos/util");
|
|
1834
2240
|
|
|
@@ -1840,22 +2246,22 @@ var import_debug4 = require("@dxos/debug");
|
|
|
1840
2246
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
1841
2247
|
var import_errors3 = require("@dxos/errors");
|
|
1842
2248
|
var import_keys6 = require("@dxos/keys");
|
|
1843
|
-
var
|
|
1844
|
-
var
|
|
1845
|
-
var
|
|
2249
|
+
var import_log10 = require("@dxos/log");
|
|
2250
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2251
|
+
var import_credentials11 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
1846
2252
|
var import_timeframe = require("@dxos/timeframe");
|
|
1847
2253
|
var import_util3 = require("@dxos/util");
|
|
1848
2254
|
|
|
1849
2255
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
1850
|
-
var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
|
|
1851
2256
|
var import_async7 = require("@dxos/async");
|
|
1852
2257
|
var import_context4 = require("@dxos/context");
|
|
2258
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
1853
2259
|
var import_keys5 = require("@dxos/keys");
|
|
1854
|
-
var
|
|
1855
|
-
var
|
|
2260
|
+
var import_log9 = require("@dxos/log");
|
|
2261
|
+
var import_protocols6 = require("@dxos/protocols");
|
|
1856
2262
|
var import_teleport2 = require("@dxos/teleport");
|
|
1857
2263
|
var import_util2 = require("@dxos/util");
|
|
1858
|
-
var
|
|
2264
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
1859
2265
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
1860
2266
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
1861
2267
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -1880,23 +2286,31 @@ var NotarizationPlugin = class {
|
|
|
1880
2286
|
* Request credentials to be notarized.
|
|
1881
2287
|
*/
|
|
1882
2288
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
1883
|
-
(0,
|
|
2289
|
+
(0, import_log9.log)("notarize", {
|
|
1884
2290
|
credentials
|
|
1885
2291
|
}, {
|
|
1886
|
-
F:
|
|
1887
|
-
L:
|
|
2292
|
+
F: __dxlog_file11,
|
|
2293
|
+
L: 90,
|
|
1888
2294
|
S: this,
|
|
1889
2295
|
C: (f, a) => f(...a)
|
|
1890
2296
|
});
|
|
1891
|
-
(0,
|
|
2297
|
+
(0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
2298
|
+
F: __dxlog_file11,
|
|
2299
|
+
L: 91,
|
|
2300
|
+
S: this,
|
|
2301
|
+
A: [
|
|
2302
|
+
"credentials.every((credential) => credential.id)",
|
|
2303
|
+
"'Credentials must have an id'"
|
|
2304
|
+
]
|
|
2305
|
+
});
|
|
1892
2306
|
const errors = new import_async7.Trigger();
|
|
1893
2307
|
const ctx = this._ctx.derive({
|
|
1894
2308
|
onError: (err) => {
|
|
1895
|
-
|
|
2309
|
+
import_log9.log.warn("Notarization error", {
|
|
1896
2310
|
err
|
|
1897
2311
|
}, {
|
|
1898
|
-
F:
|
|
1899
|
-
L:
|
|
2312
|
+
F: __dxlog_file11,
|
|
2313
|
+
L: 99,
|
|
1900
2314
|
S: this,
|
|
1901
2315
|
C: (f, a) => f(...a)
|
|
1902
2316
|
});
|
|
@@ -1907,12 +2321,12 @@ var NotarizationPlugin = class {
|
|
|
1907
2321
|
opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
|
|
1908
2322
|
if (timeout !== 0) {
|
|
1909
2323
|
(0, import_async7.scheduleTask)(ctx, () => {
|
|
1910
|
-
|
|
2324
|
+
import_log9.log.warn("Notarization timeout", {
|
|
1911
2325
|
timeout,
|
|
1912
2326
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
1913
2327
|
}, {
|
|
1914
|
-
F:
|
|
1915
|
-
L:
|
|
2328
|
+
F: __dxlog_file11,
|
|
2329
|
+
L: 111,
|
|
1916
2330
|
S: this,
|
|
1917
2331
|
C: (f, a) => f(...a)
|
|
1918
2332
|
});
|
|
@@ -1931,11 +2345,11 @@ var NotarizationPlugin = class {
|
|
|
1931
2345
|
...this._extensions
|
|
1932
2346
|
].find((peer2) => !peersTried.has(peer2));
|
|
1933
2347
|
if (!peer) {
|
|
1934
|
-
|
|
2348
|
+
import_log9.log.warn("Exhausted all peers to notarize with", {
|
|
1935
2349
|
retryIn: retryTimeout
|
|
1936
2350
|
}, {
|
|
1937
|
-
F:
|
|
1938
|
-
L:
|
|
2351
|
+
F: __dxlog_file11,
|
|
2352
|
+
L: 136,
|
|
1939
2353
|
S: this,
|
|
1940
2354
|
C: (f, a) => f(...a)
|
|
1941
2355
|
});
|
|
@@ -1944,30 +2358,30 @@ var NotarizationPlugin = class {
|
|
|
1944
2358
|
return;
|
|
1945
2359
|
}
|
|
1946
2360
|
peersTried.add(peer);
|
|
1947
|
-
(0,
|
|
2361
|
+
(0, import_log9.log)("try notarizing", {
|
|
1948
2362
|
peer: peer.localPeerId,
|
|
1949
2363
|
credentialId: credentials.map((credential) => credential.id)
|
|
1950
2364
|
}, {
|
|
1951
|
-
F:
|
|
1952
|
-
L:
|
|
2365
|
+
F: __dxlog_file11,
|
|
2366
|
+
L: 143,
|
|
1953
2367
|
S: this,
|
|
1954
2368
|
C: (f, a) => f(...a)
|
|
1955
2369
|
});
|
|
1956
2370
|
await peer.rpc.NotarizationService.notarize({
|
|
1957
2371
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
1958
2372
|
});
|
|
1959
|
-
(0,
|
|
1960
|
-
F:
|
|
1961
|
-
L:
|
|
2373
|
+
(0, import_log9.log)("success", void 0, {
|
|
2374
|
+
F: __dxlog_file11,
|
|
2375
|
+
L: 147,
|
|
1962
2376
|
S: this,
|
|
1963
2377
|
C: (f, a) => f(...a)
|
|
1964
2378
|
});
|
|
1965
2379
|
await (0, import_async7.sleep)(successDelay);
|
|
1966
2380
|
} catch (err) {
|
|
1967
2381
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
1968
|
-
|
|
1969
|
-
F:
|
|
1970
|
-
L:
|
|
2382
|
+
import_log9.log.warn("error notarizing (recoverable)", err, {
|
|
2383
|
+
F: __dxlog_file11,
|
|
2384
|
+
L: 151,
|
|
1971
2385
|
S: this,
|
|
1972
2386
|
C: (f, a) => f(...a)
|
|
1973
2387
|
});
|
|
@@ -1983,9 +2397,9 @@ var NotarizationPlugin = class {
|
|
|
1983
2397
|
allNotarized,
|
|
1984
2398
|
errors.wait()
|
|
1985
2399
|
]);
|
|
1986
|
-
(0,
|
|
1987
|
-
F:
|
|
1988
|
-
L:
|
|
2400
|
+
(0, import_log9.log)("done", void 0, {
|
|
2401
|
+
F: __dxlog_file11,
|
|
2402
|
+
L: 162,
|
|
1989
2403
|
S: this,
|
|
1990
2404
|
C: (f, a) => f(...a)
|
|
1991
2405
|
});
|
|
@@ -2006,7 +2420,15 @@ var NotarizationPlugin = class {
|
|
|
2006
2420
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2007
2421
|
}
|
|
2008
2422
|
setWriter(writer) {
|
|
2009
|
-
(0,
|
|
2423
|
+
(0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
|
|
2424
|
+
F: __dxlog_file11,
|
|
2425
|
+
L: 181,
|
|
2426
|
+
S: this,
|
|
2427
|
+
A: [
|
|
2428
|
+
"!this._writer",
|
|
2429
|
+
"'Writer already set.'"
|
|
2430
|
+
]
|
|
2431
|
+
});
|
|
2010
2432
|
this._writer = writer;
|
|
2011
2433
|
}
|
|
2012
2434
|
async _waitUntilProcessed(id) {
|
|
@@ -2024,7 +2446,15 @@ var NotarizationPlugin = class {
|
|
|
2024
2446
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2025
2447
|
}
|
|
2026
2448
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2027
|
-
(0,
|
|
2449
|
+
(0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
|
|
2450
|
+
F: __dxlog_file11,
|
|
2451
|
+
L: 200,
|
|
2452
|
+
S: this,
|
|
2453
|
+
A: [
|
|
2454
|
+
"credential.id",
|
|
2455
|
+
"'Credential must have an id'"
|
|
2456
|
+
]
|
|
2457
|
+
});
|
|
2028
2458
|
if (this._processedCredentials.has(credential.id)) {
|
|
2029
2459
|
continue;
|
|
2030
2460
|
}
|
|
@@ -2034,11 +2464,11 @@ var NotarizationPlugin = class {
|
|
|
2034
2464
|
createExtension() {
|
|
2035
2465
|
const extension = new NotarizationTeleportExtension({
|
|
2036
2466
|
onOpen: async () => {
|
|
2037
|
-
(0,
|
|
2467
|
+
(0, import_log9.log)("extension opened", {
|
|
2038
2468
|
peer: extension.localPeerId
|
|
2039
2469
|
}, {
|
|
2040
|
-
F:
|
|
2041
|
-
L:
|
|
2470
|
+
F: __dxlog_file11,
|
|
2471
|
+
L: 211,
|
|
2042
2472
|
S: this,
|
|
2043
2473
|
C: (f, a) => f(...a)
|
|
2044
2474
|
});
|
|
@@ -2046,11 +2476,11 @@ var NotarizationPlugin = class {
|
|
|
2046
2476
|
this._extensionOpened.emit();
|
|
2047
2477
|
},
|
|
2048
2478
|
onClose: async () => {
|
|
2049
|
-
(0,
|
|
2479
|
+
(0, import_log9.log)("extension closed", {
|
|
2050
2480
|
peer: extension.localPeerId
|
|
2051
2481
|
}, {
|
|
2052
|
-
F:
|
|
2053
|
-
L:
|
|
2482
|
+
F: __dxlog_file11,
|
|
2483
|
+
L: 216,
|
|
2054
2484
|
S: this,
|
|
2055
2485
|
C: (f, a) => f(...a)
|
|
2056
2486
|
});
|
|
@@ -2065,10 +2495,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
2065
2495
|
constructor(_params) {
|
|
2066
2496
|
super({
|
|
2067
2497
|
requested: {
|
|
2068
|
-
NotarizationService:
|
|
2498
|
+
NotarizationService: import_protocols6.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2069
2499
|
},
|
|
2070
2500
|
exposed: {
|
|
2071
|
-
NotarizationService:
|
|
2501
|
+
NotarizationService: import_protocols6.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2072
2502
|
}
|
|
2073
2503
|
});
|
|
2074
2504
|
this._params = _params;
|
|
@@ -2103,12 +2533,12 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
2103
2533
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2104
2534
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2105
2535
|
}
|
|
2106
|
-
var
|
|
2536
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2107
2537
|
var DataSpace = class DataSpace2 {
|
|
2108
2538
|
constructor(params) {
|
|
2109
2539
|
this._ctx = new import_context5.Context();
|
|
2110
2540
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
2111
|
-
this._state =
|
|
2541
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
2112
2542
|
/**
|
|
2113
2543
|
* Error for _state === SpaceState.ERROR.
|
|
2114
2544
|
*/
|
|
@@ -2165,7 +2595,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2165
2595
|
await this._notarizationPlugin.open();
|
|
2166
2596
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2167
2597
|
await this._inner.open();
|
|
2168
|
-
this._state =
|
|
2598
|
+
this._state = import_services7.SpaceState.CONTROL_ONLY;
|
|
2169
2599
|
this.stateUpdate.emit();
|
|
2170
2600
|
this.metrics = {};
|
|
2171
2601
|
this.metrics.open = new Date();
|
|
@@ -2176,7 +2606,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2176
2606
|
async _close() {
|
|
2177
2607
|
var _a, _b;
|
|
2178
2608
|
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
2179
|
-
this._state =
|
|
2609
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
2180
2610
|
await this._ctx.dispose();
|
|
2181
2611
|
this._ctx = new import_context5.Context();
|
|
2182
2612
|
await this.authVerifier.close();
|
|
@@ -2201,21 +2631,21 @@ var DataSpace = class DataSpace2 {
|
|
|
2201
2631
|
await this.initializeDataPipeline();
|
|
2202
2632
|
} catch (err) {
|
|
2203
2633
|
if (err instanceof import_errors3.CancelledError) {
|
|
2204
|
-
(0,
|
|
2205
|
-
F:
|
|
2634
|
+
(0, import_log10.log)("data pipeline initialization cancelled", err, {
|
|
2635
|
+
F: __dxlog_file12,
|
|
2206
2636
|
L: 193,
|
|
2207
2637
|
S: this,
|
|
2208
2638
|
C: (f, a) => f(...a)
|
|
2209
2639
|
});
|
|
2210
2640
|
return;
|
|
2211
2641
|
}
|
|
2212
|
-
|
|
2213
|
-
F:
|
|
2642
|
+
import_log10.log.error("Error initializing data pipeline", err, {
|
|
2643
|
+
F: __dxlog_file12,
|
|
2214
2644
|
L: 197,
|
|
2215
2645
|
S: this,
|
|
2216
2646
|
C: (f, a) => f(...a)
|
|
2217
2647
|
});
|
|
2218
|
-
this._state =
|
|
2648
|
+
this._state = import_services7.SpaceState.ERROR;
|
|
2219
2649
|
this.error = err;
|
|
2220
2650
|
this.stateUpdate.emit();
|
|
2221
2651
|
} finally {
|
|
@@ -2225,18 +2655,18 @@ var DataSpace = class DataSpace2 {
|
|
|
2225
2655
|
}
|
|
2226
2656
|
async initializeDataPipeline() {
|
|
2227
2657
|
var _a, _b, _c, _d;
|
|
2228
|
-
if (this._state !==
|
|
2658
|
+
if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
|
|
2229
2659
|
throw new import_errors3.SystemError("Invalid operation");
|
|
2230
2660
|
}
|
|
2231
|
-
this._state =
|
|
2661
|
+
this._state = import_services7.SpaceState.INITIALIZING;
|
|
2232
2662
|
await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
2233
2663
|
ctx: this._ctx,
|
|
2234
2664
|
breakOnStall: false
|
|
2235
2665
|
});
|
|
2236
2666
|
this.metrics.controlPipelineReady = new Date();
|
|
2237
2667
|
await this._createWritableFeeds();
|
|
2238
|
-
(0,
|
|
2239
|
-
F:
|
|
2668
|
+
(0, import_log10.log)("writable feeds created", void 0, {
|
|
2669
|
+
F: __dxlog_file12,
|
|
2240
2670
|
L: 221,
|
|
2241
2671
|
S: this,
|
|
2242
2672
|
C: (f, a) => f(...a)
|
|
@@ -2252,8 +2682,8 @@ var DataSpace = class DataSpace2 {
|
|
|
2252
2682
|
await this._inner.initializeDataPipeline();
|
|
2253
2683
|
this.metrics.dataPipelineOpen = new Date();
|
|
2254
2684
|
await (0, import_context5.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2255
|
-
(0,
|
|
2256
|
-
F:
|
|
2685
|
+
(0, import_log10.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
2686
|
+
F: __dxlog_file12,
|
|
2257
2687
|
L: 242,
|
|
2258
2688
|
S: this,
|
|
2259
2689
|
C: (f, a) => f(...a)
|
|
@@ -2263,14 +2693,14 @@ var DataSpace = class DataSpace2 {
|
|
|
2263
2693
|
breakOnStall: false
|
|
2264
2694
|
});
|
|
2265
2695
|
this.metrics.dataPipelineReady = new Date();
|
|
2266
|
-
(0,
|
|
2267
|
-
F:
|
|
2696
|
+
(0, import_log10.log)("data pipeline ready", void 0, {
|
|
2697
|
+
F: __dxlog_file12,
|
|
2268
2698
|
L: 251,
|
|
2269
2699
|
S: this,
|
|
2270
2700
|
C: (f, a) => f(...a)
|
|
2271
2701
|
});
|
|
2272
2702
|
await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
|
|
2273
|
-
this._state =
|
|
2703
|
+
this._state = import_services7.SpaceState.READY;
|
|
2274
2704
|
this.stateUpdate.emit();
|
|
2275
2705
|
await ((_d = (_c = this._callbacks).afterReady) == null ? void 0 : _d.call(_c));
|
|
2276
2706
|
}
|
|
@@ -2288,7 +2718,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2288
2718
|
spaceKey: this.key,
|
|
2289
2719
|
deviceKey: this._signingContext.deviceKey,
|
|
2290
2720
|
identityKey: this._signingContext.identityKey,
|
|
2291
|
-
designation:
|
|
2721
|
+
designation: import_credentials11.AdmittedFeed.Designation.CONTROL
|
|
2292
2722
|
}
|
|
2293
2723
|
}));
|
|
2294
2724
|
}
|
|
@@ -2305,7 +2735,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2305
2735
|
spaceKey: this.key,
|
|
2306
2736
|
deviceKey: this._signingContext.deviceKey,
|
|
2307
2737
|
identityKey: this._signingContext.identityKey,
|
|
2308
|
-
designation:
|
|
2738
|
+
designation: import_credentials11.AdmittedFeed.Designation.DATA
|
|
2309
2739
|
}
|
|
2310
2740
|
}));
|
|
2311
2741
|
}
|
|
@@ -2346,20 +2776,20 @@ var DataSpace = class DataSpace2 {
|
|
|
2346
2776
|
}
|
|
2347
2777
|
}
|
|
2348
2778
|
async activate() {
|
|
2349
|
-
if (this._state !==
|
|
2779
|
+
if (this._state !== import_services7.SpaceState.INACTIVE) {
|
|
2350
2780
|
return;
|
|
2351
2781
|
}
|
|
2352
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
2782
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
|
|
2353
2783
|
await this._open();
|
|
2354
2784
|
this.initializeDataPipelineAsync();
|
|
2355
2785
|
}
|
|
2356
2786
|
async deactivate() {
|
|
2357
|
-
if (this._state ===
|
|
2787
|
+
if (this._state === import_services7.SpaceState.INACTIVE) {
|
|
2358
2788
|
return;
|
|
2359
2789
|
}
|
|
2360
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
2790
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
|
|
2361
2791
|
await this._close();
|
|
2362
|
-
this._state =
|
|
2792
|
+
this._state = import_services7.SpaceState.INACTIVE;
|
|
2363
2793
|
this.stateUpdate.emit();
|
|
2364
2794
|
}
|
|
2365
2795
|
};
|
|
@@ -2383,14 +2813,14 @@ DataSpace = _ts_decorate([
|
|
|
2383
2813
|
], DataSpace);
|
|
2384
2814
|
|
|
2385
2815
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
2386
|
-
var
|
|
2816
|
+
var import_credentials12 = require("@dxos/credentials");
|
|
2387
2817
|
var import_debug5 = require("@dxos/debug");
|
|
2388
|
-
var
|
|
2818
|
+
var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2389
2819
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
2390
2820
|
var spaceGenesis = async (keyring, signingContext, space) => {
|
|
2391
2821
|
var _a, _b, _c, _d;
|
|
2392
2822
|
const credentials = [
|
|
2393
|
-
await (0,
|
|
2823
|
+
await (0, import_credentials12.createCredential)({
|
|
2394
2824
|
signer: keyring,
|
|
2395
2825
|
issuer: space.key,
|
|
2396
2826
|
subject: space.key,
|
|
@@ -2399,14 +2829,14 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2399
2829
|
spaceKey: space.key
|
|
2400
2830
|
}
|
|
2401
2831
|
}),
|
|
2402
|
-
await (0,
|
|
2832
|
+
await (0, import_credentials12.createCredential)({
|
|
2403
2833
|
signer: keyring,
|
|
2404
2834
|
issuer: space.key,
|
|
2405
2835
|
subject: signingContext.identityKey,
|
|
2406
2836
|
assertion: {
|
|
2407
2837
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
2408
2838
|
spaceKey: space.key,
|
|
2409
|
-
role:
|
|
2839
|
+
role: import_credentials13.SpaceMember.Role.ADMIN,
|
|
2410
2840
|
profile: signingContext.profile,
|
|
2411
2841
|
genesisFeedKey: (_a = space.controlFeedKey) != null ? _a : (0, import_debug5.failUndefined)()
|
|
2412
2842
|
}
|
|
@@ -2418,7 +2848,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2418
2848
|
spaceKey: space.key,
|
|
2419
2849
|
identityKey: signingContext.identityKey,
|
|
2420
2850
|
deviceKey: signingContext.deviceKey,
|
|
2421
|
-
designation:
|
|
2851
|
+
designation: import_credentials13.AdmittedFeed.Designation.CONTROL
|
|
2422
2852
|
}
|
|
2423
2853
|
}),
|
|
2424
2854
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -2428,7 +2858,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2428
2858
|
spaceKey: space.key,
|
|
2429
2859
|
identityKey: signingContext.identityKey,
|
|
2430
2860
|
deviceKey: signingContext.deviceKey,
|
|
2431
|
-
designation:
|
|
2861
|
+
designation: import_credentials13.AdmittedFeed.Designation.DATA
|
|
2432
2862
|
}
|
|
2433
2863
|
}),
|
|
2434
2864
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -2463,7 +2893,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
2463
2893
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2464
2894
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2465
2895
|
}
|
|
2466
|
-
var
|
|
2896
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
2467
2897
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
2468
2898
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
2469
2899
|
this._spaceManager = _spaceManager;
|
|
@@ -2483,50 +2913,50 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2483
2913
|
return this._spaces;
|
|
2484
2914
|
}
|
|
2485
2915
|
async open() {
|
|
2486
|
-
(0,
|
|
2487
|
-
F:
|
|
2488
|
-
L:
|
|
2916
|
+
(0, import_log11.log)("open", void 0, {
|
|
2917
|
+
F: __dxlog_file13,
|
|
2918
|
+
L: 79,
|
|
2489
2919
|
S: this,
|
|
2490
2920
|
C: (f, a) => f(...a)
|
|
2491
2921
|
});
|
|
2492
|
-
|
|
2922
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols7.trace.begin({
|
|
2493
2923
|
id: this._instanceId
|
|
2494
2924
|
}), {
|
|
2495
|
-
F:
|
|
2496
|
-
L:
|
|
2925
|
+
F: __dxlog_file13,
|
|
2926
|
+
L: 80,
|
|
2497
2927
|
S: this,
|
|
2498
2928
|
C: (f, a) => f(...a)
|
|
2499
2929
|
});
|
|
2500
2930
|
await this._metadataStore.load();
|
|
2501
|
-
(0,
|
|
2931
|
+
(0, import_log11.log)("metadata loaded", {
|
|
2502
2932
|
spaces: this._metadataStore.spaces.length
|
|
2503
2933
|
}, {
|
|
2504
|
-
F:
|
|
2505
|
-
L:
|
|
2934
|
+
F: __dxlog_file13,
|
|
2935
|
+
L: 82,
|
|
2506
2936
|
S: this,
|
|
2507
2937
|
C: (f, a) => f(...a)
|
|
2508
2938
|
});
|
|
2509
2939
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2510
2940
|
try {
|
|
2511
|
-
(0,
|
|
2941
|
+
(0, import_log11.log)("load space", {
|
|
2512
2942
|
spaceMetadata
|
|
2513
2943
|
}, {
|
|
2514
|
-
F:
|
|
2515
|
-
L:
|
|
2944
|
+
F: __dxlog_file13,
|
|
2945
|
+
L: 86,
|
|
2516
2946
|
S: this,
|
|
2517
2947
|
C: (f, a) => f(...a)
|
|
2518
2948
|
});
|
|
2519
2949
|
const space = await this._constructSpace(spaceMetadata);
|
|
2520
|
-
if (spaceMetadata.state !==
|
|
2950
|
+
if (spaceMetadata.state !== import_services8.SpaceState.INACTIVE) {
|
|
2521
2951
|
space.initializeDataPipelineAsync();
|
|
2522
2952
|
}
|
|
2523
2953
|
} catch (err) {
|
|
2524
|
-
|
|
2954
|
+
import_log11.log.error("Error loading space", {
|
|
2525
2955
|
spaceMetadata,
|
|
2526
2956
|
err
|
|
2527
2957
|
}, {
|
|
2528
|
-
F:
|
|
2529
|
-
L:
|
|
2958
|
+
F: __dxlog_file13,
|
|
2959
|
+
L: 92,
|
|
2530
2960
|
S: this,
|
|
2531
2961
|
C: (f, a) => f(...a)
|
|
2532
2962
|
});
|
|
@@ -2534,19 +2964,19 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2534
2964
|
}
|
|
2535
2965
|
this._isOpen = true;
|
|
2536
2966
|
this.updated.emit();
|
|
2537
|
-
|
|
2967
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols7.trace.end({
|
|
2538
2968
|
id: this._instanceId
|
|
2539
2969
|
}), {
|
|
2540
|
-
F:
|
|
2541
|
-
L:
|
|
2970
|
+
F: __dxlog_file13,
|
|
2971
|
+
L: 98,
|
|
2542
2972
|
S: this,
|
|
2543
2973
|
C: (f, a) => f(...a)
|
|
2544
2974
|
});
|
|
2545
2975
|
}
|
|
2546
2976
|
async close() {
|
|
2547
|
-
(0,
|
|
2548
|
-
F:
|
|
2549
|
-
L:
|
|
2977
|
+
(0, import_log11.log)("close", void 0, {
|
|
2978
|
+
F: __dxlog_file13,
|
|
2979
|
+
L: 103,
|
|
2550
2980
|
S: this,
|
|
2551
2981
|
C: (f, a) => f(...a)
|
|
2552
2982
|
});
|
|
@@ -2560,7 +2990,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2560
2990
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
2561
2991
|
*/
|
|
2562
2992
|
async createSpace() {
|
|
2563
|
-
(0,
|
|
2993
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
2994
|
+
F: __dxlog_file13,
|
|
2995
|
+
L: 116,
|
|
2996
|
+
S: this,
|
|
2997
|
+
A: [
|
|
2998
|
+
"this._isOpen",
|
|
2999
|
+
"'Not open.'"
|
|
3000
|
+
]
|
|
3001
|
+
});
|
|
2564
3002
|
const spaceKey = await this._keyring.createKey();
|
|
2565
3003
|
const controlFeedKey = await this._keyring.createKey();
|
|
2566
3004
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -2569,13 +3007,13 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2569
3007
|
genesisFeedKey: controlFeedKey,
|
|
2570
3008
|
controlFeedKey,
|
|
2571
3009
|
dataFeedKey,
|
|
2572
|
-
state:
|
|
3010
|
+
state: import_services8.SpaceState.ACTIVE
|
|
2573
3011
|
};
|
|
2574
|
-
(0,
|
|
3012
|
+
(0, import_log11.log)("creating space...", {
|
|
2575
3013
|
spaceKey
|
|
2576
3014
|
}, {
|
|
2577
|
-
F:
|
|
2578
|
-
L:
|
|
3015
|
+
F: __dxlog_file13,
|
|
3016
|
+
L: 128,
|
|
2579
3017
|
S: this,
|
|
2580
3018
|
C: (f, a) => f(...a)
|
|
2581
3019
|
});
|
|
@@ -2583,7 +3021,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2583
3021
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2584
3022
|
await this._metadataStore.addSpace(metadata);
|
|
2585
3023
|
const memberCredential = credentials[1];
|
|
2586
|
-
(0,
|
|
3024
|
+
(0, import_invariant11.invariant)((0, import_credentials14.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3025
|
+
F: __dxlog_file13,
|
|
3026
|
+
L: 135,
|
|
3027
|
+
S: this,
|
|
3028
|
+
A: [
|
|
3029
|
+
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
3030
|
+
""
|
|
3031
|
+
]
|
|
3032
|
+
});
|
|
2587
3033
|
await this._signingContext.recordCredential(memberCredential);
|
|
2588
3034
|
await space.initializeDataPipeline();
|
|
2589
3035
|
this.updated.emit();
|
|
@@ -2591,16 +3037,32 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2591
3037
|
}
|
|
2592
3038
|
// TODO(burdon): Rename join space.
|
|
2593
3039
|
async acceptSpace(opts) {
|
|
2594
|
-
(0,
|
|
3040
|
+
(0, import_log11.log)("accept space", {
|
|
2595
3041
|
opts
|
|
2596
3042
|
}, {
|
|
2597
|
-
F:
|
|
2598
|
-
L:
|
|
3043
|
+
F: __dxlog_file13,
|
|
3044
|
+
L: 147,
|
|
2599
3045
|
S: this,
|
|
2600
3046
|
C: (f, a) => f(...a)
|
|
2601
3047
|
});
|
|
2602
|
-
(0,
|
|
2603
|
-
|
|
3048
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3049
|
+
F: __dxlog_file13,
|
|
3050
|
+
L: 148,
|
|
3051
|
+
S: this,
|
|
3052
|
+
A: [
|
|
3053
|
+
"this._isOpen",
|
|
3054
|
+
"'Not open.'"
|
|
3055
|
+
]
|
|
3056
|
+
});
|
|
3057
|
+
(0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3058
|
+
F: __dxlog_file13,
|
|
3059
|
+
L: 149,
|
|
3060
|
+
S: this,
|
|
3061
|
+
A: [
|
|
3062
|
+
"!this._spaces.has(opts.spaceKey)",
|
|
3063
|
+
"'Space already exists.'"
|
|
3064
|
+
]
|
|
3065
|
+
});
|
|
2604
3066
|
const metadata = {
|
|
2605
3067
|
key: opts.spaceKey,
|
|
2606
3068
|
genesisFeedKey: opts.genesisFeedKey,
|
|
@@ -2621,15 +3083,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2621
3083
|
async waitUntilSpaceReady(spaceKey) {
|
|
2622
3084
|
await (0, import_context6.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
2623
3085
|
const space = this._spaces.get(spaceKey);
|
|
2624
|
-
return !!space && space.state ===
|
|
3086
|
+
return !!space && space.state === import_services8.SpaceState.READY;
|
|
2625
3087
|
}));
|
|
2626
3088
|
}
|
|
2627
3089
|
async _constructSpace(metadata) {
|
|
2628
|
-
(0,
|
|
3090
|
+
(0, import_log11.log)("construct space", {
|
|
2629
3091
|
metadata
|
|
2630
3092
|
}, {
|
|
2631
|
-
F:
|
|
2632
|
-
L:
|
|
3093
|
+
F: __dxlog_file13,
|
|
3094
|
+
L: 182,
|
|
2633
3095
|
S: this,
|
|
2634
3096
|
C: (f, a) => f(...a)
|
|
2635
3097
|
});
|
|
@@ -2663,9 +3125,9 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2663
3125
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
2664
3126
|
},
|
|
2665
3127
|
onAuthFailure: () => {
|
|
2666
|
-
|
|
2667
|
-
F:
|
|
2668
|
-
L:
|
|
3128
|
+
import_log11.log.warn("auth failure", void 0, {
|
|
3129
|
+
F: __dxlog_file13,
|
|
3130
|
+
L: 213,
|
|
2669
3131
|
S: this,
|
|
2670
3132
|
C: (f, a) => f(...a)
|
|
2671
3133
|
});
|
|
@@ -2676,7 +3138,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2676
3138
|
dataFeed && space.setDataFeed(dataFeed);
|
|
2677
3139
|
const dataSpace = new DataSpace({
|
|
2678
3140
|
inner: space,
|
|
2679
|
-
initialState: metadata.state ===
|
|
3141
|
+
initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
|
|
2680
3142
|
metadataStore: this._metadataStore,
|
|
2681
3143
|
gossip,
|
|
2682
3144
|
presence,
|
|
@@ -2685,23 +3147,23 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2685
3147
|
signingContext: this._signingContext,
|
|
2686
3148
|
callbacks: {
|
|
2687
3149
|
beforeReady: async () => {
|
|
2688
|
-
(0,
|
|
3150
|
+
(0, import_log11.log)("before space ready", {
|
|
2689
3151
|
space: space.key
|
|
2690
3152
|
}, {
|
|
2691
|
-
F:
|
|
2692
|
-
L:
|
|
3153
|
+
F: __dxlog_file13,
|
|
3154
|
+
L: 231,
|
|
2693
3155
|
S: this,
|
|
2694
3156
|
C: (f, a) => f(...a)
|
|
2695
3157
|
});
|
|
2696
3158
|
await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2697
3159
|
},
|
|
2698
3160
|
afterReady: async () => {
|
|
2699
|
-
(0,
|
|
3161
|
+
(0, import_log11.log)("after space ready", {
|
|
2700
3162
|
space: space.key,
|
|
2701
3163
|
open: this._isOpen
|
|
2702
3164
|
}, {
|
|
2703
|
-
F:
|
|
2704
|
-
L:
|
|
3165
|
+
F: __dxlog_file13,
|
|
3166
|
+
L: 238,
|
|
2705
3167
|
S: this,
|
|
2706
3168
|
C: (f, a) => f(...a)
|
|
2707
3169
|
});
|
|
@@ -2710,11 +3172,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2710
3172
|
}
|
|
2711
3173
|
},
|
|
2712
3174
|
beforeClose: async () => {
|
|
2713
|
-
(0,
|
|
3175
|
+
(0, import_log11.log)("before space close", {
|
|
2714
3176
|
space: space.key
|
|
2715
3177
|
}, {
|
|
2716
|
-
F:
|
|
2717
|
-
L:
|
|
3178
|
+
F: __dxlog_file13,
|
|
3179
|
+
L: 244,
|
|
2718
3180
|
S: this,
|
|
2719
3181
|
C: (f, a) => f(...a)
|
|
2720
3182
|
});
|
|
@@ -2723,7 +3185,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2723
3185
|
},
|
|
2724
3186
|
cache: metadata.cache
|
|
2725
3187
|
});
|
|
2726
|
-
if (metadata.state !==
|
|
3188
|
+
if (metadata.state !== import_services8.SpaceState.INACTIVE) {
|
|
2727
3189
|
await dataSpace.open();
|
|
2728
3190
|
}
|
|
2729
3191
|
if (metadata.controlTimeframe) {
|
|
@@ -2754,15 +3216,15 @@ DataSpaceManager = _ts_decorate2([
|
|
|
2754
3216
|
|
|
2755
3217
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
2756
3218
|
var import_async10 = require("@dxos/async");
|
|
2757
|
-
var
|
|
3219
|
+
var import_codec_protobuf5 = require("@dxos/codec-protobuf");
|
|
2758
3220
|
var import_debug6 = require("@dxos/debug");
|
|
2759
3221
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
2760
3222
|
var import_errors4 = require("@dxos/errors");
|
|
2761
|
-
var
|
|
2762
|
-
var
|
|
2763
|
-
var
|
|
3223
|
+
var import_log12 = require("@dxos/log");
|
|
3224
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
3225
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2764
3226
|
var import_util5 = require("@dxos/util");
|
|
2765
|
-
var
|
|
3227
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
2766
3228
|
var SpacesServiceImpl = class {
|
|
2767
3229
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
2768
3230
|
this._identityManager = _identityManager;
|
|
@@ -2784,10 +3246,10 @@ var SpacesServiceImpl = class {
|
|
|
2784
3246
|
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
2785
3247
|
if (state) {
|
|
2786
3248
|
switch (state) {
|
|
2787
|
-
case
|
|
3249
|
+
case import_services9.SpaceState.ACTIVE:
|
|
2788
3250
|
await space.activate();
|
|
2789
3251
|
break;
|
|
2790
|
-
case
|
|
3252
|
+
case import_services9.SpaceState.INACTIVE:
|
|
2791
3253
|
await space.deactivate();
|
|
2792
3254
|
break;
|
|
2793
3255
|
default:
|
|
@@ -2796,14 +3258,14 @@ var SpacesServiceImpl = class {
|
|
|
2796
3258
|
}
|
|
2797
3259
|
}
|
|
2798
3260
|
querySpaces() {
|
|
2799
|
-
return new
|
|
3261
|
+
return new import_codec_protobuf5.Stream(({ next, ctx }) => {
|
|
2800
3262
|
const scheduler = new import_async10.UpdateScheduler(ctx, async () => {
|
|
2801
3263
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2802
3264
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
2803
|
-
(0,
|
|
3265
|
+
(0, import_log12.log)("update", {
|
|
2804
3266
|
spaces
|
|
2805
3267
|
}, {
|
|
2806
|
-
F:
|
|
3268
|
+
F: __dxlog_file14,
|
|
2807
3269
|
L: 78,
|
|
2808
3270
|
S: this,
|
|
2809
3271
|
C: (f, a) => f(...a)
|
|
@@ -2851,7 +3313,7 @@ var SpacesServiceImpl = class {
|
|
|
2851
3313
|
await space.postMessage(getChannelId(channel), message);
|
|
2852
3314
|
}
|
|
2853
3315
|
subscribeMessages({ spaceKey, channel }) {
|
|
2854
|
-
return new
|
|
3316
|
+
return new import_codec_protobuf5.Stream(({ ctx, next }) => {
|
|
2855
3317
|
(0, import_async10.scheduleTask)(ctx, async () => {
|
|
2856
3318
|
var _a;
|
|
2857
3319
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
@@ -2864,7 +3326,7 @@ var SpacesServiceImpl = class {
|
|
|
2864
3326
|
});
|
|
2865
3327
|
}
|
|
2866
3328
|
queryCredentials({ spaceKey }) {
|
|
2867
|
-
return new
|
|
3329
|
+
return new import_codec_protobuf5.Stream(({ ctx, next }) => {
|
|
2868
3330
|
var _a;
|
|
2869
3331
|
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
2870
3332
|
const processor = {
|
|
@@ -2898,7 +3360,7 @@ var SpacesServiceImpl = class {
|
|
|
2898
3360
|
return {
|
|
2899
3361
|
spaceKey: space.key,
|
|
2900
3362
|
state: space.state,
|
|
2901
|
-
error: space.error ? (0,
|
|
3363
|
+
error: space.error ? (0, import_protocols8.encodeError)(space.error) : void 0,
|
|
2902
3364
|
pipeline: {
|
|
2903
3365
|
currentEpoch: space.dataPipeline.currentEpoch,
|
|
2904
3366
|
appliedEpoch: space.dataPipeline.appliedEpoch,
|
|
@@ -2926,7 +3388,7 @@ var SpacesServiceImpl = class {
|
|
|
2926
3388
|
displayName: (_c2 = (_b2 = member.assertion.profile) == null ? void 0 : _b2.displayName) != null ? _c2 : (0, import_util5.humanize)(member.key)
|
|
2927
3389
|
}
|
|
2928
3390
|
},
|
|
2929
|
-
presence: isMe || peers.length > 0 ?
|
|
3391
|
+
presence: isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
|
|
2930
3392
|
peerStates: peers
|
|
2931
3393
|
};
|
|
2932
3394
|
}),
|
|
@@ -2939,7 +3401,7 @@ var SpacesServiceImpl = class {
|
|
|
2939
3401
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
2940
3402
|
|
|
2941
3403
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
2942
|
-
var
|
|
3404
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
2943
3405
|
var ServiceContext = class {
|
|
2944
3406
|
// prettier-ignore
|
|
2945
3407
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
@@ -2974,24 +3436,24 @@ var ServiceContext = class {
|
|
|
2974
3436
|
});
|
|
2975
3437
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
2976
3438
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
2977
|
-
this._handlerFactories.set(
|
|
3439
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
|
|
2978
3440
|
var _a;
|
|
2979
3441
|
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
|
|
2980
3442
|
}, this._acceptIdentity.bind(this)));
|
|
2981
3443
|
}
|
|
2982
3444
|
async open() {
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
L: 126,
|
|
3445
|
+
await this._checkStorageVersion();
|
|
3446
|
+
(0, import_log13.log)("opening...", void 0, {
|
|
3447
|
+
F: __dxlog_file15,
|
|
3448
|
+
L: 127,
|
|
2988
3449
|
S: this,
|
|
2989
3450
|
C: (f, a) => f(...a)
|
|
2990
3451
|
});
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
3452
|
+
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.begin({
|
|
3453
|
+
id: this._instanceId
|
|
3454
|
+
}), {
|
|
3455
|
+
F: __dxlog_file15,
|
|
3456
|
+
L: 128,
|
|
2995
3457
|
S: this,
|
|
2996
3458
|
C: (f, a) => f(...a)
|
|
2997
3459
|
});
|
|
@@ -3002,26 +3464,26 @@ var ServiceContext = class {
|
|
|
3002
3464
|
if (this.identityManager.identity) {
|
|
3003
3465
|
await this._initialize();
|
|
3004
3466
|
}
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3467
|
+
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.end({
|
|
3468
|
+
id: this._instanceId
|
|
3469
|
+
}), {
|
|
3470
|
+
F: __dxlog_file15,
|
|
3471
|
+
L: 136,
|
|
3008
3472
|
S: this,
|
|
3009
3473
|
C: (f, a) => f(...a)
|
|
3010
3474
|
});
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
F: __dxlog_file12,
|
|
3015
|
-
L: 139,
|
|
3475
|
+
(0, import_log13.log)("opened", void 0, {
|
|
3476
|
+
F: __dxlog_file15,
|
|
3477
|
+
L: 137,
|
|
3016
3478
|
S: this,
|
|
3017
3479
|
C: (f, a) => f(...a)
|
|
3018
3480
|
});
|
|
3019
3481
|
}
|
|
3020
3482
|
async close() {
|
|
3021
3483
|
var _a;
|
|
3022
|
-
(0,
|
|
3023
|
-
F:
|
|
3024
|
-
L:
|
|
3484
|
+
(0, import_log13.log)("closing...", void 0, {
|
|
3485
|
+
F: __dxlog_file15,
|
|
3486
|
+
L: 141,
|
|
3025
3487
|
S: this,
|
|
3026
3488
|
C: (f, a) => f(...a)
|
|
3027
3489
|
});
|
|
@@ -3035,9 +3497,9 @@ var ServiceContext = class {
|
|
|
3035
3497
|
await this.networkManager.close();
|
|
3036
3498
|
await this.signalManager.close();
|
|
3037
3499
|
this.dataServiceSubscriptions.clear();
|
|
3038
|
-
(0,
|
|
3039
|
-
F:
|
|
3040
|
-
L:
|
|
3500
|
+
(0, import_log13.log)("closed", void 0, {
|
|
3501
|
+
F: __dxlog_file15,
|
|
3502
|
+
L: 152,
|
|
3041
3503
|
S: this,
|
|
3042
3504
|
C: (f, a) => f(...a)
|
|
3043
3505
|
});
|
|
@@ -3049,7 +3511,15 @@ var ServiceContext = class {
|
|
|
3049
3511
|
}
|
|
3050
3512
|
getInvitationHandler(invitation) {
|
|
3051
3513
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3052
|
-
(0,
|
|
3514
|
+
(0, import_invariant12.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
3515
|
+
F: __dxlog_file15,
|
|
3516
|
+
L: 164,
|
|
3517
|
+
S: this,
|
|
3518
|
+
A: [
|
|
3519
|
+
"factory",
|
|
3520
|
+
"`Unknown invitation kind: ${invitation.kind}`"
|
|
3521
|
+
]
|
|
3522
|
+
});
|
|
3053
3523
|
return factory(invitation);
|
|
3054
3524
|
}
|
|
3055
3525
|
async _acceptIdentity(params) {
|
|
@@ -3059,16 +3529,16 @@ var ServiceContext = class {
|
|
|
3059
3529
|
}
|
|
3060
3530
|
async _checkStorageVersion() {
|
|
3061
3531
|
await this.metadataStore.load();
|
|
3062
|
-
if (this.metadataStore.version !==
|
|
3063
|
-
throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${
|
|
3532
|
+
if (this.metadataStore.version !== import_protocols9.STORAGE_VERSION) {
|
|
3533
|
+
throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${import_protocols9.STORAGE_VERSION}`);
|
|
3064
3534
|
}
|
|
3065
3535
|
}
|
|
3066
3536
|
// Called when identity is created.
|
|
3067
3537
|
async _initialize() {
|
|
3068
3538
|
var _a;
|
|
3069
|
-
(0,
|
|
3070
|
-
F:
|
|
3071
|
-
L:
|
|
3539
|
+
(0, import_log13.log)("initializing spaces...", void 0, {
|
|
3540
|
+
F: __dxlog_file15,
|
|
3541
|
+
L: 185,
|
|
3072
3542
|
S: this,
|
|
3073
3543
|
C: (f, a) => f(...a)
|
|
3074
3544
|
});
|
|
@@ -3088,14 +3558,22 @@ var ServiceContext = class {
|
|
|
3088
3558
|
};
|
|
3089
3559
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3090
3560
|
await this.dataSpaceManager.open();
|
|
3091
|
-
this._handlerFactories.set(
|
|
3092
|
-
(0,
|
|
3561
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
|
|
3562
|
+
(0, import_invariant12.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
3563
|
+
F: __dxlog_file15,
|
|
3564
|
+
L: 208,
|
|
3565
|
+
S: this,
|
|
3566
|
+
A: [
|
|
3567
|
+
"this.dataSpaceManager",
|
|
3568
|
+
"'dataSpaceManager not initialized yet'"
|
|
3569
|
+
]
|
|
3570
|
+
});
|
|
3093
3571
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3094
3572
|
});
|
|
3095
3573
|
this.initialized.wake();
|
|
3096
3574
|
this._deviceSpaceSync = {
|
|
3097
3575
|
processCredential: async (credential) => {
|
|
3098
|
-
const assertion = (0,
|
|
3576
|
+
const assertion = (0, import_credentials15.getCredentialAssertion)(credential);
|
|
3099
3577
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
3100
3578
|
return;
|
|
3101
3579
|
}
|
|
@@ -3103,33 +3581,33 @@ var ServiceContext = class {
|
|
|
3103
3581
|
return;
|
|
3104
3582
|
}
|
|
3105
3583
|
if (!this.dataSpaceManager) {
|
|
3106
|
-
(0,
|
|
3584
|
+
(0, import_log13.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3107
3585
|
details: assertion
|
|
3108
3586
|
}, {
|
|
3109
|
-
F:
|
|
3110
|
-
L:
|
|
3587
|
+
F: __dxlog_file15,
|
|
3588
|
+
L: 224,
|
|
3111
3589
|
S: this,
|
|
3112
3590
|
C: (f, a) => f(...a)
|
|
3113
3591
|
});
|
|
3114
3592
|
return;
|
|
3115
3593
|
}
|
|
3116
3594
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
3117
|
-
(0,
|
|
3595
|
+
(0, import_log13.log)("space already exists, ignoring space admission", {
|
|
3118
3596
|
details: assertion
|
|
3119
3597
|
}, {
|
|
3120
|
-
F:
|
|
3121
|
-
L:
|
|
3598
|
+
F: __dxlog_file15,
|
|
3599
|
+
L: 228,
|
|
3122
3600
|
S: this,
|
|
3123
3601
|
C: (f, a) => f(...a)
|
|
3124
3602
|
});
|
|
3125
3603
|
return;
|
|
3126
3604
|
}
|
|
3127
3605
|
try {
|
|
3128
|
-
(0,
|
|
3606
|
+
(0, import_log13.log)("accepting space recorded in halo", {
|
|
3129
3607
|
details: assertion
|
|
3130
3608
|
}, {
|
|
3131
|
-
F:
|
|
3132
|
-
L:
|
|
3609
|
+
F: __dxlog_file15,
|
|
3610
|
+
L: 233,
|
|
3133
3611
|
S: this,
|
|
3134
3612
|
C: (f, a) => f(...a)
|
|
3135
3613
|
});
|
|
@@ -3138,9 +3616,9 @@ var ServiceContext = class {
|
|
|
3138
3616
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3139
3617
|
});
|
|
3140
3618
|
} catch (err) {
|
|
3141
|
-
|
|
3142
|
-
F:
|
|
3143
|
-
L:
|
|
3619
|
+
import_log13.log.catch(err, void 0, {
|
|
3620
|
+
F: __dxlog_file15,
|
|
3621
|
+
L: 239,
|
|
3144
3622
|
S: this,
|
|
3145
3623
|
C: (f, a) => f(...a)
|
|
3146
3624
|
});
|
|
@@ -3152,24 +3630,24 @@ var ServiceContext = class {
|
|
|
3152
3630
|
};
|
|
3153
3631
|
|
|
3154
3632
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3155
|
-
var import_tiny_invariant13 = __toESM(require("tiny-invariant"));
|
|
3156
3633
|
var import_async17 = require("@dxos/async");
|
|
3157
3634
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
3158
|
-
var
|
|
3635
|
+
var import_document_model2 = require("@dxos/document-model");
|
|
3159
3636
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
3637
|
+
var import_invariant14 = require("@dxos/invariant");
|
|
3160
3638
|
var import_keys12 = require("@dxos/keys");
|
|
3161
|
-
var
|
|
3639
|
+
var import_log16 = require("@dxos/log");
|
|
3162
3640
|
var import_messaging = require("@dxos/messaging");
|
|
3163
3641
|
var import_model_factory = require("@dxos/model-factory");
|
|
3164
3642
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
3165
|
-
var
|
|
3166
|
-
var
|
|
3643
|
+
var import_protocols10 = require("@dxos/protocols");
|
|
3644
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3167
3645
|
var import_text_model = require("@dxos/text-model");
|
|
3168
3646
|
|
|
3169
3647
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3170
3648
|
var import_async12 = require("@dxos/async");
|
|
3171
|
-
var
|
|
3172
|
-
var
|
|
3649
|
+
var import_codec_protobuf6 = require("@dxos/codec-protobuf");
|
|
3650
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3173
3651
|
var DevicesServiceImpl = class {
|
|
3174
3652
|
constructor(_identityManager) {
|
|
3175
3653
|
this._identityManager = _identityManager;
|
|
@@ -3178,7 +3656,7 @@ var DevicesServiceImpl = class {
|
|
|
3178
3656
|
throw new Error("Method not implemented.");
|
|
3179
3657
|
}
|
|
3180
3658
|
queryDevices() {
|
|
3181
|
-
return new
|
|
3659
|
+
return new import_codec_protobuf6.Stream(({ next }) => {
|
|
3182
3660
|
const update = () => {
|
|
3183
3661
|
var _a;
|
|
3184
3662
|
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
@@ -3192,7 +3670,7 @@ var DevicesServiceImpl = class {
|
|
|
3192
3670
|
var _a2;
|
|
3193
3671
|
return {
|
|
3194
3672
|
deviceKey: key,
|
|
3195
|
-
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ?
|
|
3673
|
+
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services11.DeviceKind.CURRENT : import_services11.DeviceKind.TRUSTED
|
|
3196
3674
|
};
|
|
3197
3675
|
})
|
|
3198
3676
|
});
|
|
@@ -3215,16 +3693,16 @@ var DevicesServiceImpl = class {
|
|
|
3215
3693
|
|
|
3216
3694
|
// packages/sdk/client-services/src/packlets/devtools/devtools.ts
|
|
3217
3695
|
var import_async15 = require("@dxos/async");
|
|
3218
|
-
var
|
|
3696
|
+
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
3219
3697
|
|
|
3220
3698
|
// packages/sdk/client-services/src/packlets/devtools/feeds.ts
|
|
3221
3699
|
var import_async13 = require("@dxos/async");
|
|
3222
|
-
var
|
|
3700
|
+
var import_codec_protobuf7 = require("@dxos/codec-protobuf");
|
|
3223
3701
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
3224
3702
|
var import_keys9 = require("@dxos/keys");
|
|
3225
3703
|
var import_util6 = require("@dxos/util");
|
|
3226
3704
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
3227
|
-
return new
|
|
3705
|
+
return new import_codec_protobuf7.Stream(({ next }) => {
|
|
3228
3706
|
const subscriptions = new import_async13.EventSubscriptions();
|
|
3229
3707
|
const feedMap = new import_util6.ComplexMap(import_keys9.PublicKey.hash);
|
|
3230
3708
|
const update = () => {
|
|
@@ -3256,7 +3734,7 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
3256
3734
|
});
|
|
3257
3735
|
};
|
|
3258
3736
|
var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
|
|
3259
|
-
return new
|
|
3737
|
+
return new import_codec_protobuf7.Stream(({ next }) => {
|
|
3260
3738
|
if (!feedKey) {
|
|
3261
3739
|
return;
|
|
3262
3740
|
}
|
|
@@ -3296,8 +3774,8 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
|
|
|
3296
3774
|
|
|
3297
3775
|
// packages/sdk/client-services/src/packlets/devtools/keys.ts
|
|
3298
3776
|
var import_async14 = require("@dxos/async");
|
|
3299
|
-
var
|
|
3300
|
-
var subscribeToKeyringKeys = ({ keyring }) => new
|
|
3777
|
+
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
3778
|
+
var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf8.Stream(({ next, ctx }) => {
|
|
3301
3779
|
const update = async () => {
|
|
3302
3780
|
next({
|
|
3303
3781
|
keys: await keyring.list()
|
|
@@ -3308,8 +3786,8 @@ var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf7.Stream(
|
|
|
3308
3786
|
});
|
|
3309
3787
|
|
|
3310
3788
|
// packages/sdk/client-services/src/packlets/devtools/metadata.ts
|
|
3311
|
-
var
|
|
3312
|
-
var subscribeToMetadata = ({ context }) => new
|
|
3789
|
+
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
3790
|
+
var subscribeToMetadata = ({ context }) => new import_codec_protobuf9.Stream(({ next, ctx }) => {
|
|
3313
3791
|
context.metadataStore.update.on(ctx, (data) => next({
|
|
3314
3792
|
metadata: data
|
|
3315
3793
|
}));
|
|
@@ -3319,10 +3797,10 @@ var subscribeToMetadata = ({ context }) => new import_codec_protobuf8.Stream(({
|
|
|
3319
3797
|
});
|
|
3320
3798
|
|
|
3321
3799
|
// packages/sdk/client-services/src/packlets/devtools/network.ts
|
|
3322
|
-
var
|
|
3800
|
+
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
3323
3801
|
var import_context7 = require("@dxos/context");
|
|
3324
3802
|
var import_keys10 = require("@dxos/keys");
|
|
3325
|
-
var subscribeToNetworkStatus = ({ signalManager }) => new
|
|
3803
|
+
var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf10.Stream(({ next, close }) => {
|
|
3326
3804
|
const update = () => {
|
|
3327
3805
|
try {
|
|
3328
3806
|
const status = signalManager.getStatus();
|
|
@@ -3336,7 +3814,7 @@ var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf9
|
|
|
3336
3814
|
signalManager.statusChanged.on(() => update());
|
|
3337
3815
|
update();
|
|
3338
3816
|
});
|
|
3339
|
-
var subscribeToSignal = ({ signalManager }) => new
|
|
3817
|
+
var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf10.Stream(({ next }) => {
|
|
3340
3818
|
const ctx = new import_context7.Context();
|
|
3341
3819
|
signalManager.onMessage.on(ctx, (message) => {
|
|
3342
3820
|
next({
|
|
@@ -3358,7 +3836,7 @@ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf9.Stream
|
|
|
3358
3836
|
return ctx.dispose();
|
|
3359
3837
|
};
|
|
3360
3838
|
});
|
|
3361
|
-
var subscribeToSwarmInfo = ({ networkManager }) => new
|
|
3839
|
+
var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf10.Stream(({ next }) => {
|
|
3362
3840
|
var _a;
|
|
3363
3841
|
const update = () => {
|
|
3364
3842
|
var _a2;
|
|
@@ -3374,9 +3852,9 @@ var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf9.St
|
|
|
3374
3852
|
});
|
|
3375
3853
|
|
|
3376
3854
|
// packages/sdk/client-services/src/packlets/devtools/spaces.ts
|
|
3377
|
-
var
|
|
3855
|
+
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
3378
3856
|
var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
3379
|
-
return new
|
|
3857
|
+
return new import_codec_protobuf11.Stream(({ next }) => {
|
|
3380
3858
|
let unsubscribe;
|
|
3381
3859
|
const update = async () => {
|
|
3382
3860
|
const spaces = [
|
|
@@ -3420,7 +3898,7 @@ var DevtoolsServiceImpl = class {
|
|
|
3420
3898
|
this.params = params;
|
|
3421
3899
|
}
|
|
3422
3900
|
events(request) {
|
|
3423
|
-
return new
|
|
3901
|
+
return new import_codec_protobuf12.Stream(({ next }) => {
|
|
3424
3902
|
this.params.events.ready.on(() => {
|
|
3425
3903
|
next({
|
|
3426
3904
|
ready: {}
|
|
@@ -3527,9 +4005,9 @@ var DevtoolsServiceImpl = class {
|
|
|
3527
4005
|
};
|
|
3528
4006
|
|
|
3529
4007
|
// packages/sdk/client-services/src/packlets/locks/node.ts
|
|
3530
|
-
var
|
|
4008
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
3531
4009
|
var import_lock_file = require("@dxos/lock-file");
|
|
3532
|
-
var
|
|
4010
|
+
var import_log14 = require("@dxos/log");
|
|
3533
4011
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
3534
4012
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3535
4013
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -3540,7 +4018,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
3540
4018
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3541
4019
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3542
4020
|
}
|
|
3543
|
-
var
|
|
4021
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
3544
4022
|
var Lock = class {
|
|
3545
4023
|
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
3546
4024
|
this._lockPath = lockPath;
|
|
@@ -3552,16 +4030,16 @@ var Lock = class {
|
|
|
3552
4030
|
}
|
|
3553
4031
|
async acquire() {
|
|
3554
4032
|
var _a;
|
|
3555
|
-
(0,
|
|
3556
|
-
F:
|
|
4033
|
+
(0, import_log14.log)("acquiring lock...", void 0, {
|
|
4034
|
+
F: __dxlog_file16,
|
|
3557
4035
|
L: 32,
|
|
3558
4036
|
S: this,
|
|
3559
4037
|
C: (f, a) => f(...a)
|
|
3560
4038
|
});
|
|
3561
4039
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
3562
4040
|
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
3563
|
-
(0,
|
|
3564
|
-
F:
|
|
4041
|
+
(0, import_log14.log)("acquired lock", void 0, {
|
|
4042
|
+
F: __dxlog_file16,
|
|
3565
4043
|
L: 37,
|
|
3566
4044
|
S: this,
|
|
3567
4045
|
C: (f, a) => f(...a)
|
|
@@ -3570,33 +4048,42 @@ var Lock = class {
|
|
|
3570
4048
|
async release() {
|
|
3571
4049
|
var _a;
|
|
3572
4050
|
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
3573
|
-
(0,
|
|
4051
|
+
(0, import_invariant13.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
4052
|
+
F: __dxlog_file16,
|
|
4053
|
+
L: 42,
|
|
4054
|
+
S: this,
|
|
4055
|
+
A: [
|
|
4056
|
+
"this._fileHandle",
|
|
4057
|
+
"'Lock is not acquired'"
|
|
4058
|
+
]
|
|
4059
|
+
});
|
|
3574
4060
|
await import_lock_file.LockFile.release(this._fileHandle);
|
|
3575
4061
|
}
|
|
3576
4062
|
};
|
|
3577
4063
|
_ts_decorate3([
|
|
3578
|
-
|
|
4064
|
+
import_log14.logInfo
|
|
3579
4065
|
], Lock.prototype, "lockKey", null);
|
|
3580
4066
|
|
|
3581
4067
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
3582
4068
|
var import_async16 = require("@dxos/async");
|
|
3583
|
-
var
|
|
3584
|
-
var
|
|
3585
|
-
var
|
|
4069
|
+
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
4070
|
+
var import_log15 = require("@dxos/log");
|
|
4071
|
+
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3586
4072
|
var import_util7 = require("@dxos/util");
|
|
3587
4073
|
var LoggingServiceImpl = class {
|
|
3588
4074
|
constructor() {
|
|
3589
4075
|
this._logs = new import_async16.Event();
|
|
4076
|
+
this._started = new Date();
|
|
3590
4077
|
this._logProcessor = (_config, entry2) => {
|
|
3591
4078
|
this._logs.emit(entry2);
|
|
3592
4079
|
};
|
|
3593
4080
|
}
|
|
3594
4081
|
async open() {
|
|
3595
|
-
|
|
4082
|
+
import_log15.log.runtimeConfig.processors.push(this._logProcessor);
|
|
3596
4083
|
}
|
|
3597
4084
|
async close() {
|
|
3598
|
-
const index =
|
|
3599
|
-
|
|
4085
|
+
const index = import_log15.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
4086
|
+
import_log15.log.runtimeConfig.processors.splice(index, 1);
|
|
3600
4087
|
}
|
|
3601
4088
|
async controlMetrics({ reset, record }) {
|
|
3602
4089
|
if (reset) {
|
|
@@ -3611,35 +4098,41 @@ var LoggingServiceImpl = class {
|
|
|
3611
4098
|
recording: import_util7.tracer.recording
|
|
3612
4099
|
};
|
|
3613
4100
|
}
|
|
3614
|
-
|
|
3615
|
-
|
|
4101
|
+
/**
|
|
4102
|
+
* @deprecated (Move to diagnostics).
|
|
4103
|
+
*/
|
|
4104
|
+
queryMetrics({ interval = 5e3 }) {
|
|
4105
|
+
const getNumericalValues = (key) => {
|
|
3616
4106
|
var _a;
|
|
3617
|
-
const
|
|
4107
|
+
const events = (_a = import_util7.tracer.get(key)) != null ? _a : [];
|
|
3618
4108
|
return {
|
|
3619
4109
|
key,
|
|
3620
|
-
stats: (0, import_util7.numericalValues)(
|
|
4110
|
+
stats: (0, import_util7.numericalValues)(events, "duration")
|
|
3621
4111
|
};
|
|
3622
4112
|
};
|
|
3623
|
-
return new
|
|
4113
|
+
return new import_codec_protobuf13.Stream(({ next }) => {
|
|
3624
4114
|
const update = () => {
|
|
3625
4115
|
const metrics = {
|
|
3626
4116
|
timestamp: new Date(),
|
|
3627
4117
|
values: [
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
]
|
|
4118
|
+
getNumericalValues("dxos.echo.pipeline.control"),
|
|
4119
|
+
getNumericalValues("dxos.echo.pipeline.data")
|
|
4120
|
+
].filter(Boolean)
|
|
3631
4121
|
};
|
|
3632
|
-
next(
|
|
4122
|
+
next({
|
|
4123
|
+
timestamp: new Date(),
|
|
4124
|
+
metrics
|
|
4125
|
+
});
|
|
3633
4126
|
};
|
|
3634
4127
|
update();
|
|
3635
|
-
const i = setInterval(update, interval);
|
|
4128
|
+
const i = setInterval(update, Math.max(interval, 1e3));
|
|
3636
4129
|
return () => {
|
|
3637
4130
|
clearInterval(i);
|
|
3638
4131
|
};
|
|
3639
4132
|
});
|
|
3640
4133
|
}
|
|
3641
4134
|
queryLogs(request) {
|
|
3642
|
-
return new
|
|
4135
|
+
return new import_codec_protobuf13.Stream(({ ctx, next }) => {
|
|
3643
4136
|
const handler = (entry2) => {
|
|
3644
4137
|
var _a, _b, _c, _d, _e;
|
|
3645
4138
|
if (LOG_PROCESSING > 0) {
|
|
@@ -3653,7 +4146,7 @@ var LoggingServiceImpl = class {
|
|
|
3653
4146
|
}
|
|
3654
4147
|
const record = {
|
|
3655
4148
|
...entry2,
|
|
3656
|
-
context: (0, import_util7.jsonify)((0,
|
|
4149
|
+
context: (0, import_util7.jsonify)((0, import_log15.getContextFromEntry)(entry2)),
|
|
3657
4150
|
timestamp: new Date(),
|
|
3658
4151
|
meta: {
|
|
3659
4152
|
// TODO(dmaretskyi): Fix proto.
|
|
@@ -3674,17 +4167,17 @@ var LoggingServiceImpl = class {
|
|
|
3674
4167
|
};
|
|
3675
4168
|
var matchFilter = (filter, level, path, options) => {
|
|
3676
4169
|
switch (options) {
|
|
3677
|
-
case
|
|
4170
|
+
case import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
3678
4171
|
return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
3679
|
-
case
|
|
4172
|
+
case import_services12.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
3680
4173
|
return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
3681
4174
|
}
|
|
3682
4175
|
};
|
|
3683
4176
|
var shouldLog = (entry2, request) => {
|
|
3684
4177
|
var _a;
|
|
3685
|
-
const options = (_a = request.options) != null ? _a :
|
|
4178
|
+
const options = (_a = request.options) != null ? _a : import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
3686
4179
|
if (request.filters === void 0) {
|
|
3687
|
-
return options ===
|
|
4180
|
+
return options === import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
3688
4181
|
} else {
|
|
3689
4182
|
return request.filters.some((filter) => {
|
|
3690
4183
|
var _a2, _b;
|
|
@@ -3695,14 +4188,14 @@ var shouldLog = (entry2, request) => {
|
|
|
3695
4188
|
var LOG_PROCESSING = 0;
|
|
3696
4189
|
|
|
3697
4190
|
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
3698
|
-
var
|
|
4191
|
+
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
3699
4192
|
var NetworkServiceImpl = class {
|
|
3700
4193
|
constructor(networkManager, signalManager) {
|
|
3701
4194
|
this.networkManager = networkManager;
|
|
3702
4195
|
this.signalManager = signalManager;
|
|
3703
4196
|
}
|
|
3704
4197
|
queryStatus() {
|
|
3705
|
-
return new
|
|
4198
|
+
return new import_codec_protobuf14.Stream(({ next }) => {
|
|
3706
4199
|
const update = () => {
|
|
3707
4200
|
next({
|
|
3708
4201
|
swarm: this.networkManager.connectionState,
|
|
@@ -3776,12 +4269,15 @@ var toStorageType = (type) => {
|
|
|
3776
4269
|
};
|
|
3777
4270
|
|
|
3778
4271
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
3779
|
-
var
|
|
4272
|
+
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
4273
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4274
|
+
var import_util9 = require("@dxos/util");
|
|
3780
4275
|
var SystemServiceImpl = class {
|
|
3781
|
-
constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
4276
|
+
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
3782
4277
|
this._config = config;
|
|
3783
4278
|
this._statusUpdate = statusUpdate;
|
|
3784
4279
|
this._getCurrentStatus = getCurrentStatus;
|
|
4280
|
+
this._getDiagnostics = getDiagnostics;
|
|
3785
4281
|
this._onUpdateStatus = onUpdateStatus;
|
|
3786
4282
|
this._onReset = onReset;
|
|
3787
4283
|
}
|
|
@@ -3789,12 +4285,25 @@ var SystemServiceImpl = class {
|
|
|
3789
4285
|
var _a, _b;
|
|
3790
4286
|
return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
|
|
3791
4287
|
}
|
|
4288
|
+
/**
|
|
4289
|
+
* NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
|
|
4290
|
+
*/
|
|
4291
|
+
async getDiagnostics({ keys } = {}) {
|
|
4292
|
+
const diagnostics = await this._getDiagnostics();
|
|
4293
|
+
return {
|
|
4294
|
+
timestamp: new Date(),
|
|
4295
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util9.jsonKeyReplacer)({
|
|
4296
|
+
truncate: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
4297
|
+
humanize: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
4298
|
+
})))
|
|
4299
|
+
};
|
|
4300
|
+
}
|
|
3792
4301
|
async updateStatus({ status }) {
|
|
3793
4302
|
await this._onUpdateStatus(status);
|
|
3794
4303
|
}
|
|
3795
4304
|
// TODO(burdon): Standardize interval option in stream request?
|
|
3796
4305
|
queryStatus({ interval = 3e3 } = {}) {
|
|
3797
|
-
return new
|
|
4306
|
+
return new import_codec_protobuf15.Stream(({ next }) => {
|
|
3798
4307
|
const update = () => {
|
|
3799
4308
|
next({
|
|
3800
4309
|
status: this._getCurrentStatus()
|
|
@@ -3849,18 +4358,16 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3849
4358
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3850
4359
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3851
4360
|
}
|
|
3852
|
-
var
|
|
4361
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
3853
4362
|
var createDefaultModelFactory = () => {
|
|
3854
|
-
return new import_model_factory.ModelFactory().registerModel(
|
|
4363
|
+
return new import_model_factory.ModelFactory().registerModel(import_document_model2.DocumentModel).registerModel(import_text_model.TextModel);
|
|
3855
4364
|
};
|
|
3856
4365
|
var ClientServicesHost = class {
|
|
3857
4366
|
constructor({
|
|
3858
4367
|
config,
|
|
3859
4368
|
modelFactory = createDefaultModelFactory(),
|
|
3860
|
-
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
3861
4369
|
transportFactory,
|
|
3862
4370
|
signalManager,
|
|
3863
|
-
connectionLog,
|
|
3864
4371
|
storage,
|
|
3865
4372
|
// TODO(wittjosiah): Turn this on by default.
|
|
3866
4373
|
lockKey,
|
|
@@ -3893,12 +4400,15 @@ var ClientServicesHost = class {
|
|
|
3893
4400
|
this._systemService = new SystemServiceImpl({
|
|
3894
4401
|
config: this._config,
|
|
3895
4402
|
statusUpdate: this._statusUpdate,
|
|
3896
|
-
getCurrentStatus: () => this.isOpen ?
|
|
4403
|
+
getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
|
|
4404
|
+
getDiagnostics: () => {
|
|
4405
|
+
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
4406
|
+
},
|
|
3897
4407
|
onUpdateStatus: async (status) => {
|
|
3898
4408
|
var _a, _b;
|
|
3899
|
-
if (!this.isOpen && status ===
|
|
4409
|
+
if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
|
|
3900
4410
|
await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
|
|
3901
|
-
} else if (this.isOpen && status ===
|
|
4411
|
+
} else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
|
|
3902
4412
|
await ((_b = this._resourceLock) == null ? void 0 : _b.release());
|
|
3903
4413
|
}
|
|
3904
4414
|
},
|
|
@@ -3914,6 +4424,12 @@ var ClientServicesHost = class {
|
|
|
3914
4424
|
get isOpen() {
|
|
3915
4425
|
return this._open;
|
|
3916
4426
|
}
|
|
4427
|
+
get config() {
|
|
4428
|
+
return this._config;
|
|
4429
|
+
}
|
|
4430
|
+
get context() {
|
|
4431
|
+
return this._serviceContext;
|
|
4432
|
+
}
|
|
3917
4433
|
get serviceRegistry() {
|
|
3918
4434
|
return this._serviceRegistry;
|
|
3919
4435
|
}
|
|
@@ -3930,9 +4446,31 @@ var ClientServicesHost = class {
|
|
|
3930
4446
|
*/
|
|
3931
4447
|
initialize({ config, ...options }) {
|
|
3932
4448
|
var _a, _b, _c;
|
|
3933
|
-
(0,
|
|
4449
|
+
(0, import_invariant14.invariant)(!this._open, "service host is open", {
|
|
4450
|
+
F: __dxlog_file17,
|
|
4451
|
+
L: 172,
|
|
4452
|
+
S: this,
|
|
4453
|
+
A: [
|
|
4454
|
+
"!this._open",
|
|
4455
|
+
"'service host is open'"
|
|
4456
|
+
]
|
|
4457
|
+
});
|
|
4458
|
+
import_log16.log.info("initializing...", void 0, {
|
|
4459
|
+
F: __dxlog_file17,
|
|
4460
|
+
L: 173,
|
|
4461
|
+
S: this,
|
|
4462
|
+
C: (f, a) => f(...a)
|
|
4463
|
+
});
|
|
3934
4464
|
if (config) {
|
|
3935
|
-
(0,
|
|
4465
|
+
(0, import_invariant14.invariant)(!this._config, "config already set", {
|
|
4466
|
+
F: __dxlog_file17,
|
|
4467
|
+
L: 176,
|
|
4468
|
+
S: this,
|
|
4469
|
+
A: [
|
|
4470
|
+
"!this._config",
|
|
4471
|
+
"'config already set'"
|
|
4472
|
+
]
|
|
4473
|
+
});
|
|
3936
4474
|
this._config = config;
|
|
3937
4475
|
if (!this._storage) {
|
|
3938
4476
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
@@ -3942,12 +4480,26 @@ var ClientServicesHost = class {
|
|
|
3942
4480
|
iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
|
|
3943
4481
|
}), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
|
|
3944
4482
|
this._signalManager = signalManager;
|
|
3945
|
-
(0,
|
|
4483
|
+
(0, import_invariant14.invariant)(!this._networkManager, "network manager already set", {
|
|
4484
|
+
F: __dxlog_file17,
|
|
4485
|
+
L: 192,
|
|
4486
|
+
S: this,
|
|
4487
|
+
A: [
|
|
4488
|
+
"!this._networkManager",
|
|
4489
|
+
"'network manager already set'"
|
|
4490
|
+
]
|
|
4491
|
+
});
|
|
3946
4492
|
this._networkManager = new import_network_manager2.NetworkManager({
|
|
3947
4493
|
log: connectionLog,
|
|
3948
4494
|
transportFactory,
|
|
3949
4495
|
signalManager
|
|
3950
4496
|
});
|
|
4497
|
+
import_log16.log.info("initialized", void 0, {
|
|
4498
|
+
F: __dxlog_file17,
|
|
4499
|
+
L: 199,
|
|
4500
|
+
S: this,
|
|
4501
|
+
C: (f, a) => f(...a)
|
|
4502
|
+
});
|
|
3951
4503
|
}
|
|
3952
4504
|
async open() {
|
|
3953
4505
|
var _a, _b, _c;
|
|
@@ -3955,24 +4507,56 @@ var ClientServicesHost = class {
|
|
|
3955
4507
|
return;
|
|
3956
4508
|
}
|
|
3957
4509
|
const traceId = import_keys12.PublicKey.random().toHex();
|
|
3958
|
-
|
|
4510
|
+
import_log16.log.trace("dxos.client-services.host.open", import_protocols10.trace.begin({
|
|
3959
4511
|
id: traceId
|
|
3960
4512
|
}), {
|
|
3961
|
-
F:
|
|
3962
|
-
L:
|
|
4513
|
+
F: __dxlog_file17,
|
|
4514
|
+
L: 209,
|
|
3963
4515
|
S: this,
|
|
3964
4516
|
C: (f, a) => f(...a)
|
|
3965
4517
|
});
|
|
3966
|
-
(0,
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
4518
|
+
(0, import_invariant14.invariant)(this._config, "config not set", {
|
|
4519
|
+
F: __dxlog_file17,
|
|
4520
|
+
L: 211,
|
|
4521
|
+
S: this,
|
|
4522
|
+
A: [
|
|
4523
|
+
"this._config",
|
|
4524
|
+
"'config not set'"
|
|
4525
|
+
]
|
|
4526
|
+
});
|
|
4527
|
+
(0, import_invariant14.invariant)(this._storage, "storage not set", {
|
|
4528
|
+
F: __dxlog_file17,
|
|
4529
|
+
L: 212,
|
|
4530
|
+
S: this,
|
|
4531
|
+
A: [
|
|
4532
|
+
"this._storage",
|
|
4533
|
+
"'storage not set'"
|
|
4534
|
+
]
|
|
4535
|
+
});
|
|
4536
|
+
(0, import_invariant14.invariant)(this._signalManager, "signal manager not set", {
|
|
4537
|
+
F: __dxlog_file17,
|
|
4538
|
+
L: 213,
|
|
4539
|
+
S: this,
|
|
4540
|
+
A: [
|
|
4541
|
+
"this._signalManager",
|
|
4542
|
+
"'signal manager not set'"
|
|
4543
|
+
]
|
|
4544
|
+
});
|
|
4545
|
+
(0, import_invariant14.invariant)(this._networkManager, "network manager not set", {
|
|
4546
|
+
F: __dxlog_file17,
|
|
4547
|
+
L: 214,
|
|
4548
|
+
S: this,
|
|
4549
|
+
A: [
|
|
4550
|
+
"this._networkManager",
|
|
4551
|
+
"'network manager not set'"
|
|
4552
|
+
]
|
|
4553
|
+
});
|
|
3970
4554
|
this._opening = true;
|
|
3971
|
-
|
|
4555
|
+
import_log16.log.info("opening...", {
|
|
3972
4556
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
3973
4557
|
}, {
|
|
3974
|
-
F:
|
|
3975
|
-
L:
|
|
4558
|
+
F: __dxlog_file17,
|
|
4559
|
+
L: 217,
|
|
3976
4560
|
S: this,
|
|
3977
4561
|
C: (f, a) => f(...a)
|
|
3978
4562
|
});
|
|
@@ -4003,19 +4587,19 @@ var ClientServicesHost = class {
|
|
|
4003
4587
|
this._open = true;
|
|
4004
4588
|
this._statusUpdate.emit();
|
|
4005
4589
|
const deviceKey = (_c = this._serviceContext.identityManager.identity) == null ? void 0 : _c.deviceKey;
|
|
4006
|
-
|
|
4590
|
+
import_log16.log.info("opened", {
|
|
4007
4591
|
deviceKey
|
|
4008
4592
|
}, {
|
|
4009
|
-
F:
|
|
4010
|
-
L:
|
|
4593
|
+
F: __dxlog_file17,
|
|
4594
|
+
L: 269,
|
|
4011
4595
|
S: this,
|
|
4012
4596
|
C: (f, a) => f(...a)
|
|
4013
4597
|
});
|
|
4014
|
-
|
|
4598
|
+
import_log16.log.trace("dxos.client-services.host.open", import_protocols10.trace.end({
|
|
4015
4599
|
id: traceId
|
|
4016
4600
|
}), {
|
|
4017
|
-
F:
|
|
4018
|
-
L:
|
|
4601
|
+
F: __dxlog_file17,
|
|
4602
|
+
L: 270,
|
|
4019
4603
|
S: this,
|
|
4020
4604
|
C: (f, a) => f(...a)
|
|
4021
4605
|
});
|
|
@@ -4026,11 +4610,11 @@ var ClientServicesHost = class {
|
|
|
4026
4610
|
return;
|
|
4027
4611
|
}
|
|
4028
4612
|
const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
|
|
4029
|
-
|
|
4613
|
+
import_log16.log.info("closing...", {
|
|
4030
4614
|
deviceKey
|
|
4031
4615
|
}, {
|
|
4032
|
-
F:
|
|
4033
|
-
L:
|
|
4616
|
+
F: __dxlog_file17,
|
|
4617
|
+
L: 280,
|
|
4034
4618
|
S: this,
|
|
4035
4619
|
C: (f, a) => f(...a)
|
|
4036
4620
|
});
|
|
@@ -4041,11 +4625,11 @@ var ClientServicesHost = class {
|
|
|
4041
4625
|
await this._serviceContext.close();
|
|
4042
4626
|
this._open = false;
|
|
4043
4627
|
this._statusUpdate.emit();
|
|
4044
|
-
|
|
4628
|
+
import_log16.log.info("closed", {
|
|
4045
4629
|
deviceKey
|
|
4046
4630
|
}, {
|
|
4047
|
-
F:
|
|
4048
|
-
L:
|
|
4631
|
+
F: __dxlog_file17,
|
|
4632
|
+
L: 286,
|
|
4049
4633
|
S: this,
|
|
4050
4634
|
C: (f, a) => f(...a)
|
|
4051
4635
|
});
|
|
@@ -4053,33 +4637,33 @@ var ClientServicesHost = class {
|
|
|
4053
4637
|
async reset() {
|
|
4054
4638
|
var _a, _b, _c;
|
|
4055
4639
|
const traceId = import_keys12.PublicKey.random().toHex();
|
|
4056
|
-
|
|
4640
|
+
import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.begin({
|
|
4057
4641
|
id: traceId
|
|
4058
4642
|
}), {
|
|
4059
|
-
F:
|
|
4060
|
-
L:
|
|
4643
|
+
F: __dxlog_file17,
|
|
4644
|
+
L: 291,
|
|
4061
4645
|
S: this,
|
|
4062
4646
|
C: (f, a) => f(...a)
|
|
4063
4647
|
});
|
|
4064
|
-
(0,
|
|
4065
|
-
F:
|
|
4066
|
-
L:
|
|
4648
|
+
(0, import_log16.log)("resetting...", void 0, {
|
|
4649
|
+
F: __dxlog_file17,
|
|
4650
|
+
L: 293,
|
|
4067
4651
|
S: this,
|
|
4068
4652
|
C: (f, a) => f(...a)
|
|
4069
4653
|
});
|
|
4070
4654
|
await ((_a = this._serviceContext) == null ? void 0 : _a.close());
|
|
4071
4655
|
await this._storage.reset();
|
|
4072
|
-
(0,
|
|
4073
|
-
F:
|
|
4074
|
-
L:
|
|
4656
|
+
(0, import_log16.log)("reset", void 0, {
|
|
4657
|
+
F: __dxlog_file17,
|
|
4658
|
+
L: 296,
|
|
4075
4659
|
S: this,
|
|
4076
4660
|
C: (f, a) => f(...a)
|
|
4077
4661
|
});
|
|
4078
|
-
|
|
4662
|
+
import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.end({
|
|
4079
4663
|
id: traceId
|
|
4080
4664
|
}), {
|
|
4081
|
-
F:
|
|
4082
|
-
L:
|
|
4665
|
+
F: __dxlog_file17,
|
|
4666
|
+
L: 297,
|
|
4083
4667
|
S: this,
|
|
4084
4668
|
C: (f, a) => f(...a)
|
|
4085
4669
|
});
|
|
@@ -4094,6 +4678,7 @@ _ts_decorate4([
|
|
|
4094
4678
|
], ClientServicesHost.prototype, "close", null);
|
|
4095
4679
|
|
|
4096
4680
|
// packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
|
|
4681
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/testing/invitation-utils.ts";
|
|
4097
4682
|
var sanitizeInvitation = (invitation) => {
|
|
4098
4683
|
return {
|
|
4099
4684
|
invitationId: invitation.invitationId,
|
|
@@ -4113,7 +4698,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4113
4698
|
hostObservable.subscribe(async (hostInvitation) => {
|
|
4114
4699
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
4115
4700
|
switch (hostInvitation.state) {
|
|
4116
|
-
case
|
|
4701
|
+
case import_services15.Invitation.State.CONNECTING: {
|
|
4117
4702
|
if ((_b = (_a = hooks == null ? void 0 : hooks.host) == null ? void 0 : _a.onConnecting) == null ? void 0 : _b.call(_a, hostObservable)) {
|
|
4118
4703
|
break;
|
|
4119
4704
|
}
|
|
@@ -4121,29 +4706,37 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4121
4706
|
guestObservable.subscribe(async (guestInvitation) => {
|
|
4122
4707
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
|
|
4123
4708
|
switch (guestInvitation.state) {
|
|
4124
|
-
case
|
|
4709
|
+
case import_services15.Invitation.State.CONNECTING: {
|
|
4125
4710
|
if ((_b2 = (_a2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _a2.onConnecting) == null ? void 0 : _b2.call(_a2, guestObservable)) {
|
|
4126
4711
|
break;
|
|
4127
4712
|
}
|
|
4128
|
-
(0,
|
|
4713
|
+
(0, import_invariant15.invariant)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey), void 0, {
|
|
4714
|
+
F: __dxlog_file18,
|
|
4715
|
+
L: 84,
|
|
4716
|
+
S: void 0,
|
|
4717
|
+
A: [
|
|
4718
|
+
"hostInvitation.swarmKey!.equals(guestInvitation.swarmKey!)",
|
|
4719
|
+
""
|
|
4720
|
+
]
|
|
4721
|
+
});
|
|
4129
4722
|
break;
|
|
4130
4723
|
}
|
|
4131
|
-
case
|
|
4724
|
+
case import_services15.Invitation.State.CONNECTED: {
|
|
4132
4725
|
(_d2 = (_c2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _c2.onConnected) == null ? void 0 : _d2.call(_c2, guestObservable);
|
|
4133
4726
|
break;
|
|
4134
4727
|
}
|
|
4135
|
-
case
|
|
4728
|
+
case import_services15.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
4136
4729
|
if ((_f2 = (_e2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _e2.onReady) == null ? void 0 : _f2.call(_e2, guestObservable)) {
|
|
4137
4730
|
break;
|
|
4138
4731
|
}
|
|
4139
4732
|
await guestObservable.authenticate(await authCode.wait());
|
|
4140
4733
|
break;
|
|
4141
4734
|
}
|
|
4142
|
-
case
|
|
4735
|
+
case import_services15.Invitation.State.AUTHENTICATING: {
|
|
4143
4736
|
(_h2 = (_g2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _g2.onAuthenticating) == null ? void 0 : _h2.call(_g2, guestObservable);
|
|
4144
4737
|
break;
|
|
4145
4738
|
}
|
|
4146
|
-
case
|
|
4739
|
+
case import_services15.Invitation.State.SUCCESS: {
|
|
4147
4740
|
if ((_j2 = (_i2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _i2.onSuccess) == null ? void 0 : _j2.call(_i2, guestObservable)) {
|
|
4148
4741
|
break;
|
|
4149
4742
|
}
|
|
@@ -4152,7 +4745,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4152
4745
|
});
|
|
4153
4746
|
break;
|
|
4154
4747
|
}
|
|
4155
|
-
case
|
|
4748
|
+
case import_services15.Invitation.State.CANCELLED: {
|
|
4156
4749
|
if ((_l2 = (_k2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _k2.onCancelled) == null ? void 0 : _l2.call(_k2, guestObservable)) {
|
|
4157
4750
|
break;
|
|
4158
4751
|
}
|
|
@@ -4161,7 +4754,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4161
4754
|
});
|
|
4162
4755
|
break;
|
|
4163
4756
|
}
|
|
4164
|
-
case
|
|
4757
|
+
case import_services15.Invitation.State.TIMEOUT: {
|
|
4165
4758
|
if ((_n2 = (_m2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _m2.onTimeout) == null ? void 0 : _n2.call(_m2, guestObservable)) {
|
|
4166
4759
|
return;
|
|
4167
4760
|
}
|
|
@@ -4181,11 +4774,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4181
4774
|
});
|
|
4182
4775
|
break;
|
|
4183
4776
|
}
|
|
4184
|
-
case
|
|
4777
|
+
case import_services15.Invitation.State.CONNECTED: {
|
|
4185
4778
|
(_d = (_c = hooks == null ? void 0 : hooks.host) == null ? void 0 : _c.onConnected) == null ? void 0 : _d.call(_c, hostObservable);
|
|
4186
4779
|
break;
|
|
4187
4780
|
}
|
|
4188
|
-
case
|
|
4781
|
+
case import_services15.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
4189
4782
|
if ((_f = (_e = hooks == null ? void 0 : hooks.host) == null ? void 0 : _e.onReady) == null ? void 0 : _f.call(_e, hostObservable)) {
|
|
4190
4783
|
break;
|
|
4191
4784
|
}
|
|
@@ -4194,11 +4787,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4194
4787
|
}
|
|
4195
4788
|
break;
|
|
4196
4789
|
}
|
|
4197
|
-
case
|
|
4790
|
+
case import_services15.Invitation.State.AUTHENTICATING: {
|
|
4198
4791
|
(_h = (_g = hooks == null ? void 0 : hooks.host) == null ? void 0 : _g.onAuthenticating) == null ? void 0 : _h.call(_g, hostObservable);
|
|
4199
4792
|
break;
|
|
4200
4793
|
}
|
|
4201
|
-
case
|
|
4794
|
+
case import_services15.Invitation.State.SUCCESS: {
|
|
4202
4795
|
if ((_j = (_i = hooks == null ? void 0 : hooks.host) == null ? void 0 : _i.onSuccess) == null ? void 0 : _j.call(_i, hostObservable)) {
|
|
4203
4796
|
break;
|
|
4204
4797
|
}
|
|
@@ -4207,7 +4800,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4207
4800
|
});
|
|
4208
4801
|
break;
|
|
4209
4802
|
}
|
|
4210
|
-
case
|
|
4803
|
+
case import_services15.Invitation.State.CANCELLED: {
|
|
4211
4804
|
if ((_l = (_k = hooks == null ? void 0 : hooks.host) == null ? void 0 : _k.onCancelled) == null ? void 0 : _l.call(_k, hostObservable)) {
|
|
4212
4805
|
break;
|
|
4213
4806
|
}
|
|
@@ -4216,7 +4809,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4216
4809
|
});
|
|
4217
4810
|
break;
|
|
4218
4811
|
}
|
|
4219
|
-
case
|
|
4812
|
+
case import_services15.Invitation.State.TIMEOUT: {
|
|
4220
4813
|
if ((_n = (_m = hooks == null ? void 0 : hooks.host) == null ? void 0 : _m.onTimeout) == null ? void 0 : _n.call(_m, hostObservable)) {
|
|
4221
4814
|
break;
|
|
4222
4815
|
}
|
|
@@ -4242,12 +4835,12 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4242
4835
|
};
|
|
4243
4836
|
var createInvitation = (host, options) => {
|
|
4244
4837
|
options != null ? options : options = {
|
|
4245
|
-
authMethod:
|
|
4838
|
+
authMethod: import_services15.Invitation.AuthMethod.NONE,
|
|
4246
4839
|
...options != null ? options : {}
|
|
4247
4840
|
};
|
|
4248
4841
|
if (host instanceof ServiceContext) {
|
|
4249
4842
|
const hostHandler = host.getInvitationHandler({
|
|
4250
|
-
kind:
|
|
4843
|
+
kind: import_services15.Invitation.Kind.SPACE,
|
|
4251
4844
|
...options
|
|
4252
4845
|
});
|
|
4253
4846
|
return host.invitations.createInvitation(hostHandler, options);
|
|
@@ -4267,7 +4860,7 @@ var acceptInvitation = (guest, invitation) => {
|
|
|
4267
4860
|
|
|
4268
4861
|
// packages/sdk/client-services/src/packlets/testing/test-builder.ts
|
|
4269
4862
|
var import_context8 = require("@dxos/context");
|
|
4270
|
-
var
|
|
4863
|
+
var import_credentials16 = require("@dxos/credentials");
|
|
4271
4864
|
var import_debug8 = require("@dxos/debug");
|
|
4272
4865
|
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
4273
4866
|
var import_testing = require("@dxos/echo-pipeline/testing");
|
|
@@ -4412,8 +5005,8 @@ var createSigningContext = async (keyring) => {
|
|
|
4412
5005
|
return {
|
|
4413
5006
|
identityKey,
|
|
4414
5007
|
deviceKey,
|
|
4415
|
-
credentialSigner: (0,
|
|
4416
|
-
credential: await new
|
|
5008
|
+
credentialSigner: (0, import_credentials16.createCredentialSignerWithChain)(keyring, {
|
|
5009
|
+
credential: await new import_credentials16.CredentialGenerator(keyring, identityKey, deviceKey).createDeviceAuthorization(deviceKey)
|
|
4417
5010
|
}, deviceKey),
|
|
4418
5011
|
recordCredential: async () => {
|
|
4419
5012
|
}
|