@dxos/client-services 0.1.55 → 0.1.56-main.01afb72
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-XSZIBW37.mjs → chunk-53BV3Q7V.mjs} +1131 -463
- package/dist/lib/browser/chunk-53BV3Q7V.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +63 -42
- 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 +13 -4
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +1279 -593
- 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 +1410 -736
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/packlets/identity/identity-manager.d.ts +2 -1
- 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 +3 -2
- 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/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/diagnostics.d.ts +46 -0
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -0
- package/dist/types/src/packlets/services/index.d.ts +1 -0
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/platform.d.ts +16 -0
- package/dist/types/src/packlets/services/platform.d.ts.map +1 -0
- package/dist/types/src/packlets/services/service-context.d.ts +2 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +7 -3
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts +6 -0
- package/dist/types/src/packlets/services/util.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.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/iframe-host-runtime.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-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +2 -0
- package/dist/types/src/version.d.ts.map +1 -0
- package/package.json +34 -33
- package/src/packlets/devices/devices-service.test.ts +2 -1
- package/src/packlets/identity/authenticator.test.ts +2 -2
- package/src/packlets/identity/identity-manager.test.ts +4 -3
- package/src/packlets/identity/identity-manager.ts +10 -7
- package/src/packlets/identity/identity-service.test.ts +2 -1
- package/src/packlets/identity/identity-service.ts +1 -2
- package/src/packlets/identity/identity.test.ts +7 -6
- package/src/packlets/identity/identity.ts +9 -5
- package/src/packlets/invitations/device-invitation-protocol.test.ts +2 -1
- 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/network/network-service.test.ts +2 -1
- package/src/packlets/services/client-rpc-server.ts +4 -4
- package/src/packlets/services/diagnostics.ts +211 -0
- package/src/packlets/services/index.ts +1 -0
- package/src/packlets/services/platform.ts +48 -0
- package/src/packlets/services/service-context.ts +14 -11
- package/src/packlets/services/service-host.test.ts +11 -10
- package/src/packlets/services/service-host.ts +38 -23
- package/src/packlets/services/service-registry.test.ts +3 -1
- package/src/packlets/services/util.ts +33 -0
- package/src/packlets/spaces/data-space-manager.ts +2 -3
- package/src/packlets/spaces/data-space.ts +1 -1
- package/src/packlets/spaces/notarization-plugin.ts +1 -2
- package/src/packlets/spaces/spaces-service.test.ts +2 -1
- package/src/packlets/spaces/spaces-service.ts +18 -12
- 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/testing/test-builder.ts +1 -1
- package/src/packlets/vault/iframe-host-runtime.ts +2 -1
- package/src/packlets/vault/shell-runtime.ts +1 -2
- package/src/packlets/vault/worker-runtime.ts +2 -1
- package/src/packlets/vault/worker-session.ts +7 -3
- package/src/version.ts +1 -0
- package/dist/lib/browser/chunk-XSZIBW37.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,205 @@ 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.01afb72";
|
|
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_context8 = require("@dxos/context");
|
|
232
|
+
var import_credentials15 = require("@dxos/credentials");
|
|
77
233
|
var import_debug7 = require("@dxos/debug");
|
|
78
234
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
79
235
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
236
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
80
237
|
var import_keyring = require("@dxos/keyring");
|
|
81
238
|
var import_keys8 = require("@dxos/keys");
|
|
82
|
-
var
|
|
83
|
-
var
|
|
84
|
-
var
|
|
239
|
+
var import_log13 = require("@dxos/log");
|
|
240
|
+
var import_protocols9 = require("@dxos/protocols");
|
|
241
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
85
242
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
243
|
+
var import_tracing3 = require("@dxos/tracing");
|
|
86
244
|
|
|
87
245
|
// packages/sdk/client-services/src/packlets/identity/authenticator.ts
|
|
88
246
|
var import_async = require("@dxos/async");
|
|
89
247
|
var import_context = require("@dxos/context");
|
|
90
|
-
var
|
|
91
|
-
var
|
|
92
|
-
var
|
|
93
|
-
var
|
|
94
|
-
var Credential =
|
|
248
|
+
var import_credentials3 = require("@dxos/credentials");
|
|
249
|
+
var import_log2 = require("@dxos/log");
|
|
250
|
+
var import_protocols2 = require("@dxos/protocols");
|
|
251
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
|
|
252
|
+
var Credential = import_protocols2.schema.getCodecForType("dxos.halo.credentials.Credential");
|
|
95
253
|
var createAuthProvider = (signer) => async (nonce) => {
|
|
96
254
|
const credential = await signer.createCredential({
|
|
97
255
|
assertion: {
|
|
@@ -114,20 +272,20 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
114
272
|
get verifier() {
|
|
115
273
|
return async (nonce, auth) => {
|
|
116
274
|
const credential = Credential.decode(auth);
|
|
117
|
-
(0,
|
|
275
|
+
(0, import_log2.log)("authenticating...", {
|
|
118
276
|
credential
|
|
119
277
|
}, {
|
|
120
|
-
F:
|
|
278
|
+
F: __dxlog_file2,
|
|
121
279
|
L: 59,
|
|
122
280
|
S: this,
|
|
123
281
|
C: (f, a) => f(...a)
|
|
124
282
|
});
|
|
125
|
-
const result = await (0,
|
|
283
|
+
const result = await (0, import_credentials3.verifyCredential)(credential);
|
|
126
284
|
if (result.kind === "fail") {
|
|
127
|
-
(0,
|
|
285
|
+
(0, import_log2.log)("Invalid credential", {
|
|
128
286
|
result
|
|
129
287
|
}, {
|
|
130
|
-
F:
|
|
288
|
+
F: __dxlog_file2,
|
|
131
289
|
L: 63,
|
|
132
290
|
S: this,
|
|
133
291
|
C: (f, a) => f(...a)
|
|
@@ -135,11 +293,11 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
135
293
|
return false;
|
|
136
294
|
}
|
|
137
295
|
if (!credential.proof.nonce || !Buffer.from(nonce).equals(credential.proof.nonce)) {
|
|
138
|
-
(0,
|
|
296
|
+
(0, import_log2.log)("Invalid nonce", {
|
|
139
297
|
nonce,
|
|
140
298
|
credential
|
|
141
299
|
}, {
|
|
142
|
-
F:
|
|
300
|
+
F: __dxlog_file2,
|
|
143
301
|
L: 68,
|
|
144
302
|
S: this,
|
|
145
303
|
C: (f, a) => f(...a)
|
|
@@ -147,10 +305,10 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
147
305
|
return false;
|
|
148
306
|
}
|
|
149
307
|
if (this._isTrustedKey(credential.issuer)) {
|
|
150
|
-
(0,
|
|
308
|
+
(0, import_log2.log)("key is not currently in trusted set, waiting...", {
|
|
151
309
|
key: credential.issuer
|
|
152
310
|
}, {
|
|
153
|
-
F:
|
|
311
|
+
F: __dxlog_file2,
|
|
154
312
|
L: 73,
|
|
155
313
|
S: this,
|
|
156
314
|
C: (f, a) => f(...a)
|
|
@@ -163,20 +321,20 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
163
321
|
});
|
|
164
322
|
const clear = this._params.update.on(this._ctx, () => {
|
|
165
323
|
if (this._isTrustedKey(credential.issuer)) {
|
|
166
|
-
(0,
|
|
324
|
+
(0, import_log2.log)("auth success", {
|
|
167
325
|
key: credential.issuer
|
|
168
326
|
}, {
|
|
169
|
-
F:
|
|
327
|
+
F: __dxlog_file2,
|
|
170
328
|
L: 84,
|
|
171
329
|
S: this,
|
|
172
330
|
C: (f, a) => f(...a)
|
|
173
331
|
});
|
|
174
332
|
trigger.wake(true);
|
|
175
333
|
} else {
|
|
176
|
-
(0,
|
|
334
|
+
(0, import_log2.log)("key is not currently in trusted set, waiting...", {
|
|
177
335
|
key: credential.issuer
|
|
178
336
|
}, {
|
|
179
|
-
F:
|
|
337
|
+
F: __dxlog_file2,
|
|
180
338
|
L: 87,
|
|
181
339
|
S: this,
|
|
182
340
|
C: (f, a) => f(...a)
|
|
@@ -201,28 +359,39 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
201
359
|
};
|
|
202
360
|
|
|
203
361
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
204
|
-
var import_tiny_invariant = __toESM(require("tiny-invariant"));
|
|
205
362
|
var import_async2 = require("@dxos/async");
|
|
206
363
|
var import_client_protocol = require("@dxos/client-protocol");
|
|
207
|
-
var
|
|
364
|
+
var import_credentials4 = require("@dxos/credentials");
|
|
208
365
|
var import_debug2 = require("@dxos/debug");
|
|
209
366
|
var import_feed_store = require("@dxos/feed-store");
|
|
210
|
-
var
|
|
211
|
-
var
|
|
212
|
-
var
|
|
213
|
-
var
|
|
367
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
368
|
+
var import_log3 = require("@dxos/log");
|
|
369
|
+
var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
370
|
+
var import_tracing = require("@dxos/tracing");
|
|
371
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
372
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
373
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
374
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
375
|
+
else
|
|
376
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
377
|
+
if (d = decorators[i])
|
|
378
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
379
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
380
|
+
}
|
|
381
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
382
|
+
var Identity = class Identity2 {
|
|
214
383
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
215
384
|
this.stateUpdate = new import_async2.Event();
|
|
216
385
|
this.space = space;
|
|
217
386
|
this._signer = signer;
|
|
218
387
|
this.identityKey = identityKey;
|
|
219
388
|
this.deviceKey = deviceKey;
|
|
220
|
-
this._deviceStateMachine = new
|
|
389
|
+
this._deviceStateMachine = new import_credentials4.DeviceStateMachine({
|
|
221
390
|
identityKey: this.identityKey,
|
|
222
391
|
deviceKey: this.deviceKey,
|
|
223
392
|
onUpdate: () => this.stateUpdate.emit()
|
|
224
393
|
});
|
|
225
|
-
this._profileStateMachine = new
|
|
394
|
+
this._profileStateMachine = new import_credentials4.ProfileStateMachine({
|
|
226
395
|
identityKey: this.identityKey,
|
|
227
396
|
onUpdate: () => this.stateUpdate.emit()
|
|
228
397
|
});
|
|
@@ -236,12 +405,12 @@ var Identity = class {
|
|
|
236
405
|
get authorizedDeviceKeys() {
|
|
237
406
|
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
238
407
|
}
|
|
239
|
-
async open() {
|
|
408
|
+
async open(ctx) {
|
|
240
409
|
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
241
410
|
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
242
|
-
await this.space.open();
|
|
411
|
+
await this.space.open(ctx);
|
|
243
412
|
}
|
|
244
|
-
async close() {
|
|
413
|
+
async close(ctx) {
|
|
245
414
|
await this.authVerifier.close();
|
|
246
415
|
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
247
416
|
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
@@ -284,25 +453,33 @@ var Identity = class {
|
|
|
284
453
|
* Requires identity to be ready.
|
|
285
454
|
*/
|
|
286
455
|
getIdentityCredentialSigner() {
|
|
287
|
-
(0,
|
|
288
|
-
|
|
456
|
+
(0, import_invariant2.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
457
|
+
F: __dxlog_file3,
|
|
458
|
+
L: 139,
|
|
459
|
+
S: this,
|
|
460
|
+
A: [
|
|
461
|
+
"this._deviceStateMachine.deviceCredentialChain",
|
|
462
|
+
"'Device credential chain is not ready.'"
|
|
463
|
+
]
|
|
464
|
+
});
|
|
465
|
+
return (0, import_credentials4.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
|
|
289
466
|
}
|
|
290
467
|
/**
|
|
291
468
|
* Issues credentials as device.
|
|
292
469
|
*/
|
|
293
470
|
getDeviceCredentialSigner() {
|
|
294
|
-
return (0,
|
|
471
|
+
return (0, import_credentials4.createCredentialSignerWithKey)(this._signer, this.deviceKey);
|
|
295
472
|
}
|
|
296
473
|
async admitDevice({ deviceKey, controlFeedKey, dataFeedKey }) {
|
|
297
|
-
(0,
|
|
474
|
+
(0, import_log3.log)("Admitting device:", {
|
|
298
475
|
identityKey: this.identityKey,
|
|
299
476
|
hostDevice: this.deviceKey,
|
|
300
477
|
deviceKey,
|
|
301
478
|
controlFeedKey,
|
|
302
479
|
dataFeedKey
|
|
303
480
|
}, {
|
|
304
|
-
F:
|
|
305
|
-
L:
|
|
481
|
+
F: __dxlog_file3,
|
|
482
|
+
L: 155,
|
|
306
483
|
S: this,
|
|
307
484
|
C: (f, a) => f(...a)
|
|
308
485
|
});
|
|
@@ -323,7 +500,7 @@ var Identity = class {
|
|
|
323
500
|
spaceKey: this.haloSpaceKey,
|
|
324
501
|
deviceKey,
|
|
325
502
|
identityKey: this.identityKey,
|
|
326
|
-
designation:
|
|
503
|
+
designation: import_credentials5.AdmittedFeed.Designation.CONTROL
|
|
327
504
|
}
|
|
328
505
|
}),
|
|
329
506
|
await signer.createCredential({
|
|
@@ -333,7 +510,7 @@ var Identity = class {
|
|
|
333
510
|
spaceKey: this.haloSpaceKey,
|
|
334
511
|
deviceKey,
|
|
335
512
|
identityKey: this.identityKey,
|
|
336
|
-
designation:
|
|
513
|
+
designation: import_credentials5.AdmittedFeed.Designation.DATA
|
|
337
514
|
}
|
|
338
515
|
})
|
|
339
516
|
].map((credential) => ({
|
|
@@ -343,18 +520,39 @@ var Identity = class {
|
|
|
343
520
|
})));
|
|
344
521
|
}
|
|
345
522
|
};
|
|
523
|
+
_ts_decorate([
|
|
524
|
+
import_tracing.trace.span()
|
|
525
|
+
], Identity.prototype, "open", null);
|
|
526
|
+
_ts_decorate([
|
|
527
|
+
import_tracing.trace.span()
|
|
528
|
+
], Identity.prototype, "close", null);
|
|
529
|
+
Identity = _ts_decorate([
|
|
530
|
+
import_tracing.trace.resource()
|
|
531
|
+
], Identity);
|
|
346
532
|
|
|
347
533
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
348
|
-
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
349
534
|
var import_async3 = require("@dxos/async");
|
|
350
|
-
var
|
|
535
|
+
var import_context2 = require("@dxos/context");
|
|
536
|
+
var import_credentials6 = require("@dxos/credentials");
|
|
537
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
351
538
|
var import_keys2 = require("@dxos/keys");
|
|
352
|
-
var
|
|
353
|
-
var
|
|
354
|
-
var
|
|
539
|
+
var import_log4 = require("@dxos/log");
|
|
540
|
+
var import_protocols3 = require("@dxos/protocols");
|
|
541
|
+
var import_credentials7 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
542
|
+
var import_tracing2 = require("@dxos/tracing");
|
|
355
543
|
var import_util = require("@dxos/util");
|
|
356
|
-
|
|
357
|
-
var
|
|
544
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
545
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
546
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
547
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
548
|
+
else
|
|
549
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
550
|
+
if (d = decorators[i])
|
|
551
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
552
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
553
|
+
}
|
|
554
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
555
|
+
var IdentityManager = class IdentityManager2 {
|
|
358
556
|
// TODO(burdon): IdentityManagerParams.
|
|
359
557
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
360
558
|
constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
|
|
@@ -367,61 +565,69 @@ var IdentityManager = class {
|
|
|
367
565
|
get identity() {
|
|
368
566
|
return this._identity;
|
|
369
567
|
}
|
|
370
|
-
async open() {
|
|
568
|
+
async open(ctx) {
|
|
371
569
|
var _a;
|
|
372
570
|
const traceId = import_keys2.PublicKey.random().toHex();
|
|
373
|
-
|
|
571
|
+
import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.begin({
|
|
374
572
|
id: traceId
|
|
375
573
|
}), {
|
|
376
|
-
F:
|
|
377
|
-
L:
|
|
574
|
+
F: __dxlog_file4,
|
|
575
|
+
L: 73,
|
|
378
576
|
S: this,
|
|
379
577
|
C: (f, a) => f(...a)
|
|
380
578
|
});
|
|
381
579
|
await this._metadataStore.load();
|
|
382
580
|
const identityRecord = this._metadataStore.getIdentityRecord();
|
|
383
|
-
(0,
|
|
581
|
+
(0, import_log4.log)("identity record", {
|
|
384
582
|
identityRecord
|
|
385
583
|
}, {
|
|
386
|
-
F:
|
|
387
|
-
L:
|
|
584
|
+
F: __dxlog_file4,
|
|
585
|
+
L: 77,
|
|
388
586
|
S: this,
|
|
389
587
|
C: (f, a) => f(...a)
|
|
390
588
|
});
|
|
391
589
|
if (identityRecord) {
|
|
392
590
|
this._identity = await this._constructIdentity(identityRecord);
|
|
393
|
-
await this._identity.open();
|
|
591
|
+
await this._identity.open(ctx);
|
|
394
592
|
await this._identity.ready();
|
|
395
|
-
|
|
593
|
+
import_log4.log.trace("dxos.halo.identity", {
|
|
396
594
|
identityKey: identityRecord.identityKey,
|
|
397
595
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
398
596
|
}, {
|
|
399
|
-
F:
|
|
400
|
-
L:
|
|
597
|
+
F: __dxlog_file4,
|
|
598
|
+
L: 82,
|
|
401
599
|
S: this,
|
|
402
600
|
C: (f, a) => f(...a)
|
|
403
601
|
});
|
|
404
602
|
this.stateUpdate.emit();
|
|
405
603
|
}
|
|
406
|
-
|
|
604
|
+
import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.end({
|
|
407
605
|
id: traceId
|
|
408
606
|
}), {
|
|
409
|
-
F:
|
|
410
|
-
L:
|
|
607
|
+
F: __dxlog_file4,
|
|
608
|
+
L: 88,
|
|
411
609
|
S: this,
|
|
412
610
|
C: (f, a) => f(...a)
|
|
413
611
|
});
|
|
414
612
|
}
|
|
415
613
|
async close() {
|
|
416
614
|
var _a;
|
|
417
|
-
await ((_a = this._identity) == null ? void 0 : _a.close());
|
|
615
|
+
await ((_a = this._identity) == null ? void 0 : _a.close(new import_context2.Context()));
|
|
418
616
|
}
|
|
419
617
|
async createIdentity({ displayName } = {}) {
|
|
420
618
|
var _a;
|
|
421
|
-
(0,
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
619
|
+
(0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
|
|
620
|
+
F: __dxlog_file4,
|
|
621
|
+
L: 96,
|
|
622
|
+
S: this,
|
|
623
|
+
A: [
|
|
624
|
+
"!this._identity",
|
|
625
|
+
"'Identity already exists.'"
|
|
626
|
+
]
|
|
627
|
+
});
|
|
628
|
+
(0, import_log4.log)("creating identity...", void 0, {
|
|
629
|
+
F: __dxlog_file4,
|
|
630
|
+
L: 97,
|
|
425
631
|
S: this,
|
|
426
632
|
C: (f, a) => f(...a)
|
|
427
633
|
});
|
|
@@ -437,16 +643,32 @@ var IdentityManager = class {
|
|
|
437
643
|
}
|
|
438
644
|
};
|
|
439
645
|
const identity = await this._constructIdentity(identityRecord);
|
|
440
|
-
await identity.open();
|
|
646
|
+
await identity.open(new import_context2.Context());
|
|
441
647
|
{
|
|
442
|
-
const generator = new
|
|
443
|
-
(0,
|
|
444
|
-
|
|
648
|
+
const generator = new import_credentials6.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
649
|
+
(0, import_invariant3.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
|
|
650
|
+
F: __dxlog_file4,
|
|
651
|
+
L: 116,
|
|
652
|
+
S: this,
|
|
653
|
+
A: [
|
|
654
|
+
"identityRecord.haloSpace.genesisFeedKey",
|
|
655
|
+
"'Genesis feed key is required.'"
|
|
656
|
+
]
|
|
657
|
+
});
|
|
658
|
+
(0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
|
|
659
|
+
F: __dxlog_file4,
|
|
660
|
+
L: 117,
|
|
661
|
+
S: this,
|
|
662
|
+
A: [
|
|
663
|
+
"identityRecord.haloSpace.dataFeedKey",
|
|
664
|
+
"'Data feed key is required.'"
|
|
665
|
+
]
|
|
666
|
+
});
|
|
445
667
|
const credentials = [
|
|
446
668
|
// Space genesis.
|
|
447
669
|
...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
|
|
448
670
|
// Feed admission.
|
|
449
|
-
await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey,
|
|
671
|
+
await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, import_credentials7.AdmittedFeed.Designation.DATA)
|
|
450
672
|
];
|
|
451
673
|
if (displayName) {
|
|
452
674
|
credentials.push(await generator.createProfileCredential({
|
|
@@ -465,22 +687,22 @@ var IdentityManager = class {
|
|
|
465
687
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
466
688
|
this._identity = identity;
|
|
467
689
|
await this._identity.ready();
|
|
468
|
-
|
|
690
|
+
import_log4.log.trace("dxos.halo.identity", {
|
|
469
691
|
identityKey: identityRecord.identityKey,
|
|
470
692
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
471
693
|
}, {
|
|
472
|
-
F:
|
|
473
|
-
L:
|
|
694
|
+
F: __dxlog_file4,
|
|
695
|
+
L: 152,
|
|
474
696
|
S: this,
|
|
475
697
|
C: (f, a) => f(...a)
|
|
476
698
|
});
|
|
477
699
|
this.stateUpdate.emit();
|
|
478
|
-
(0,
|
|
700
|
+
(0, import_log4.log)("created identity", {
|
|
479
701
|
identityKey: identity.identityKey,
|
|
480
702
|
deviceKey: identity.deviceKey
|
|
481
703
|
}, {
|
|
482
|
-
F:
|
|
483
|
-
L:
|
|
704
|
+
F: __dxlog_file4,
|
|
705
|
+
L: 158,
|
|
484
706
|
S: this,
|
|
485
707
|
C: (f, a) => f(...a)
|
|
486
708
|
});
|
|
@@ -491,15 +713,23 @@ var IdentityManager = class {
|
|
|
491
713
|
*/
|
|
492
714
|
async acceptIdentity(params) {
|
|
493
715
|
var _a;
|
|
494
|
-
(0,
|
|
716
|
+
(0, import_log4.log)("accepting identity", {
|
|
495
717
|
params
|
|
496
718
|
}, {
|
|
497
|
-
F:
|
|
498
|
-
L:
|
|
719
|
+
F: __dxlog_file4,
|
|
720
|
+
L: 166,
|
|
499
721
|
S: this,
|
|
500
722
|
C: (f, a) => f(...a)
|
|
501
723
|
});
|
|
502
|
-
(0,
|
|
724
|
+
(0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
|
|
725
|
+
F: __dxlog_file4,
|
|
726
|
+
L: 167,
|
|
727
|
+
S: this,
|
|
728
|
+
A: [
|
|
729
|
+
"!this._identity",
|
|
730
|
+
"'Identity already exists.'"
|
|
731
|
+
]
|
|
732
|
+
});
|
|
503
733
|
const identityRecord = {
|
|
504
734
|
identityKey: params.identityKey,
|
|
505
735
|
deviceKey: params.deviceKey,
|
|
@@ -512,46 +742,70 @@ var IdentityManager = class {
|
|
|
512
742
|
}
|
|
513
743
|
};
|
|
514
744
|
const identity = await this._constructIdentity(identityRecord);
|
|
515
|
-
await identity.open();
|
|
745
|
+
await identity.open(new import_context2.Context());
|
|
516
746
|
this._identity = identity;
|
|
517
747
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
518
748
|
await this._identity.ready();
|
|
519
|
-
|
|
749
|
+
import_log4.log.trace("dxos.halo.identity", {
|
|
520
750
|
identityKey: identityRecord.identityKey,
|
|
521
751
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
522
752
|
}, {
|
|
523
|
-
F:
|
|
524
|
-
L:
|
|
753
|
+
F: __dxlog_file4,
|
|
754
|
+
L: 186,
|
|
525
755
|
S: this,
|
|
526
756
|
C: (f, a) => f(...a)
|
|
527
757
|
});
|
|
528
758
|
this.stateUpdate.emit();
|
|
529
|
-
(0,
|
|
759
|
+
(0, import_log4.log)("accepted identity", {
|
|
530
760
|
identityKey: identity.identityKey,
|
|
531
761
|
deviceKey: identity.deviceKey
|
|
532
762
|
}, {
|
|
533
|
-
F:
|
|
534
|
-
L:
|
|
763
|
+
F: __dxlog_file4,
|
|
764
|
+
L: 192,
|
|
535
765
|
S: this,
|
|
536
766
|
C: (f, a) => f(...a)
|
|
537
767
|
});
|
|
538
768
|
return identity;
|
|
539
769
|
}
|
|
540
770
|
async _constructIdentity(identityRecord) {
|
|
541
|
-
(0,
|
|
542
|
-
|
|
771
|
+
(0, import_invariant3.invariant)(!this._identity, void 0, {
|
|
772
|
+
F: __dxlog_file4,
|
|
773
|
+
L: 197,
|
|
774
|
+
S: this,
|
|
775
|
+
A: [
|
|
776
|
+
"!this._identity",
|
|
777
|
+
""
|
|
778
|
+
]
|
|
779
|
+
});
|
|
780
|
+
(0, import_log4.log)("constructing identity", {
|
|
543
781
|
identityRecord
|
|
544
782
|
}, {
|
|
545
|
-
F:
|
|
546
|
-
L:
|
|
783
|
+
F: __dxlog_file4,
|
|
784
|
+
L: 198,
|
|
547
785
|
S: this,
|
|
548
786
|
C: (f, a) => f(...a)
|
|
549
787
|
});
|
|
550
|
-
(0,
|
|
788
|
+
(0, import_invariant3.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
789
|
+
F: __dxlog_file4,
|
|
790
|
+
L: 201,
|
|
791
|
+
S: this,
|
|
792
|
+
A: [
|
|
793
|
+
"identityRecord.haloSpace.controlFeedKey",
|
|
794
|
+
""
|
|
795
|
+
]
|
|
796
|
+
});
|
|
551
797
|
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
|
|
552
798
|
writable: true
|
|
553
799
|
});
|
|
554
|
-
(0,
|
|
800
|
+
(0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
801
|
+
F: __dxlog_file4,
|
|
802
|
+
L: 205,
|
|
803
|
+
S: this,
|
|
804
|
+
A: [
|
|
805
|
+
"identityRecord.haloSpace.dataFeedKey",
|
|
806
|
+
""
|
|
807
|
+
]
|
|
808
|
+
});
|
|
555
809
|
const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
|
|
556
810
|
writable: true,
|
|
557
811
|
sparse: true
|
|
@@ -560,7 +814,7 @@ var IdentityManager = class {
|
|
|
560
814
|
spaceRecord: identityRecord.haloSpace,
|
|
561
815
|
swarmIdentity: {
|
|
562
816
|
peerKey: identityRecord.deviceKey,
|
|
563
|
-
credentialProvider: createAuthProvider((0,
|
|
817
|
+
credentialProvider: createAuthProvider((0, import_credentials6.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
|
|
564
818
|
credentialAuthenticator: (0, import_util.deferFunction)(() => identity.authVerifier.verifier)
|
|
565
819
|
},
|
|
566
820
|
identityKey: identityRecord.identityKey
|
|
@@ -573,11 +827,11 @@ var IdentityManager = class {
|
|
|
573
827
|
identityKey: identityRecord.identityKey,
|
|
574
828
|
deviceKey: identityRecord.deviceKey
|
|
575
829
|
});
|
|
576
|
-
(0,
|
|
830
|
+
(0, import_log4.log)("done", {
|
|
577
831
|
identityKey: identityRecord.identityKey
|
|
578
832
|
}, {
|
|
579
|
-
F:
|
|
580
|
-
L:
|
|
833
|
+
F: __dxlog_file4,
|
|
834
|
+
L: 229,
|
|
581
835
|
S: this,
|
|
582
836
|
C: (f, a) => f(...a)
|
|
583
837
|
});
|
|
@@ -596,9 +850,9 @@ var IdentityManager = class {
|
|
|
596
850
|
onNetworkConnection: () => {
|
|
597
851
|
},
|
|
598
852
|
onAuthFailure: () => {
|
|
599
|
-
|
|
600
|
-
F:
|
|
601
|
-
L:
|
|
853
|
+
import_log4.log.warn("auth failure", void 0, {
|
|
854
|
+
F: __dxlog_file4,
|
|
855
|
+
L: 248,
|
|
602
856
|
S: this,
|
|
603
857
|
C: (f, a) => f(...a)
|
|
604
858
|
});
|
|
@@ -607,12 +861,19 @@ var IdentityManager = class {
|
|
|
607
861
|
});
|
|
608
862
|
}
|
|
609
863
|
};
|
|
864
|
+
_ts_decorate2([
|
|
865
|
+
import_tracing2.trace.span()
|
|
866
|
+
], IdentityManager.prototype, "open", null);
|
|
867
|
+
IdentityManager = _ts_decorate2([
|
|
868
|
+
import_tracing2.trace.resource()
|
|
869
|
+
], IdentityManager);
|
|
610
870
|
|
|
611
871
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
612
|
-
var
|
|
613
|
-
var
|
|
614
|
-
var import_credentials7 = require("@dxos/credentials");
|
|
872
|
+
var import_codec_protobuf3 = require("@dxos/codec-protobuf");
|
|
873
|
+
var import_credentials8 = require("@dxos/credentials");
|
|
615
874
|
var import_debug3 = require("@dxos/debug");
|
|
875
|
+
var import_invariant4 = require("@dxos/invariant");
|
|
876
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
616
877
|
var IdentityServiceImpl = class {
|
|
617
878
|
// TODO(wittjosiah): Remove dependency on service context.
|
|
618
879
|
constructor(_serviceContext) {
|
|
@@ -626,7 +887,7 @@ var IdentityServiceImpl = class {
|
|
|
626
887
|
return (0, import_debug3.todo)();
|
|
627
888
|
}
|
|
628
889
|
queryIdentity() {
|
|
629
|
-
return new
|
|
890
|
+
return new import_codec_protobuf3.Stream(({ next }) => {
|
|
630
891
|
const emitNext = () => next({
|
|
631
892
|
identity: this._getIdentity()
|
|
632
893
|
});
|
|
@@ -645,8 +906,16 @@ var IdentityServiceImpl = class {
|
|
|
645
906
|
};
|
|
646
907
|
}
|
|
647
908
|
async signPresentation({ presentation, nonce }) {
|
|
648
|
-
(0,
|
|
649
|
-
|
|
909
|
+
(0, import_invariant4.invariant)(this._serviceContext.identityManager.identity, "Identity not initialized.", {
|
|
910
|
+
F: __dxlog_file5,
|
|
911
|
+
L: 56,
|
|
912
|
+
S: this,
|
|
913
|
+
A: [
|
|
914
|
+
"this._serviceContext.identityManager.identity",
|
|
915
|
+
"'Identity not initialized.'"
|
|
916
|
+
]
|
|
917
|
+
});
|
|
918
|
+
return await (0, import_credentials8.signPresentation)({
|
|
650
919
|
presentation,
|
|
651
920
|
signer: this._serviceContext.keyring,
|
|
652
921
|
signerKey: this._serviceContext.identityManager.identity.deviceKey,
|
|
@@ -657,8 +926,9 @@ var IdentityServiceImpl = class {
|
|
|
657
926
|
};
|
|
658
927
|
|
|
659
928
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
660
|
-
var
|
|
661
|
-
var
|
|
929
|
+
var import_invariant5 = require("@dxos/invariant");
|
|
930
|
+
var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
931
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
|
|
662
932
|
var DeviceInvitationProtocol = class {
|
|
663
933
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
664
934
|
this._keyring = _keyring;
|
|
@@ -670,11 +940,19 @@ var DeviceInvitationProtocol = class {
|
|
|
670
940
|
}
|
|
671
941
|
getInvitationContext() {
|
|
672
942
|
return {
|
|
673
|
-
kind:
|
|
943
|
+
kind: import_services2.Invitation.Kind.DEVICE
|
|
674
944
|
};
|
|
675
945
|
}
|
|
676
946
|
async admit(request) {
|
|
677
|
-
(0,
|
|
947
|
+
(0, import_invariant5.invariant)(request.device, void 0, {
|
|
948
|
+
F: __dxlog_file6,
|
|
949
|
+
L: 31,
|
|
950
|
+
S: this,
|
|
951
|
+
A: [
|
|
952
|
+
"request.device",
|
|
953
|
+
""
|
|
954
|
+
]
|
|
955
|
+
});
|
|
678
956
|
const identity = this._getIdentity();
|
|
679
957
|
await identity.admitDevice(request.device);
|
|
680
958
|
return {
|
|
@@ -702,9 +980,25 @@ var DeviceInvitationProtocol = class {
|
|
|
702
980
|
};
|
|
703
981
|
}
|
|
704
982
|
async accept(response, request) {
|
|
705
|
-
(0,
|
|
983
|
+
(0, import_invariant5.invariant)(response.device, void 0, {
|
|
984
|
+
F: __dxlog_file6,
|
|
985
|
+
L: 64,
|
|
986
|
+
S: this,
|
|
987
|
+
A: [
|
|
988
|
+
"response.device",
|
|
989
|
+
""
|
|
990
|
+
]
|
|
991
|
+
});
|
|
706
992
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
707
|
-
(0,
|
|
993
|
+
(0, import_invariant5.invariant)(request.device, void 0, {
|
|
994
|
+
F: __dxlog_file6,
|
|
995
|
+
L: 67,
|
|
996
|
+
S: this,
|
|
997
|
+
A: [
|
|
998
|
+
"request.device",
|
|
999
|
+
""
|
|
1000
|
+
]
|
|
1001
|
+
});
|
|
708
1002
|
const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
|
|
709
1003
|
await this._acceptIdentity({
|
|
710
1004
|
identityKey,
|
|
@@ -722,45 +1016,45 @@ var DeviceInvitationProtocol = class {
|
|
|
722
1016
|
};
|
|
723
1017
|
|
|
724
1018
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
725
|
-
var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
|
|
726
1019
|
var import_async5 = require("@dxos/async");
|
|
727
1020
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
728
|
-
var
|
|
729
|
-
var
|
|
1021
|
+
var import_context4 = require("@dxos/context");
|
|
1022
|
+
var import_credentials9 = require("@dxos/credentials");
|
|
730
1023
|
var import_errors2 = require("@dxos/errors");
|
|
1024
|
+
var import_invariant7 = require("@dxos/invariant");
|
|
731
1025
|
var import_keys4 = require("@dxos/keys");
|
|
732
|
-
var
|
|
1026
|
+
var import_log6 = require("@dxos/log");
|
|
733
1027
|
var import_network_manager = require("@dxos/network-manager");
|
|
734
|
-
var
|
|
735
|
-
var
|
|
1028
|
+
var import_protocols5 = require("@dxos/protocols");
|
|
1029
|
+
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
736
1030
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
737
1031
|
|
|
738
1032
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
739
|
-
var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
|
|
740
1033
|
var import_async4 = require("@dxos/async");
|
|
741
|
-
var
|
|
1034
|
+
var import_context3 = require("@dxos/context");
|
|
742
1035
|
var import_errors = require("@dxos/errors");
|
|
1036
|
+
var import_invariant6 = require("@dxos/invariant");
|
|
743
1037
|
var import_keys3 = require("@dxos/keys");
|
|
744
|
-
var
|
|
745
|
-
var
|
|
746
|
-
var
|
|
1038
|
+
var import_log5 = require("@dxos/log");
|
|
1039
|
+
var import_protocols4 = require("@dxos/protocols");
|
|
1040
|
+
var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
747
1041
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
748
1042
|
var import_teleport = require("@dxos/teleport");
|
|
749
|
-
var
|
|
1043
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
|
|
750
1044
|
var OPTIONS_TIMEOUT = 1e4;
|
|
751
1045
|
var MAX_OTP_ATTEMPTS = 3;
|
|
752
1046
|
var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
753
1047
|
constructor(_callbacks) {
|
|
754
1048
|
super({
|
|
755
1049
|
requested: {
|
|
756
|
-
InvitationHostService:
|
|
1050
|
+
InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
757
1051
|
},
|
|
758
1052
|
exposed: {
|
|
759
|
-
InvitationHostService:
|
|
1053
|
+
InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
760
1054
|
}
|
|
761
1055
|
});
|
|
762
1056
|
this._callbacks = _callbacks;
|
|
763
|
-
this._ctx = new
|
|
1057
|
+
this._ctx = new import_context3.Context();
|
|
764
1058
|
this._remoteOptionsTrigger = new import_async4.Trigger();
|
|
765
1059
|
this.invitation = void 0;
|
|
766
1060
|
this.guestProfile = void 0;
|
|
@@ -774,88 +1068,104 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
774
1068
|
// Perhaps in the future we will have more complex logic here.
|
|
775
1069
|
InvitationHostService: {
|
|
776
1070
|
options: async (options) => {
|
|
777
|
-
(0,
|
|
1071
|
+
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1072
|
+
F: __dxlog_file7,
|
|
1073
|
+
L: 88,
|
|
1074
|
+
S: this,
|
|
1075
|
+
A: [
|
|
1076
|
+
"!this._remoteOptions",
|
|
1077
|
+
"'Remote options already set.'"
|
|
1078
|
+
]
|
|
1079
|
+
});
|
|
778
1080
|
this._remoteOptions = options;
|
|
779
1081
|
this._remoteOptionsTrigger.wake();
|
|
780
1082
|
},
|
|
781
1083
|
introduce: async (request) => {
|
|
782
1084
|
const { profile, invitationId } = request;
|
|
783
1085
|
const traceId = import_keys3.PublicKey.random().toHex();
|
|
784
|
-
|
|
1086
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols4.trace.begin({
|
|
785
1087
|
id: traceId
|
|
786
1088
|
}), {
|
|
787
|
-
F:
|
|
788
|
-
L:
|
|
1089
|
+
F: __dxlog_file7,
|
|
1090
|
+
L: 97,
|
|
789
1091
|
S: this,
|
|
790
1092
|
C: (f, a) => f(...a)
|
|
791
1093
|
});
|
|
792
1094
|
const invitation = await this._callbacks.resolveInvitation(request);
|
|
793
1095
|
if (!invitation) {
|
|
794
|
-
|
|
1096
|
+
import_log5.log.warn("invitation not found", {
|
|
795
1097
|
invitationId
|
|
796
1098
|
}, {
|
|
797
|
-
F:
|
|
798
|
-
L:
|
|
1099
|
+
F: __dxlog_file7,
|
|
1100
|
+
L: 101,
|
|
799
1101
|
S: this,
|
|
800
1102
|
C: (f, a) => f(...a)
|
|
801
1103
|
});
|
|
802
1104
|
this._callbacks.onError(new Error("Invitation not found."));
|
|
803
1105
|
return {
|
|
804
|
-
authMethod:
|
|
1106
|
+
authMethod: import_services3.Invitation.AuthMethod.NONE
|
|
805
1107
|
};
|
|
806
1108
|
}
|
|
807
1109
|
this.invitation = invitation;
|
|
808
|
-
(0,
|
|
1110
|
+
(0, import_log5.log)("guest introduced itself", {
|
|
809
1111
|
guestProfile: profile
|
|
810
1112
|
}, {
|
|
811
|
-
F:
|
|
812
|
-
L:
|
|
1113
|
+
F: __dxlog_file7,
|
|
1114
|
+
L: 110,
|
|
813
1115
|
S: this,
|
|
814
1116
|
C: (f, a) => f(...a)
|
|
815
1117
|
});
|
|
816
1118
|
this.guestProfile = profile;
|
|
817
1119
|
this._callbacks.onStateUpdate({
|
|
818
1120
|
...this.invitation,
|
|
819
|
-
state:
|
|
1121
|
+
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
820
1122
|
});
|
|
821
|
-
|
|
1123
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols4.trace.end({
|
|
822
1124
|
id: traceId
|
|
823
1125
|
}), {
|
|
824
|
-
F:
|
|
825
|
-
L:
|
|
1126
|
+
F: __dxlog_file7,
|
|
1127
|
+
L: 117,
|
|
826
1128
|
S: this,
|
|
827
1129
|
C: (f, a) => f(...a)
|
|
828
1130
|
});
|
|
829
1131
|
return {
|
|
830
|
-
spaceKey: this.invitation.authMethod ===
|
|
1132
|
+
spaceKey: this.invitation.authMethod === import_services3.Invitation.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
|
|
831
1133
|
authMethod: this.invitation.authMethod
|
|
832
1134
|
};
|
|
833
1135
|
},
|
|
834
1136
|
authenticate: async ({ authCode: code }) => {
|
|
835
1137
|
const traceId = import_keys3.PublicKey.random().toHex();
|
|
836
|
-
|
|
1138
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols4.trace.begin({
|
|
837
1139
|
id: traceId
|
|
838
1140
|
}), {
|
|
839
|
-
F:
|
|
840
|
-
L:
|
|
1141
|
+
F: __dxlog_file7,
|
|
1142
|
+
L: 126,
|
|
841
1143
|
S: this,
|
|
842
1144
|
C: (f, a) => f(...a)
|
|
843
1145
|
});
|
|
844
|
-
(0,
|
|
1146
|
+
(0, import_log5.log)("received authentication request", {
|
|
845
1147
|
authCode: code
|
|
846
1148
|
}, {
|
|
847
|
-
F:
|
|
848
|
-
L:
|
|
1149
|
+
F: __dxlog_file7,
|
|
1150
|
+
L: 127,
|
|
849
1151
|
S: this,
|
|
850
1152
|
C: (f, a) => f(...a)
|
|
851
1153
|
});
|
|
852
1154
|
let status = import_invitations.AuthenticationResponse.Status.OK;
|
|
853
|
-
(0,
|
|
1155
|
+
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1156
|
+
F: __dxlog_file7,
|
|
1157
|
+
L: 130,
|
|
1158
|
+
S: this,
|
|
1159
|
+
A: [
|
|
1160
|
+
"this.invitation",
|
|
1161
|
+
"'Invitation is not set.'"
|
|
1162
|
+
]
|
|
1163
|
+
});
|
|
854
1164
|
switch (this.invitation.authMethod) {
|
|
855
|
-
case
|
|
856
|
-
(0,
|
|
857
|
-
F:
|
|
858
|
-
L:
|
|
1165
|
+
case import_services3.Invitation.AuthMethod.NONE: {
|
|
1166
|
+
(0, import_log5.log)("authentication not required", void 0, {
|
|
1167
|
+
F: __dxlog_file7,
|
|
1168
|
+
L: 133,
|
|
859
1169
|
S: this,
|
|
860
1170
|
C: (f, a) => f(...a)
|
|
861
1171
|
});
|
|
@@ -863,7 +1173,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
863
1173
|
status: import_invitations.AuthenticationResponse.Status.OK
|
|
864
1174
|
};
|
|
865
1175
|
}
|
|
866
|
-
case
|
|
1176
|
+
case import_services3.Invitation.AuthMethod.SHARED_SECRET: {
|
|
867
1177
|
if (this.invitation.authCode) {
|
|
868
1178
|
if (this.authenticationRetry++ > MAX_OTP_ATTEMPTS) {
|
|
869
1179
|
status = import_invitations.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
|
|
@@ -876,11 +1186,11 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
876
1186
|
break;
|
|
877
1187
|
}
|
|
878
1188
|
default: {
|
|
879
|
-
|
|
1189
|
+
import_log5.log.error("invalid authentication method", {
|
|
880
1190
|
authMethod: this.invitation.authMethod
|
|
881
1191
|
}, {
|
|
882
|
-
F:
|
|
883
|
-
L:
|
|
1192
|
+
F: __dxlog_file7,
|
|
1193
|
+
L: 151,
|
|
884
1194
|
S: this,
|
|
885
1195
|
C: (f, a) => f(...a)
|
|
886
1196
|
});
|
|
@@ -888,14 +1198,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
888
1198
|
break;
|
|
889
1199
|
}
|
|
890
1200
|
}
|
|
891
|
-
|
|
1201
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols4.trace.end({
|
|
892
1202
|
id: traceId,
|
|
893
1203
|
data: {
|
|
894
1204
|
status
|
|
895
1205
|
}
|
|
896
1206
|
}), {
|
|
897
|
-
F:
|
|
898
|
-
L:
|
|
1207
|
+
F: __dxlog_file7,
|
|
1208
|
+
L: 157,
|
|
899
1209
|
S: this,
|
|
900
1210
|
C: (f, a) => f(...a)
|
|
901
1211
|
});
|
|
@@ -905,25 +1215,33 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
905
1215
|
},
|
|
906
1216
|
admit: async (request) => {
|
|
907
1217
|
const traceId = import_keys3.PublicKey.random().toHex();
|
|
908
|
-
|
|
1218
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols4.trace.begin({
|
|
909
1219
|
id: traceId
|
|
910
1220
|
}), {
|
|
911
|
-
F:
|
|
912
|
-
L:
|
|
1221
|
+
F: __dxlog_file7,
|
|
1222
|
+
L: 163,
|
|
913
1223
|
S: this,
|
|
914
1224
|
C: (f, a) => f(...a)
|
|
915
1225
|
});
|
|
916
1226
|
try {
|
|
917
|
-
(0,
|
|
1227
|
+
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1228
|
+
F: __dxlog_file7,
|
|
1229
|
+
L: 166,
|
|
1230
|
+
S: this,
|
|
1231
|
+
A: [
|
|
1232
|
+
"this.invitation",
|
|
1233
|
+
"'Invitation is not set.'"
|
|
1234
|
+
]
|
|
1235
|
+
});
|
|
918
1236
|
if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
|
|
919
1237
|
throw new Error("Not authenticated");
|
|
920
1238
|
}
|
|
921
1239
|
const response = await this._callbacks.admit(request);
|
|
922
|
-
|
|
1240
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols4.trace.end({
|
|
923
1241
|
id: traceId
|
|
924
1242
|
}), {
|
|
925
|
-
F:
|
|
926
|
-
L:
|
|
1243
|
+
F: __dxlog_file7,
|
|
1244
|
+
L: 174,
|
|
927
1245
|
S: this,
|
|
928
1246
|
C: (f, a) => f(...a)
|
|
929
1247
|
});
|
|
@@ -943,7 +1261,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
943
1261
|
await this.rpc.InvitationHostService.options({
|
|
944
1262
|
role: import_invitations.Options.Role.HOST
|
|
945
1263
|
});
|
|
946
|
-
await (0,
|
|
1264
|
+
await (0, import_context3.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
947
1265
|
timeout: OPTIONS_TIMEOUT
|
|
948
1266
|
}));
|
|
949
1267
|
if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== import_invitations.Options.Role.GUEST) {
|
|
@@ -965,21 +1283,29 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
965
1283
|
constructor(_callbacks) {
|
|
966
1284
|
super({
|
|
967
1285
|
requested: {
|
|
968
|
-
InvitationHostService:
|
|
1286
|
+
InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
969
1287
|
},
|
|
970
1288
|
exposed: {
|
|
971
|
-
InvitationHostService:
|
|
1289
|
+
InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
972
1290
|
}
|
|
973
1291
|
});
|
|
974
1292
|
this._callbacks = _callbacks;
|
|
975
|
-
this._ctx = new
|
|
1293
|
+
this._ctx = new import_context3.Context();
|
|
976
1294
|
this._remoteOptionsTrigger = new import_async4.Trigger();
|
|
977
1295
|
}
|
|
978
1296
|
async getHandlers() {
|
|
979
1297
|
return {
|
|
980
1298
|
InvitationHostService: {
|
|
981
1299
|
options: async (options) => {
|
|
982
|
-
(0,
|
|
1300
|
+
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1301
|
+
F: __dxlog_file7,
|
|
1302
|
+
L: 241,
|
|
1303
|
+
S: this,
|
|
1304
|
+
A: [
|
|
1305
|
+
"!this._remoteOptions",
|
|
1306
|
+
"'Remote options already set.'"
|
|
1307
|
+
]
|
|
1308
|
+
});
|
|
983
1309
|
this._remoteOptions = options;
|
|
984
1310
|
this._remoteOptionsTrigger.wake();
|
|
985
1311
|
},
|
|
@@ -999,21 +1325,21 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
999
1325
|
var _a;
|
|
1000
1326
|
await super.onOpen(context);
|
|
1001
1327
|
try {
|
|
1002
|
-
(0,
|
|
1003
|
-
F:
|
|
1004
|
-
L:
|
|
1328
|
+
(0, import_log5.log)("begin options", void 0, {
|
|
1329
|
+
F: __dxlog_file7,
|
|
1330
|
+
L: 262,
|
|
1005
1331
|
S: this,
|
|
1006
1332
|
C: (f, a) => f(...a)
|
|
1007
1333
|
});
|
|
1008
|
-
await (0,
|
|
1334
|
+
await (0, import_context3.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
|
|
1009
1335
|
role: import_invitations.Options.Role.GUEST
|
|
1010
1336
|
}));
|
|
1011
|
-
await (0,
|
|
1337
|
+
await (0, import_context3.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1012
1338
|
timeout: OPTIONS_TIMEOUT
|
|
1013
1339
|
}));
|
|
1014
|
-
(0,
|
|
1015
|
-
F:
|
|
1016
|
-
L:
|
|
1340
|
+
(0, import_log5.log)("end options", void 0, {
|
|
1341
|
+
F: __dxlog_file7,
|
|
1342
|
+
L: 265,
|
|
1017
1343
|
S: this,
|
|
1018
1344
|
C: (f, a) => f(...a)
|
|
1019
1345
|
});
|
|
@@ -1025,9 +1351,9 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1025
1351
|
}
|
|
1026
1352
|
this._callbacks.onOpen(this._ctx);
|
|
1027
1353
|
} catch (err) {
|
|
1028
|
-
(0,
|
|
1029
|
-
F:
|
|
1030
|
-
L:
|
|
1354
|
+
(0, import_log5.log)("openError", err, {
|
|
1355
|
+
F: __dxlog_file7,
|
|
1356
|
+
L: 275,
|
|
1031
1357
|
S: this,
|
|
1032
1358
|
C: (f, a) => f(...a)
|
|
1033
1359
|
});
|
|
@@ -1035,19 +1361,19 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1035
1361
|
}
|
|
1036
1362
|
}
|
|
1037
1363
|
async onClose() {
|
|
1038
|
-
(0,
|
|
1039
|
-
F:
|
|
1040
|
-
L:
|
|
1364
|
+
(0, import_log5.log)("onClose", void 0, {
|
|
1365
|
+
F: __dxlog_file7,
|
|
1366
|
+
L: 281,
|
|
1041
1367
|
S: this,
|
|
1042
1368
|
C: (f, a) => f(...a)
|
|
1043
1369
|
});
|
|
1044
1370
|
await this._ctx.dispose();
|
|
1045
1371
|
}
|
|
1046
1372
|
};
|
|
1047
|
-
var isAuthenticationRequired = (invitation) => invitation.authMethod !==
|
|
1373
|
+
var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services3.Invitation.AuthMethod.NONE;
|
|
1048
1374
|
|
|
1049
1375
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1050
|
-
var
|
|
1376
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
1051
1377
|
var InvitationsHandler = class {
|
|
1052
1378
|
/**
|
|
1053
1379
|
* @internal
|
|
@@ -1057,9 +1383,17 @@ var InvitationsHandler = class {
|
|
|
1057
1383
|
}
|
|
1058
1384
|
createInvitation(protocol, options) {
|
|
1059
1385
|
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,
|
|
1386
|
+
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 : {};
|
|
1387
|
+
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;
|
|
1388
|
+
(0, import_invariant7.invariant)(protocol, void 0, {
|
|
1389
|
+
F: __dxlog_file8,
|
|
1390
|
+
L: 76,
|
|
1391
|
+
S: this,
|
|
1392
|
+
A: [
|
|
1393
|
+
"protocol",
|
|
1394
|
+
""
|
|
1395
|
+
]
|
|
1396
|
+
});
|
|
1063
1397
|
const invitation = {
|
|
1064
1398
|
invitationId,
|
|
1065
1399
|
type,
|
|
@@ -1071,18 +1405,18 @@ var InvitationsHandler = class {
|
|
|
1071
1405
|
...protocol.getInvitationContext()
|
|
1072
1406
|
};
|
|
1073
1407
|
const stream = new import_async5.PushStream();
|
|
1074
|
-
const ctx = new
|
|
1408
|
+
const ctx = new import_context4.Context({
|
|
1075
1409
|
onError: (err) => {
|
|
1076
1410
|
void ctx.dispose();
|
|
1077
1411
|
stream.error(err);
|
|
1078
1412
|
}
|
|
1079
1413
|
});
|
|
1080
1414
|
ctx.onDispose(() => {
|
|
1081
|
-
(0,
|
|
1415
|
+
(0, import_log6.log)("complete", {
|
|
1082
1416
|
...protocol.toJSON()
|
|
1083
1417
|
}, {
|
|
1084
|
-
F:
|
|
1085
|
-
L:
|
|
1418
|
+
F: __dxlog_file8,
|
|
1419
|
+
L: 98,
|
|
1086
1420
|
S: this,
|
|
1087
1421
|
C: (f, a) => f(...a)
|
|
1088
1422
|
});
|
|
@@ -1093,7 +1427,7 @@ var InvitationsHandler = class {
|
|
|
1093
1427
|
onStateUpdate: (invitation2) => {
|
|
1094
1428
|
stream.next({
|
|
1095
1429
|
...invitation2,
|
|
1096
|
-
state:
|
|
1430
|
+
state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1097
1431
|
});
|
|
1098
1432
|
},
|
|
1099
1433
|
resolveInvitation: async ({ invitationId: invitationId2 }) => {
|
|
@@ -1106,7 +1440,15 @@ var InvitationsHandler = class {
|
|
|
1106
1440
|
var _a2, _b, _c;
|
|
1107
1441
|
try {
|
|
1108
1442
|
const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
|
|
1109
|
-
(0,
|
|
1443
|
+
(0, import_invariant7.invariant)(deviceKey, void 0, {
|
|
1444
|
+
F: __dxlog_file8,
|
|
1445
|
+
L: 119,
|
|
1446
|
+
S: this,
|
|
1447
|
+
A: [
|
|
1448
|
+
"deviceKey",
|
|
1449
|
+
""
|
|
1450
|
+
]
|
|
1451
|
+
});
|
|
1110
1452
|
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1111
1453
|
extension.completedTrigger.wake(deviceKey);
|
|
1112
1454
|
return admissionResponse;
|
|
@@ -1119,84 +1461,84 @@ var InvitationsHandler = class {
|
|
|
1119
1461
|
(0, import_async5.scheduleTask)(ctx, async () => {
|
|
1120
1462
|
const traceId = import_keys4.PublicKey.random().toHex();
|
|
1121
1463
|
try {
|
|
1122
|
-
|
|
1464
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.begin({
|
|
1123
1465
|
id: traceId
|
|
1124
1466
|
}), {
|
|
1125
|
-
F:
|
|
1126
|
-
L:
|
|
1467
|
+
F: __dxlog_file8,
|
|
1468
|
+
L: 137,
|
|
1127
1469
|
S: this,
|
|
1128
1470
|
C: (f, a) => f(...a)
|
|
1129
1471
|
});
|
|
1130
|
-
(0,
|
|
1472
|
+
(0, import_log6.log)("connected", {
|
|
1131
1473
|
...protocol.toJSON()
|
|
1132
1474
|
}, {
|
|
1133
|
-
F:
|
|
1134
|
-
L:
|
|
1475
|
+
F: __dxlog_file8,
|
|
1476
|
+
L: 138,
|
|
1135
1477
|
S: this,
|
|
1136
1478
|
C: (f, a) => f(...a)
|
|
1137
1479
|
});
|
|
1138
1480
|
stream.next({
|
|
1139
1481
|
...invitation,
|
|
1140
|
-
state:
|
|
1482
|
+
state: import_services4.Invitation.State.CONNECTED
|
|
1141
1483
|
});
|
|
1142
1484
|
const deviceKey = await extension.completedTrigger.wait({
|
|
1143
1485
|
timeout
|
|
1144
1486
|
});
|
|
1145
|
-
(0,
|
|
1487
|
+
(0, import_log6.log)("admitted guest", {
|
|
1146
1488
|
guest: deviceKey,
|
|
1147
1489
|
...protocol.toJSON()
|
|
1148
1490
|
}, {
|
|
1149
|
-
F:
|
|
1150
|
-
L:
|
|
1491
|
+
F: __dxlog_file8,
|
|
1492
|
+
L: 141,
|
|
1151
1493
|
S: this,
|
|
1152
1494
|
C: (f, a) => f(...a)
|
|
1153
1495
|
});
|
|
1154
1496
|
stream.next({
|
|
1155
1497
|
...invitation,
|
|
1156
|
-
state:
|
|
1498
|
+
state: import_services4.Invitation.State.SUCCESS
|
|
1157
1499
|
});
|
|
1158
|
-
|
|
1500
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.end({
|
|
1159
1501
|
id: traceId
|
|
1160
1502
|
}), {
|
|
1161
|
-
F:
|
|
1162
|
-
L:
|
|
1503
|
+
F: __dxlog_file8,
|
|
1504
|
+
L: 143,
|
|
1163
1505
|
S: this,
|
|
1164
1506
|
C: (f, a) => f(...a)
|
|
1165
1507
|
});
|
|
1166
1508
|
} catch (err) {
|
|
1167
1509
|
if (err instanceof import_async5.TimeoutError) {
|
|
1168
|
-
(0,
|
|
1510
|
+
(0, import_log6.log)("timeout", {
|
|
1169
1511
|
...protocol.toJSON()
|
|
1170
1512
|
}, {
|
|
1171
|
-
F:
|
|
1172
|
-
L:
|
|
1513
|
+
F: __dxlog_file8,
|
|
1514
|
+
L: 146,
|
|
1173
1515
|
S: this,
|
|
1174
1516
|
C: (f, a) => f(...a)
|
|
1175
1517
|
});
|
|
1176
1518
|
stream.next({
|
|
1177
1519
|
...invitation,
|
|
1178
|
-
state:
|
|
1520
|
+
state: import_services4.Invitation.State.TIMEOUT
|
|
1179
1521
|
});
|
|
1180
1522
|
} else {
|
|
1181
|
-
|
|
1182
|
-
F:
|
|
1183
|
-
L:
|
|
1523
|
+
import_log6.log.error("failed", err, {
|
|
1524
|
+
F: __dxlog_file8,
|
|
1525
|
+
L: 149,
|
|
1184
1526
|
S: this,
|
|
1185
1527
|
C: (f, a) => f(...a)
|
|
1186
1528
|
});
|
|
1187
1529
|
stream.error(err);
|
|
1188
1530
|
}
|
|
1189
|
-
|
|
1531
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.error({
|
|
1190
1532
|
id: traceId,
|
|
1191
1533
|
error: err
|
|
1192
1534
|
}), {
|
|
1193
|
-
F:
|
|
1194
|
-
L:
|
|
1535
|
+
F: __dxlog_file8,
|
|
1536
|
+
L: 152,
|
|
1195
1537
|
S: this,
|
|
1196
1538
|
C: (f, a) => f(...a)
|
|
1197
1539
|
});
|
|
1198
1540
|
} finally {
|
|
1199
|
-
if (type !==
|
|
1541
|
+
if (type !== import_services4.Invitation.Type.MULTIUSE) {
|
|
1200
1542
|
await swarmConnection.close();
|
|
1201
1543
|
await ctx.dispose();
|
|
1202
1544
|
}
|
|
@@ -1208,22 +1550,22 @@ var InvitationsHandler = class {
|
|
|
1208
1550
|
return;
|
|
1209
1551
|
}
|
|
1210
1552
|
if (err instanceof import_async5.TimeoutError) {
|
|
1211
|
-
(0,
|
|
1553
|
+
(0, import_log6.log)("timeout", {
|
|
1212
1554
|
...protocol.toJSON()
|
|
1213
1555
|
}, {
|
|
1214
|
-
F:
|
|
1215
|
-
L:
|
|
1556
|
+
F: __dxlog_file8,
|
|
1557
|
+
L: 167,
|
|
1216
1558
|
S: this,
|
|
1217
1559
|
C: (f, a) => f(...a)
|
|
1218
1560
|
});
|
|
1219
1561
|
stream.next({
|
|
1220
1562
|
...invitation,
|
|
1221
|
-
state:
|
|
1563
|
+
state: import_services4.Invitation.State.TIMEOUT
|
|
1222
1564
|
});
|
|
1223
1565
|
} else {
|
|
1224
|
-
|
|
1225
|
-
F:
|
|
1226
|
-
L:
|
|
1566
|
+
import_log6.log.error("failed", err, {
|
|
1567
|
+
F: __dxlog_file8,
|
|
1568
|
+
L: 170,
|
|
1227
1569
|
S: this,
|
|
1228
1570
|
C: (f, a) => f(...a)
|
|
1229
1571
|
});
|
|
@@ -1247,7 +1589,7 @@ var InvitationsHandler = class {
|
|
|
1247
1589
|
ctx.onDispose(() => swarmConnection.close());
|
|
1248
1590
|
stream.next({
|
|
1249
1591
|
...invitation,
|
|
1250
|
-
state:
|
|
1592
|
+
state: import_services4.Invitation.State.CONNECTING
|
|
1251
1593
|
});
|
|
1252
1594
|
});
|
|
1253
1595
|
const observable = new import_client_protocol2.CancellableInvitationObservable({
|
|
@@ -1256,7 +1598,7 @@ var InvitationsHandler = class {
|
|
|
1256
1598
|
onCancel: async () => {
|
|
1257
1599
|
stream.next({
|
|
1258
1600
|
...invitation,
|
|
1259
|
-
state:
|
|
1601
|
+
state: import_services4.Invitation.State.CANCELLED
|
|
1260
1602
|
});
|
|
1261
1603
|
await ctx.dispose();
|
|
1262
1604
|
}
|
|
@@ -1265,37 +1607,53 @@ var InvitationsHandler = class {
|
|
|
1265
1607
|
}
|
|
1266
1608
|
acceptInvitation(protocol, invitation) {
|
|
1267
1609
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
1268
|
-
(0,
|
|
1610
|
+
(0, import_invariant7.invariant)(protocol, void 0, {
|
|
1611
|
+
F: __dxlog_file8,
|
|
1612
|
+
L: 210,
|
|
1613
|
+
S: this,
|
|
1614
|
+
A: [
|
|
1615
|
+
"protocol",
|
|
1616
|
+
""
|
|
1617
|
+
]
|
|
1618
|
+
});
|
|
1269
1619
|
const authenticated = new import_async5.Trigger();
|
|
1270
1620
|
let admitted = false;
|
|
1271
1621
|
let currentState;
|
|
1272
1622
|
const stream = new import_async5.PushStream();
|
|
1273
1623
|
const setState = (newData) => {
|
|
1274
|
-
(0,
|
|
1624
|
+
(0, import_invariant7.invariant)(newData.state !== void 0, void 0, {
|
|
1625
|
+
F: __dxlog_file8,
|
|
1626
|
+
L: 221,
|
|
1627
|
+
S: this,
|
|
1628
|
+
A: [
|
|
1629
|
+
"newData.state !== undefined",
|
|
1630
|
+
""
|
|
1631
|
+
]
|
|
1632
|
+
});
|
|
1275
1633
|
currentState = newData.state;
|
|
1276
1634
|
stream.next({
|
|
1277
1635
|
...invitation,
|
|
1278
1636
|
...newData
|
|
1279
1637
|
});
|
|
1280
1638
|
};
|
|
1281
|
-
const ctx = new
|
|
1639
|
+
const ctx = new import_context4.Context({
|
|
1282
1640
|
onError: (err) => {
|
|
1283
1641
|
if (err instanceof import_async5.TimeoutError) {
|
|
1284
|
-
(0,
|
|
1642
|
+
(0, import_log6.log)("timeout", {
|
|
1285
1643
|
...protocol.toJSON()
|
|
1286
1644
|
}, {
|
|
1287
|
-
F:
|
|
1288
|
-
L:
|
|
1645
|
+
F: __dxlog_file8,
|
|
1646
|
+
L: 229,
|
|
1289
1647
|
S: this,
|
|
1290
1648
|
C: (f, a) => f(...a)
|
|
1291
1649
|
});
|
|
1292
1650
|
setState({
|
|
1293
|
-
state:
|
|
1651
|
+
state: import_services4.Invitation.State.TIMEOUT
|
|
1294
1652
|
});
|
|
1295
1653
|
} else {
|
|
1296
|
-
|
|
1297
|
-
F:
|
|
1298
|
-
L:
|
|
1654
|
+
import_log6.log.warn("auth failed", err, {
|
|
1655
|
+
F: __dxlog_file8,
|
|
1656
|
+
L: 232,
|
|
1299
1657
|
S: this,
|
|
1300
1658
|
C: (f, a) => f(...a)
|
|
1301
1659
|
});
|
|
@@ -1305,11 +1663,11 @@ var InvitationsHandler = class {
|
|
|
1305
1663
|
}
|
|
1306
1664
|
});
|
|
1307
1665
|
ctx.onDispose(() => {
|
|
1308
|
-
(0,
|
|
1666
|
+
(0, import_log6.log)("complete", {
|
|
1309
1667
|
...protocol.toJSON()
|
|
1310
1668
|
}, {
|
|
1311
|
-
F:
|
|
1312
|
-
L:
|
|
1669
|
+
F: __dxlog_file8,
|
|
1670
|
+
L: 240,
|
|
1313
1671
|
S: this,
|
|
1314
1672
|
C: (f, a) => f(...a)
|
|
1315
1673
|
});
|
|
@@ -1320,11 +1678,11 @@ var InvitationsHandler = class {
|
|
|
1320
1678
|
const extension = new InvitationGuestExtension({
|
|
1321
1679
|
onOpen: (extensionCtx) => {
|
|
1322
1680
|
extensionCtx.onDispose(async () => {
|
|
1323
|
-
(0,
|
|
1681
|
+
(0, import_log6.log)("extension disposed", {
|
|
1324
1682
|
currentState
|
|
1325
1683
|
}, {
|
|
1326
|
-
F:
|
|
1327
|
-
L:
|
|
1684
|
+
F: __dxlog_file8,
|
|
1685
|
+
L: 250,
|
|
1328
1686
|
S: this,
|
|
1329
1687
|
C: (f, a) => f(...a)
|
|
1330
1688
|
});
|
|
@@ -1335,11 +1693,11 @@ var InvitationsHandler = class {
|
|
|
1335
1693
|
(0, import_async5.scheduleTask)(ctx, async () => {
|
|
1336
1694
|
const traceId = import_keys4.PublicKey.random().toHex();
|
|
1337
1695
|
try {
|
|
1338
|
-
|
|
1696
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.begin({
|
|
1339
1697
|
id: traceId
|
|
1340
1698
|
}), {
|
|
1341
|
-
F:
|
|
1342
|
-
L:
|
|
1699
|
+
F: __dxlog_file8,
|
|
1700
|
+
L: 259,
|
|
1343
1701
|
S: this,
|
|
1344
1702
|
C: (f, a) => f(...a)
|
|
1345
1703
|
});
|
|
@@ -1347,32 +1705,32 @@ var InvitationsHandler = class {
|
|
|
1347
1705
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
1348
1706
|
}
|
|
1349
1707
|
(0, import_async5.scheduleTask)(ctx, () => ctx.raise(new import_async5.TimeoutError(timeout)), timeout);
|
|
1350
|
-
(0,
|
|
1708
|
+
(0, import_log6.log)("connected", {
|
|
1351
1709
|
...protocol.toJSON()
|
|
1352
1710
|
}, {
|
|
1353
|
-
F:
|
|
1354
|
-
L:
|
|
1711
|
+
F: __dxlog_file8,
|
|
1712
|
+
L: 267,
|
|
1355
1713
|
S: this,
|
|
1356
1714
|
C: (f, a) => f(...a)
|
|
1357
1715
|
});
|
|
1358
1716
|
setState({
|
|
1359
|
-
state:
|
|
1717
|
+
state: import_services4.Invitation.State.CONNECTED
|
|
1360
1718
|
});
|
|
1361
|
-
(0,
|
|
1719
|
+
(0, import_log6.log)("introduce", {
|
|
1362
1720
|
...protocol.toJSON()
|
|
1363
1721
|
}, {
|
|
1364
|
-
F:
|
|
1365
|
-
L:
|
|
1722
|
+
F: __dxlog_file8,
|
|
1723
|
+
L: 271,
|
|
1366
1724
|
S: this,
|
|
1367
1725
|
C: (f, a) => f(...a)
|
|
1368
1726
|
});
|
|
1369
1727
|
const introductionResponse = await extension.rpc.InvitationHostService.introduce(protocol.createIntroduction());
|
|
1370
|
-
(0,
|
|
1728
|
+
(0, import_log6.log)("introduce response", {
|
|
1371
1729
|
...protocol.toJSON(),
|
|
1372
1730
|
response: introductionResponse
|
|
1373
1731
|
}, {
|
|
1374
|
-
F:
|
|
1375
|
-
L:
|
|
1732
|
+
F: __dxlog_file8,
|
|
1733
|
+
L: 275,
|
|
1376
1734
|
S: this,
|
|
1377
1735
|
C: (f, a) => f(...a)
|
|
1378
1736
|
});
|
|
@@ -1382,26 +1740,26 @@ var InvitationsHandler = class {
|
|
|
1382
1740
|
}
|
|
1383
1741
|
if (isAuthenticationRequired(invitation)) {
|
|
1384
1742
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1385
|
-
(0,
|
|
1386
|
-
F:
|
|
1387
|
-
L:
|
|
1743
|
+
(0, import_log6.log)("guest waiting for authentication code...", void 0, {
|
|
1744
|
+
F: __dxlog_file8,
|
|
1745
|
+
L: 284,
|
|
1388
1746
|
S: this,
|
|
1389
1747
|
C: (f, a) => f(...a)
|
|
1390
1748
|
});
|
|
1391
1749
|
setState({
|
|
1392
|
-
state:
|
|
1750
|
+
state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1393
1751
|
});
|
|
1394
1752
|
const authCode = await authenticated.wait({
|
|
1395
1753
|
timeout
|
|
1396
1754
|
});
|
|
1397
|
-
(0,
|
|
1398
|
-
F:
|
|
1399
|
-
L:
|
|
1755
|
+
(0, import_log6.log)("sending authentication request", void 0, {
|
|
1756
|
+
F: __dxlog_file8,
|
|
1757
|
+
L: 288,
|
|
1400
1758
|
S: this,
|
|
1401
1759
|
C: (f, a) => f(...a)
|
|
1402
1760
|
});
|
|
1403
1761
|
setState({
|
|
1404
|
-
state:
|
|
1762
|
+
state: import_services4.Invitation.State.AUTHENTICATING
|
|
1405
1763
|
});
|
|
1406
1764
|
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
1407
1765
|
authCode
|
|
@@ -1413,11 +1771,11 @@ var InvitationsHandler = class {
|
|
|
1413
1771
|
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
1414
1772
|
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
1415
1773
|
} else {
|
|
1416
|
-
(0,
|
|
1774
|
+
(0, import_log6.log)("retrying invalid code", {
|
|
1417
1775
|
attempt
|
|
1418
1776
|
}, {
|
|
1419
|
-
F:
|
|
1420
|
-
L:
|
|
1777
|
+
F: __dxlog_file8,
|
|
1778
|
+
L: 299,
|
|
1421
1779
|
S: this,
|
|
1422
1780
|
C: (f, a) => f(...a)
|
|
1423
1781
|
});
|
|
@@ -1427,14 +1785,14 @@ var InvitationsHandler = class {
|
|
|
1427
1785
|
}
|
|
1428
1786
|
} else {
|
|
1429
1787
|
setState({
|
|
1430
|
-
state:
|
|
1788
|
+
state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1431
1789
|
});
|
|
1432
1790
|
}
|
|
1433
|
-
(0,
|
|
1791
|
+
(0, import_log6.log)("request admission", {
|
|
1434
1792
|
...protocol.toJSON()
|
|
1435
1793
|
}, {
|
|
1436
|
-
F:
|
|
1437
|
-
L:
|
|
1794
|
+
F: __dxlog_file8,
|
|
1795
|
+
L: 310,
|
|
1438
1796
|
S: this,
|
|
1439
1797
|
C: (f, a) => f(...a)
|
|
1440
1798
|
});
|
|
@@ -1442,54 +1800,54 @@ var InvitationsHandler = class {
|
|
|
1442
1800
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
1443
1801
|
admitted = true;
|
|
1444
1802
|
const result = await protocol.accept(admissionResponse, admissionRequest);
|
|
1445
|
-
(0,
|
|
1803
|
+
(0, import_log6.log)("admitted by host", {
|
|
1446
1804
|
...protocol.toJSON()
|
|
1447
1805
|
}, {
|
|
1448
|
-
F:
|
|
1449
|
-
L:
|
|
1806
|
+
F: __dxlog_file8,
|
|
1807
|
+
L: 321,
|
|
1450
1808
|
S: this,
|
|
1451
1809
|
C: (f, a) => f(...a)
|
|
1452
1810
|
});
|
|
1453
1811
|
setState({
|
|
1454
1812
|
...result,
|
|
1455
|
-
state:
|
|
1813
|
+
state: import_services4.Invitation.State.SUCCESS
|
|
1456
1814
|
});
|
|
1457
|
-
|
|
1815
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.end({
|
|
1458
1816
|
id: traceId
|
|
1459
1817
|
}), {
|
|
1460
|
-
F:
|
|
1461
|
-
L:
|
|
1818
|
+
F: __dxlog_file8,
|
|
1819
|
+
L: 323,
|
|
1462
1820
|
S: this,
|
|
1463
1821
|
C: (f, a) => f(...a)
|
|
1464
1822
|
});
|
|
1465
1823
|
} catch (err) {
|
|
1466
1824
|
if (err instanceof import_async5.TimeoutError) {
|
|
1467
|
-
(0,
|
|
1825
|
+
(0, import_log6.log)("timeout", {
|
|
1468
1826
|
...protocol.toJSON()
|
|
1469
1827
|
}, {
|
|
1470
|
-
F:
|
|
1471
|
-
L:
|
|
1828
|
+
F: __dxlog_file8,
|
|
1829
|
+
L: 326,
|
|
1472
1830
|
S: this,
|
|
1473
1831
|
C: (f, a) => f(...a)
|
|
1474
1832
|
});
|
|
1475
1833
|
setState({
|
|
1476
|
-
state:
|
|
1834
|
+
state: import_services4.Invitation.State.TIMEOUT
|
|
1477
1835
|
});
|
|
1478
1836
|
} else {
|
|
1479
|
-
(0,
|
|
1480
|
-
F:
|
|
1481
|
-
L:
|
|
1837
|
+
(0, import_log6.log)("auth failed", err, {
|
|
1838
|
+
F: __dxlog_file8,
|
|
1839
|
+
L: 329,
|
|
1482
1840
|
S: this,
|
|
1483
1841
|
C: (f, a) => f(...a)
|
|
1484
1842
|
});
|
|
1485
1843
|
stream.error(err);
|
|
1486
1844
|
}
|
|
1487
|
-
|
|
1845
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.error({
|
|
1488
1846
|
id: traceId,
|
|
1489
1847
|
error: err
|
|
1490
1848
|
}), {
|
|
1491
|
-
F:
|
|
1492
|
-
L:
|
|
1849
|
+
F: __dxlog_file8,
|
|
1850
|
+
L: 332,
|
|
1493
1851
|
S: this,
|
|
1494
1852
|
C: (f, a) => f(...a)
|
|
1495
1853
|
});
|
|
@@ -1503,21 +1861,21 @@ var InvitationsHandler = class {
|
|
|
1503
1861
|
return;
|
|
1504
1862
|
}
|
|
1505
1863
|
if (err instanceof import_async5.TimeoutError) {
|
|
1506
|
-
(0,
|
|
1864
|
+
(0, import_log6.log)("timeout", {
|
|
1507
1865
|
...protocol.toJSON()
|
|
1508
1866
|
}, {
|
|
1509
|
-
F:
|
|
1510
|
-
L:
|
|
1867
|
+
F: __dxlog_file8,
|
|
1868
|
+
L: 343,
|
|
1511
1869
|
S: this,
|
|
1512
1870
|
C: (f, a) => f(...a)
|
|
1513
1871
|
});
|
|
1514
1872
|
setState({
|
|
1515
|
-
state:
|
|
1873
|
+
state: import_services4.Invitation.State.TIMEOUT
|
|
1516
1874
|
});
|
|
1517
1875
|
} else {
|
|
1518
|
-
(0,
|
|
1519
|
-
F:
|
|
1520
|
-
L:
|
|
1876
|
+
(0, import_log6.log)("auth failed", err, {
|
|
1877
|
+
F: __dxlog_file8,
|
|
1878
|
+
L: 346,
|
|
1521
1879
|
S: this,
|
|
1522
1880
|
C: (f, a) => f(...a)
|
|
1523
1881
|
});
|
|
@@ -1528,7 +1886,15 @@ var InvitationsHandler = class {
|
|
|
1528
1886
|
return extension;
|
|
1529
1887
|
};
|
|
1530
1888
|
(0, import_async5.scheduleTask)(ctx, async () => {
|
|
1531
|
-
(0,
|
|
1889
|
+
(0, import_invariant7.invariant)(invitation.swarmKey, void 0, {
|
|
1890
|
+
F: __dxlog_file8,
|
|
1891
|
+
L: 356,
|
|
1892
|
+
S: this,
|
|
1893
|
+
A: [
|
|
1894
|
+
"invitation.swarmKey",
|
|
1895
|
+
""
|
|
1896
|
+
]
|
|
1897
|
+
});
|
|
1532
1898
|
const topic = invitation.swarmKey;
|
|
1533
1899
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1534
1900
|
topic,
|
|
@@ -1540,7 +1906,7 @@ var InvitationsHandler = class {
|
|
|
1540
1906
|
});
|
|
1541
1907
|
ctx.onDispose(() => swarmConnection.close());
|
|
1542
1908
|
setState({
|
|
1543
|
-
state:
|
|
1909
|
+
state: import_services4.Invitation.State.CONNECTING
|
|
1544
1910
|
});
|
|
1545
1911
|
});
|
|
1546
1912
|
const observable = new import_client_protocol2.AuthenticatingInvitationObservable({
|
|
@@ -1548,7 +1914,7 @@ var InvitationsHandler = class {
|
|
|
1548
1914
|
subscriber: stream.observable,
|
|
1549
1915
|
onCancel: async () => {
|
|
1550
1916
|
setState({
|
|
1551
|
-
state:
|
|
1917
|
+
state: import_services4.Invitation.State.CANCELLED
|
|
1552
1918
|
});
|
|
1553
1919
|
await ctx.dispose();
|
|
1554
1920
|
},
|
|
@@ -1561,12 +1927,12 @@ var InvitationsHandler = class {
|
|
|
1561
1927
|
};
|
|
1562
1928
|
|
|
1563
1929
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1564
|
-
var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
|
|
1565
1930
|
var import_async6 = require("@dxos/async");
|
|
1566
|
-
var
|
|
1567
|
-
var
|
|
1568
|
-
var
|
|
1569
|
-
var
|
|
1931
|
+
var import_codec_protobuf4 = require("@dxos/codec-protobuf");
|
|
1932
|
+
var import_invariant8 = require("@dxos/invariant");
|
|
1933
|
+
var import_log7 = require("@dxos/log");
|
|
1934
|
+
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1935
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
1570
1936
|
var InvitationsServiceImpl = class {
|
|
1571
1937
|
constructor(_invitationsHandler, _getHandler) {
|
|
1572
1938
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -1593,7 +1959,7 @@ var InvitationsServiceImpl = class {
|
|
|
1593
1959
|
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
1594
1960
|
this._invitationCreated.emit(invitation.get());
|
|
1595
1961
|
}
|
|
1596
|
-
return new
|
|
1962
|
+
return new import_codec_protobuf4.Stream(({ next, close }) => {
|
|
1597
1963
|
invitation.subscribe((invitation2) => {
|
|
1598
1964
|
next(invitation2);
|
|
1599
1965
|
}, (err) => {
|
|
@@ -1615,7 +1981,7 @@ var InvitationsServiceImpl = class {
|
|
|
1615
1981
|
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
1616
1982
|
this._invitationAccepted.emit(invitation.get());
|
|
1617
1983
|
}
|
|
1618
|
-
return new
|
|
1984
|
+
return new import_codec_protobuf4.Stream(({ next, close }) => {
|
|
1619
1985
|
invitation.subscribe((invitation2) => {
|
|
1620
1986
|
next(invitation2);
|
|
1621
1987
|
}, (err) => {
|
|
@@ -1627,20 +1993,28 @@ var InvitationsServiceImpl = class {
|
|
|
1627
1993
|
});
|
|
1628
1994
|
}
|
|
1629
1995
|
async authenticate({ invitationId, authCode }) {
|
|
1630
|
-
(0,
|
|
1631
|
-
F:
|
|
1632
|
-
L:
|
|
1996
|
+
(0, import_log7.log)("authenticating...", void 0, {
|
|
1997
|
+
F: __dxlog_file9,
|
|
1998
|
+
L: 102,
|
|
1633
1999
|
S: this,
|
|
1634
2000
|
C: (f, a) => f(...a)
|
|
1635
2001
|
});
|
|
1636
|
-
(0,
|
|
2002
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2003
|
+
F: __dxlog_file9,
|
|
2004
|
+
L: 103,
|
|
2005
|
+
S: this,
|
|
2006
|
+
A: [
|
|
2007
|
+
"invitationId",
|
|
2008
|
+
""
|
|
2009
|
+
]
|
|
2010
|
+
});
|
|
1637
2011
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1638
2012
|
if (!observable) {
|
|
1639
|
-
|
|
2013
|
+
import_log7.log.warn("invalid invitation", {
|
|
1640
2014
|
invitationId
|
|
1641
2015
|
}, {
|
|
1642
|
-
F:
|
|
1643
|
-
L:
|
|
2016
|
+
F: __dxlog_file9,
|
|
2017
|
+
L: 106,
|
|
1644
2018
|
S: this,
|
|
1645
2019
|
C: (f, a) => f(...a)
|
|
1646
2020
|
});
|
|
@@ -1649,13 +2023,21 @@ var InvitationsServiceImpl = class {
|
|
|
1649
2023
|
}
|
|
1650
2024
|
}
|
|
1651
2025
|
async cancelInvitation({ invitationId }) {
|
|
1652
|
-
(0,
|
|
1653
|
-
F:
|
|
1654
|
-
L:
|
|
2026
|
+
(0, import_log7.log)("deleting...", void 0, {
|
|
2027
|
+
F: __dxlog_file9,
|
|
2028
|
+
L: 113,
|
|
1655
2029
|
S: this,
|
|
1656
2030
|
C: (f, a) => f(...a)
|
|
1657
2031
|
});
|
|
1658
|
-
(0,
|
|
2032
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2033
|
+
F: __dxlog_file9,
|
|
2034
|
+
L: 114,
|
|
2035
|
+
S: this,
|
|
2036
|
+
A: [
|
|
2037
|
+
"invitationId",
|
|
2038
|
+
""
|
|
2039
|
+
]
|
|
2040
|
+
});
|
|
1659
2041
|
const created = this._createInvitations.get(invitationId);
|
|
1660
2042
|
const accepted = this._acceptInvitations.get(invitationId);
|
|
1661
2043
|
if (created) {
|
|
@@ -1667,22 +2049,22 @@ var InvitationsServiceImpl = class {
|
|
|
1667
2049
|
this._acceptInvitations.delete(invitationId);
|
|
1668
2050
|
this._removedAccepted.emit(accepted.get());
|
|
1669
2051
|
} else {
|
|
1670
|
-
|
|
2052
|
+
import_log7.log.warn("invalid invitation", {
|
|
1671
2053
|
invitationId
|
|
1672
2054
|
}, {
|
|
1673
|
-
F:
|
|
1674
|
-
L:
|
|
2055
|
+
F: __dxlog_file9,
|
|
2056
|
+
L: 126,
|
|
1675
2057
|
S: this,
|
|
1676
2058
|
C: (f, a) => f(...a)
|
|
1677
2059
|
});
|
|
1678
2060
|
}
|
|
1679
2061
|
}
|
|
1680
2062
|
queryInvitations() {
|
|
1681
|
-
return new
|
|
2063
|
+
return new import_codec_protobuf4.Stream(({ next, ctx }) => {
|
|
1682
2064
|
this._invitationCreated.on(ctx, (invitation) => {
|
|
1683
2065
|
next({
|
|
1684
|
-
action:
|
|
1685
|
-
type:
|
|
2066
|
+
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2067
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
1686
2068
|
invitations: [
|
|
1687
2069
|
invitation
|
|
1688
2070
|
]
|
|
@@ -1690,8 +2072,8 @@ var InvitationsServiceImpl = class {
|
|
|
1690
2072
|
});
|
|
1691
2073
|
this._invitationAccepted.on(ctx, (invitation) => {
|
|
1692
2074
|
next({
|
|
1693
|
-
action:
|
|
1694
|
-
type:
|
|
2075
|
+
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2076
|
+
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
1695
2077
|
invitations: [
|
|
1696
2078
|
invitation
|
|
1697
2079
|
]
|
|
@@ -1699,8 +2081,8 @@ var InvitationsServiceImpl = class {
|
|
|
1699
2081
|
});
|
|
1700
2082
|
this._removedCreated.on(ctx, (invitation) => {
|
|
1701
2083
|
next({
|
|
1702
|
-
action:
|
|
1703
|
-
type:
|
|
2084
|
+
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2085
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
1704
2086
|
invitations: [
|
|
1705
2087
|
invitation
|
|
1706
2088
|
]
|
|
@@ -1708,21 +2090,21 @@ var InvitationsServiceImpl = class {
|
|
|
1708
2090
|
});
|
|
1709
2091
|
this._removedAccepted.on(ctx, (invitation) => {
|
|
1710
2092
|
next({
|
|
1711
|
-
action:
|
|
1712
|
-
type:
|
|
2093
|
+
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2094
|
+
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
1713
2095
|
invitations: [
|
|
1714
2096
|
invitation
|
|
1715
2097
|
]
|
|
1716
2098
|
});
|
|
1717
2099
|
});
|
|
1718
2100
|
next({
|
|
1719
|
-
action:
|
|
1720
|
-
type:
|
|
2101
|
+
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2102
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
1721
2103
|
invitations: Array.from(this._createInvitations.values()).map((invitation) => invitation.get())
|
|
1722
2104
|
});
|
|
1723
2105
|
next({
|
|
1724
|
-
action:
|
|
1725
|
-
type:
|
|
2106
|
+
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2107
|
+
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
1726
2108
|
invitations: Array.from(this._acceptInvitations.values()).map((invitation) => invitation.get())
|
|
1727
2109
|
});
|
|
1728
2110
|
});
|
|
@@ -1730,12 +2112,12 @@ var InvitationsServiceImpl = class {
|
|
|
1730
2112
|
};
|
|
1731
2113
|
|
|
1732
2114
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
1733
|
-
var
|
|
1734
|
-
var import_credentials9 = require("@dxos/credentials");
|
|
2115
|
+
var import_credentials10 = require("@dxos/credentials");
|
|
1735
2116
|
var import_feed_store2 = require("@dxos/feed-store");
|
|
1736
|
-
var
|
|
1737
|
-
var
|
|
1738
|
-
var
|
|
2117
|
+
var import_invariant9 = require("@dxos/invariant");
|
|
2118
|
+
var import_log8 = require("@dxos/log");
|
|
2119
|
+
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2120
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
1739
2121
|
var SpaceInvitationProtocol = class {
|
|
1740
2122
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
1741
2123
|
this._spaceManager = _spaceManager;
|
|
@@ -1751,30 +2133,70 @@ var SpaceInvitationProtocol = class {
|
|
|
1751
2133
|
}
|
|
1752
2134
|
getInvitationContext() {
|
|
1753
2135
|
return {
|
|
1754
|
-
kind:
|
|
2136
|
+
kind: import_services6.Invitation.Kind.SPACE,
|
|
1755
2137
|
spaceKey: this._spaceKey
|
|
1756
2138
|
};
|
|
1757
2139
|
}
|
|
1758
2140
|
async admit(request, guestProfile) {
|
|
1759
2141
|
var _a;
|
|
1760
|
-
(0,
|
|
2142
|
+
(0, import_invariant9.invariant)(this._spaceKey, void 0, {
|
|
2143
|
+
F: __dxlog_file10,
|
|
2144
|
+
L: 42,
|
|
2145
|
+
S: this,
|
|
2146
|
+
A: [
|
|
2147
|
+
"this._spaceKey",
|
|
2148
|
+
""
|
|
2149
|
+
]
|
|
2150
|
+
});
|
|
1761
2151
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
1762
|
-
(0,
|
|
1763
|
-
|
|
2152
|
+
(0, import_invariant9.invariant)(space, void 0, {
|
|
2153
|
+
F: __dxlog_file10,
|
|
2154
|
+
L: 44,
|
|
2155
|
+
S: this,
|
|
2156
|
+
A: [
|
|
2157
|
+
"space",
|
|
2158
|
+
""
|
|
2159
|
+
]
|
|
2160
|
+
});
|
|
2161
|
+
(0, import_invariant9.invariant)(request.space, void 0, {
|
|
2162
|
+
F: __dxlog_file10,
|
|
2163
|
+
L: 46,
|
|
2164
|
+
S: this,
|
|
2165
|
+
A: [
|
|
2166
|
+
"request.space",
|
|
2167
|
+
""
|
|
2168
|
+
]
|
|
2169
|
+
});
|
|
1764
2170
|
const { identityKey, deviceKey } = request.space;
|
|
1765
|
-
(0,
|
|
2171
|
+
(0, import_log8.log)("writing guest credentials", {
|
|
1766
2172
|
host: this._signingContext.deviceKey,
|
|
1767
2173
|
guest: deviceKey
|
|
1768
2174
|
}, {
|
|
1769
|
-
F:
|
|
1770
|
-
L:
|
|
2175
|
+
F: __dxlog_file10,
|
|
2176
|
+
L: 49,
|
|
1771
2177
|
S: this,
|
|
1772
2178
|
C: (f, a) => f(...a)
|
|
1773
2179
|
});
|
|
1774
|
-
const credentials = await (0,
|
|
1775
|
-
(0,
|
|
2180
|
+
const credentials = await (0, import_credentials10.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2181
|
+
(0, import_invariant9.invariant)(credentials[0].credential, void 0, {
|
|
2182
|
+
F: __dxlog_file10,
|
|
2183
|
+
L: 60,
|
|
2184
|
+
S: this,
|
|
2185
|
+
A: [
|
|
2186
|
+
"credentials[0].credential",
|
|
2187
|
+
""
|
|
2188
|
+
]
|
|
2189
|
+
});
|
|
1776
2190
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
1777
|
-
(0,
|
|
2191
|
+
(0, import_invariant9.invariant)((0, import_credentials10.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2192
|
+
F: __dxlog_file10,
|
|
2193
|
+
L: 62,
|
|
2194
|
+
S: this,
|
|
2195
|
+
A: [
|
|
2196
|
+
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2197
|
+
""
|
|
2198
|
+
]
|
|
2199
|
+
});
|
|
1778
2200
|
await (0, import_feed_store2.writeMessages)(space.inner.controlPipeline.writer, credentials);
|
|
1779
2201
|
return {
|
|
1780
2202
|
space: {
|
|
@@ -1802,11 +2224,35 @@ var SpaceInvitationProtocol = class {
|
|
|
1802
2224
|
};
|
|
1803
2225
|
}
|
|
1804
2226
|
async accept(response) {
|
|
1805
|
-
(0,
|
|
2227
|
+
(0, import_invariant9.invariant)(response.space, void 0, {
|
|
2228
|
+
F: __dxlog_file10,
|
|
2229
|
+
L: 97,
|
|
2230
|
+
S: this,
|
|
2231
|
+
A: [
|
|
2232
|
+
"response.space",
|
|
2233
|
+
""
|
|
2234
|
+
]
|
|
2235
|
+
});
|
|
1806
2236
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
1807
|
-
const assertion = (0,
|
|
1808
|
-
(0,
|
|
1809
|
-
|
|
2237
|
+
const assertion = (0, import_credentials10.getCredentialAssertion)(credential);
|
|
2238
|
+
(0, import_invariant9.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2239
|
+
F: __dxlog_file10,
|
|
2240
|
+
L: 100,
|
|
2241
|
+
S: this,
|
|
2242
|
+
A: [
|
|
2243
|
+
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2244
|
+
"'Invalid credential'"
|
|
2245
|
+
]
|
|
2246
|
+
});
|
|
2247
|
+
(0, import_invariant9.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2248
|
+
F: __dxlog_file10,
|
|
2249
|
+
L: 101,
|
|
2250
|
+
S: this,
|
|
2251
|
+
A: [
|
|
2252
|
+
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
2253
|
+
""
|
|
2254
|
+
]
|
|
2255
|
+
});
|
|
1810
2256
|
await this._spaceManager.acceptSpace({
|
|
1811
2257
|
spaceKey: assertion.spaceKey,
|
|
1812
2258
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -1821,48 +2267,48 @@ var SpaceInvitationProtocol = class {
|
|
|
1821
2267
|
};
|
|
1822
2268
|
|
|
1823
2269
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
1824
|
-
var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
|
|
1825
2270
|
var import_async9 = require("@dxos/async");
|
|
1826
|
-
var
|
|
1827
|
-
var
|
|
2271
|
+
var import_context7 = require("@dxos/context");
|
|
2272
|
+
var import_credentials14 = require("@dxos/credentials");
|
|
2273
|
+
var import_invariant11 = require("@dxos/invariant");
|
|
1828
2274
|
var import_keys7 = require("@dxos/keys");
|
|
1829
|
-
var
|
|
1830
|
-
var
|
|
1831
|
-
var
|
|
2275
|
+
var import_log11 = require("@dxos/log");
|
|
2276
|
+
var import_protocols7 = require("@dxos/protocols");
|
|
2277
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1832
2278
|
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
1833
2279
|
var import_util4 = require("@dxos/util");
|
|
1834
2280
|
|
|
1835
2281
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
1836
2282
|
var import_async8 = require("@dxos/async");
|
|
1837
2283
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
1838
|
-
var
|
|
2284
|
+
var import_context6 = require("@dxos/context");
|
|
1839
2285
|
var import_debug4 = require("@dxos/debug");
|
|
1840
2286
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
1841
2287
|
var import_errors3 = require("@dxos/errors");
|
|
1842
2288
|
var import_keys6 = require("@dxos/keys");
|
|
1843
|
-
var
|
|
1844
|
-
var
|
|
1845
|
-
var
|
|
2289
|
+
var import_log10 = require("@dxos/log");
|
|
2290
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2291
|
+
var import_credentials11 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
1846
2292
|
var import_timeframe = require("@dxos/timeframe");
|
|
1847
2293
|
var import_util3 = require("@dxos/util");
|
|
1848
2294
|
|
|
1849
2295
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
1850
|
-
var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
|
|
1851
2296
|
var import_async7 = require("@dxos/async");
|
|
1852
|
-
var
|
|
2297
|
+
var import_context5 = require("@dxos/context");
|
|
2298
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
1853
2299
|
var import_keys5 = require("@dxos/keys");
|
|
1854
|
-
var
|
|
1855
|
-
var
|
|
2300
|
+
var import_log9 = require("@dxos/log");
|
|
2301
|
+
var import_protocols6 = require("@dxos/protocols");
|
|
1856
2302
|
var import_teleport2 = require("@dxos/teleport");
|
|
1857
2303
|
var import_util2 = require("@dxos/util");
|
|
1858
|
-
var
|
|
2304
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
1859
2305
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
1860
2306
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
1861
2307
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
1862
2308
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
1863
2309
|
var NotarizationPlugin = class {
|
|
1864
2310
|
constructor() {
|
|
1865
|
-
this._ctx = new
|
|
2311
|
+
this._ctx = new import_context5.Context();
|
|
1866
2312
|
this._extensionOpened = new import_async7.Event();
|
|
1867
2313
|
this._extensions = /* @__PURE__ */ new Set();
|
|
1868
2314
|
this._processedCredentials = new import_util2.ComplexSet(import_keys5.PublicKey.hash);
|
|
@@ -1880,23 +2326,31 @@ var NotarizationPlugin = class {
|
|
|
1880
2326
|
* Request credentials to be notarized.
|
|
1881
2327
|
*/
|
|
1882
2328
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
1883
|
-
(0,
|
|
2329
|
+
(0, import_log9.log)("notarize", {
|
|
1884
2330
|
credentials
|
|
1885
2331
|
}, {
|
|
1886
|
-
F:
|
|
1887
|
-
L:
|
|
2332
|
+
F: __dxlog_file11,
|
|
2333
|
+
L: 90,
|
|
1888
2334
|
S: this,
|
|
1889
2335
|
C: (f, a) => f(...a)
|
|
1890
2336
|
});
|
|
1891
|
-
(0,
|
|
2337
|
+
(0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
2338
|
+
F: __dxlog_file11,
|
|
2339
|
+
L: 91,
|
|
2340
|
+
S: this,
|
|
2341
|
+
A: [
|
|
2342
|
+
"credentials.every((credential) => credential.id)",
|
|
2343
|
+
"'Credentials must have an id'"
|
|
2344
|
+
]
|
|
2345
|
+
});
|
|
1892
2346
|
const errors = new import_async7.Trigger();
|
|
1893
2347
|
const ctx = this._ctx.derive({
|
|
1894
2348
|
onError: (err) => {
|
|
1895
|
-
|
|
2349
|
+
import_log9.log.warn("Notarization error", {
|
|
1896
2350
|
err
|
|
1897
2351
|
}, {
|
|
1898
|
-
F:
|
|
1899
|
-
L:
|
|
2352
|
+
F: __dxlog_file11,
|
|
2353
|
+
L: 99,
|
|
1900
2354
|
S: this,
|
|
1901
2355
|
C: (f, a) => f(...a)
|
|
1902
2356
|
});
|
|
@@ -1907,12 +2361,12 @@ var NotarizationPlugin = class {
|
|
|
1907
2361
|
opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
|
|
1908
2362
|
if (timeout !== 0) {
|
|
1909
2363
|
(0, import_async7.scheduleTask)(ctx, () => {
|
|
1910
|
-
|
|
2364
|
+
import_log9.log.warn("Notarization timeout", {
|
|
1911
2365
|
timeout,
|
|
1912
2366
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
1913
2367
|
}, {
|
|
1914
|
-
F:
|
|
1915
|
-
L:
|
|
2368
|
+
F: __dxlog_file11,
|
|
2369
|
+
L: 111,
|
|
1916
2370
|
S: this,
|
|
1917
2371
|
C: (f, a) => f(...a)
|
|
1918
2372
|
});
|
|
@@ -1931,11 +2385,11 @@ var NotarizationPlugin = class {
|
|
|
1931
2385
|
...this._extensions
|
|
1932
2386
|
].find((peer2) => !peersTried.has(peer2));
|
|
1933
2387
|
if (!peer) {
|
|
1934
|
-
|
|
2388
|
+
import_log9.log.warn("Exhausted all peers to notarize with", {
|
|
1935
2389
|
retryIn: retryTimeout
|
|
1936
2390
|
}, {
|
|
1937
|
-
F:
|
|
1938
|
-
L:
|
|
2391
|
+
F: __dxlog_file11,
|
|
2392
|
+
L: 136,
|
|
1939
2393
|
S: this,
|
|
1940
2394
|
C: (f, a) => f(...a)
|
|
1941
2395
|
});
|
|
@@ -1944,30 +2398,30 @@ var NotarizationPlugin = class {
|
|
|
1944
2398
|
return;
|
|
1945
2399
|
}
|
|
1946
2400
|
peersTried.add(peer);
|
|
1947
|
-
(0,
|
|
2401
|
+
(0, import_log9.log)("try notarizing", {
|
|
1948
2402
|
peer: peer.localPeerId,
|
|
1949
2403
|
credentialId: credentials.map((credential) => credential.id)
|
|
1950
2404
|
}, {
|
|
1951
|
-
F:
|
|
1952
|
-
L:
|
|
2405
|
+
F: __dxlog_file11,
|
|
2406
|
+
L: 143,
|
|
1953
2407
|
S: this,
|
|
1954
2408
|
C: (f, a) => f(...a)
|
|
1955
2409
|
});
|
|
1956
2410
|
await peer.rpc.NotarizationService.notarize({
|
|
1957
2411
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
1958
2412
|
});
|
|
1959
|
-
(0,
|
|
1960
|
-
F:
|
|
1961
|
-
L:
|
|
2413
|
+
(0, import_log9.log)("success", void 0, {
|
|
2414
|
+
F: __dxlog_file11,
|
|
2415
|
+
L: 147,
|
|
1962
2416
|
S: this,
|
|
1963
2417
|
C: (f, a) => f(...a)
|
|
1964
2418
|
});
|
|
1965
2419
|
await (0, import_async7.sleep)(successDelay);
|
|
1966
2420
|
} catch (err) {
|
|
1967
2421
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
1968
|
-
|
|
1969
|
-
F:
|
|
1970
|
-
L:
|
|
2422
|
+
import_log9.log.warn("error notarizing (recoverable)", err, {
|
|
2423
|
+
F: __dxlog_file11,
|
|
2424
|
+
L: 151,
|
|
1971
2425
|
S: this,
|
|
1972
2426
|
C: (f, a) => f(...a)
|
|
1973
2427
|
});
|
|
@@ -1979,13 +2433,13 @@ var NotarizationPlugin = class {
|
|
|
1979
2433
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
1980
2434
|
try {
|
|
1981
2435
|
await Promise.race([
|
|
1982
|
-
(0,
|
|
2436
|
+
(0, import_context5.rejectOnDispose)(ctx),
|
|
1983
2437
|
allNotarized,
|
|
1984
2438
|
errors.wait()
|
|
1985
2439
|
]);
|
|
1986
|
-
(0,
|
|
1987
|
-
F:
|
|
1988
|
-
L:
|
|
2440
|
+
(0, import_log9.log)("done", void 0, {
|
|
2441
|
+
F: __dxlog_file11,
|
|
2442
|
+
L: 162,
|
|
1989
2443
|
S: this,
|
|
1990
2444
|
C: (f, a) => f(...a)
|
|
1991
2445
|
});
|
|
@@ -2006,7 +2460,15 @@ var NotarizationPlugin = class {
|
|
|
2006
2460
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2007
2461
|
}
|
|
2008
2462
|
setWriter(writer) {
|
|
2009
|
-
(0,
|
|
2463
|
+
(0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
|
|
2464
|
+
F: __dxlog_file11,
|
|
2465
|
+
L: 181,
|
|
2466
|
+
S: this,
|
|
2467
|
+
A: [
|
|
2468
|
+
"!this._writer",
|
|
2469
|
+
"'Writer already set.'"
|
|
2470
|
+
]
|
|
2471
|
+
});
|
|
2010
2472
|
this._writer = writer;
|
|
2011
2473
|
}
|
|
2012
2474
|
async _waitUntilProcessed(id) {
|
|
@@ -2024,7 +2486,15 @@ var NotarizationPlugin = class {
|
|
|
2024
2486
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2025
2487
|
}
|
|
2026
2488
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2027
|
-
(0,
|
|
2489
|
+
(0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
|
|
2490
|
+
F: __dxlog_file11,
|
|
2491
|
+
L: 200,
|
|
2492
|
+
S: this,
|
|
2493
|
+
A: [
|
|
2494
|
+
"credential.id",
|
|
2495
|
+
"'Credential must have an id'"
|
|
2496
|
+
]
|
|
2497
|
+
});
|
|
2028
2498
|
if (this._processedCredentials.has(credential.id)) {
|
|
2029
2499
|
continue;
|
|
2030
2500
|
}
|
|
@@ -2034,11 +2504,11 @@ var NotarizationPlugin = class {
|
|
|
2034
2504
|
createExtension() {
|
|
2035
2505
|
const extension = new NotarizationTeleportExtension({
|
|
2036
2506
|
onOpen: async () => {
|
|
2037
|
-
(0,
|
|
2507
|
+
(0, import_log9.log)("extension opened", {
|
|
2038
2508
|
peer: extension.localPeerId
|
|
2039
2509
|
}, {
|
|
2040
|
-
F:
|
|
2041
|
-
L:
|
|
2510
|
+
F: __dxlog_file11,
|
|
2511
|
+
L: 211,
|
|
2042
2512
|
S: this,
|
|
2043
2513
|
C: (f, a) => f(...a)
|
|
2044
2514
|
});
|
|
@@ -2046,11 +2516,11 @@ var NotarizationPlugin = class {
|
|
|
2046
2516
|
this._extensionOpened.emit();
|
|
2047
2517
|
},
|
|
2048
2518
|
onClose: async () => {
|
|
2049
|
-
(0,
|
|
2519
|
+
(0, import_log9.log)("extension closed", {
|
|
2050
2520
|
peer: extension.localPeerId
|
|
2051
2521
|
}, {
|
|
2052
|
-
F:
|
|
2053
|
-
L:
|
|
2522
|
+
F: __dxlog_file11,
|
|
2523
|
+
L: 216,
|
|
2054
2524
|
S: this,
|
|
2055
2525
|
C: (f, a) => f(...a)
|
|
2056
2526
|
});
|
|
@@ -2065,10 +2535,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
2065
2535
|
constructor(_params) {
|
|
2066
2536
|
super({
|
|
2067
2537
|
requested: {
|
|
2068
|
-
NotarizationService:
|
|
2538
|
+
NotarizationService: import_protocols6.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2069
2539
|
},
|
|
2070
2540
|
exposed: {
|
|
2071
|
-
NotarizationService:
|
|
2541
|
+
NotarizationService: import_protocols6.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2072
2542
|
}
|
|
2073
2543
|
});
|
|
2074
2544
|
this._params = _params;
|
|
@@ -2093,7 +2563,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
2093
2563
|
};
|
|
2094
2564
|
|
|
2095
2565
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2096
|
-
function
|
|
2566
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
2097
2567
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2098
2568
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2099
2569
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2103,12 +2573,12 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
2103
2573
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2104
2574
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2105
2575
|
}
|
|
2106
|
-
var
|
|
2576
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2107
2577
|
var DataSpace = class DataSpace2 {
|
|
2108
2578
|
constructor(params) {
|
|
2109
|
-
this._ctx = new
|
|
2579
|
+
this._ctx = new import_context6.Context();
|
|
2110
2580
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
2111
|
-
this._state =
|
|
2581
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
2112
2582
|
/**
|
|
2113
2583
|
* Error for _state === SpaceState.ERROR.
|
|
2114
2584
|
*/
|
|
@@ -2164,8 +2634,8 @@ var DataSpace = class DataSpace2 {
|
|
|
2164
2634
|
async _open() {
|
|
2165
2635
|
await this._notarizationPlugin.open();
|
|
2166
2636
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2167
|
-
await this._inner.open();
|
|
2168
|
-
this._state =
|
|
2637
|
+
await this._inner.open(new import_context6.Context());
|
|
2638
|
+
this._state = import_services7.SpaceState.CONTROL_ONLY;
|
|
2169
2639
|
this.stateUpdate.emit();
|
|
2170
2640
|
this.metrics = {};
|
|
2171
2641
|
this.metrics.open = new Date();
|
|
@@ -2176,9 +2646,9 @@ var DataSpace = class DataSpace2 {
|
|
|
2176
2646
|
async _close() {
|
|
2177
2647
|
var _a, _b;
|
|
2178
2648
|
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
2179
|
-
this._state =
|
|
2649
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
2180
2650
|
await this._ctx.dispose();
|
|
2181
|
-
this._ctx = new
|
|
2651
|
+
this._ctx = new import_context6.Context();
|
|
2182
2652
|
await this.authVerifier.close();
|
|
2183
2653
|
await this._inner.close();
|
|
2184
2654
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
@@ -2201,21 +2671,21 @@ var DataSpace = class DataSpace2 {
|
|
|
2201
2671
|
await this.initializeDataPipeline();
|
|
2202
2672
|
} catch (err) {
|
|
2203
2673
|
if (err instanceof import_errors3.CancelledError) {
|
|
2204
|
-
(0,
|
|
2205
|
-
F:
|
|
2674
|
+
(0, import_log10.log)("data pipeline initialization cancelled", err, {
|
|
2675
|
+
F: __dxlog_file12,
|
|
2206
2676
|
L: 193,
|
|
2207
2677
|
S: this,
|
|
2208
2678
|
C: (f, a) => f(...a)
|
|
2209
2679
|
});
|
|
2210
2680
|
return;
|
|
2211
2681
|
}
|
|
2212
|
-
|
|
2213
|
-
F:
|
|
2682
|
+
import_log10.log.error("Error initializing data pipeline", err, {
|
|
2683
|
+
F: __dxlog_file12,
|
|
2214
2684
|
L: 197,
|
|
2215
2685
|
S: this,
|
|
2216
2686
|
C: (f, a) => f(...a)
|
|
2217
2687
|
});
|
|
2218
|
-
this._state =
|
|
2688
|
+
this._state = import_services7.SpaceState.ERROR;
|
|
2219
2689
|
this.error = err;
|
|
2220
2690
|
this.stateUpdate.emit();
|
|
2221
2691
|
} finally {
|
|
@@ -2225,18 +2695,18 @@ var DataSpace = class DataSpace2 {
|
|
|
2225
2695
|
}
|
|
2226
2696
|
async initializeDataPipeline() {
|
|
2227
2697
|
var _a, _b, _c, _d;
|
|
2228
|
-
if (this._state !==
|
|
2698
|
+
if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
|
|
2229
2699
|
throw new import_errors3.SystemError("Invalid operation");
|
|
2230
2700
|
}
|
|
2231
|
-
this._state =
|
|
2701
|
+
this._state = import_services7.SpaceState.INITIALIZING;
|
|
2232
2702
|
await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
2233
2703
|
ctx: this._ctx,
|
|
2234
2704
|
breakOnStall: false
|
|
2235
2705
|
});
|
|
2236
2706
|
this.metrics.controlPipelineReady = new Date();
|
|
2237
2707
|
await this._createWritableFeeds();
|
|
2238
|
-
(0,
|
|
2239
|
-
F:
|
|
2708
|
+
(0, import_log10.log)("writable feeds created", void 0, {
|
|
2709
|
+
F: __dxlog_file12,
|
|
2240
2710
|
L: 221,
|
|
2241
2711
|
S: this,
|
|
2242
2712
|
C: (f, a) => f(...a)
|
|
@@ -2251,9 +2721,9 @@ var DataSpace = class DataSpace2 {
|
|
|
2251
2721
|
}
|
|
2252
2722
|
await this._inner.initializeDataPipeline();
|
|
2253
2723
|
this.metrics.dataPipelineOpen = new Date();
|
|
2254
|
-
await (0,
|
|
2255
|
-
(0,
|
|
2256
|
-
F:
|
|
2724
|
+
await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2725
|
+
(0, import_log10.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
2726
|
+
F: __dxlog_file12,
|
|
2257
2727
|
L: 242,
|
|
2258
2728
|
S: this,
|
|
2259
2729
|
C: (f, a) => f(...a)
|
|
@@ -2263,14 +2733,14 @@ var DataSpace = class DataSpace2 {
|
|
|
2263
2733
|
breakOnStall: false
|
|
2264
2734
|
});
|
|
2265
2735
|
this.metrics.dataPipelineReady = new Date();
|
|
2266
|
-
(0,
|
|
2267
|
-
F:
|
|
2736
|
+
(0, import_log10.log)("data pipeline ready", void 0, {
|
|
2737
|
+
F: __dxlog_file12,
|
|
2268
2738
|
L: 251,
|
|
2269
2739
|
S: this,
|
|
2270
2740
|
C: (f, a) => f(...a)
|
|
2271
2741
|
});
|
|
2272
2742
|
await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
|
|
2273
|
-
this._state =
|
|
2743
|
+
this._state = import_services7.SpaceState.READY;
|
|
2274
2744
|
this.stateUpdate.emit();
|
|
2275
2745
|
await ((_d = (_c = this._callbacks).afterReady) == null ? void 0 : _d.call(_c));
|
|
2276
2746
|
}
|
|
@@ -2288,7 +2758,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2288
2758
|
spaceKey: this.key,
|
|
2289
2759
|
deviceKey: this._signingContext.deviceKey,
|
|
2290
2760
|
identityKey: this._signingContext.identityKey,
|
|
2291
|
-
designation:
|
|
2761
|
+
designation: import_credentials11.AdmittedFeed.Designation.CONTROL
|
|
2292
2762
|
}
|
|
2293
2763
|
}));
|
|
2294
2764
|
}
|
|
@@ -2305,7 +2775,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2305
2775
|
spaceKey: this.key,
|
|
2306
2776
|
deviceKey: this._signingContext.deviceKey,
|
|
2307
2777
|
identityKey: this._signingContext.identityKey,
|
|
2308
|
-
designation:
|
|
2778
|
+
designation: import_credentials11.AdmittedFeed.Designation.DATA
|
|
2309
2779
|
}
|
|
2310
2780
|
}));
|
|
2311
2781
|
}
|
|
@@ -2346,51 +2816,51 @@ var DataSpace = class DataSpace2 {
|
|
|
2346
2816
|
}
|
|
2347
2817
|
}
|
|
2348
2818
|
async activate() {
|
|
2349
|
-
if (this._state !==
|
|
2819
|
+
if (this._state !== import_services7.SpaceState.INACTIVE) {
|
|
2350
2820
|
return;
|
|
2351
2821
|
}
|
|
2352
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
2822
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
|
|
2353
2823
|
await this._open();
|
|
2354
2824
|
this.initializeDataPipelineAsync();
|
|
2355
2825
|
}
|
|
2356
2826
|
async deactivate() {
|
|
2357
|
-
if (this._state ===
|
|
2827
|
+
if (this._state === import_services7.SpaceState.INACTIVE) {
|
|
2358
2828
|
return;
|
|
2359
2829
|
}
|
|
2360
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
2830
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
|
|
2361
2831
|
await this._close();
|
|
2362
|
-
this._state =
|
|
2832
|
+
this._state = import_services7.SpaceState.INACTIVE;
|
|
2363
2833
|
this.stateUpdate.emit();
|
|
2364
2834
|
}
|
|
2365
2835
|
};
|
|
2366
|
-
|
|
2836
|
+
_ts_decorate3([
|
|
2367
2837
|
import_async8.synchronized
|
|
2368
2838
|
], DataSpace.prototype, "open", null);
|
|
2369
|
-
|
|
2839
|
+
_ts_decorate3([
|
|
2370
2840
|
import_async8.synchronized
|
|
2371
2841
|
], DataSpace.prototype, "close", null);
|
|
2372
|
-
|
|
2842
|
+
_ts_decorate3([
|
|
2373
2843
|
(0, import_debug4.timed)(1e4)
|
|
2374
2844
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2375
|
-
|
|
2845
|
+
_ts_decorate3([
|
|
2376
2846
|
import_async8.synchronized
|
|
2377
2847
|
], DataSpace.prototype, "activate", null);
|
|
2378
|
-
|
|
2848
|
+
_ts_decorate3([
|
|
2379
2849
|
import_async8.synchronized
|
|
2380
2850
|
], DataSpace.prototype, "deactivate", null);
|
|
2381
|
-
DataSpace =
|
|
2851
|
+
DataSpace = _ts_decorate3([
|
|
2382
2852
|
(0, import_async8.trackLeaks)("open", "close")
|
|
2383
2853
|
], DataSpace);
|
|
2384
2854
|
|
|
2385
2855
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
2386
|
-
var
|
|
2856
|
+
var import_credentials12 = require("@dxos/credentials");
|
|
2387
2857
|
var import_debug5 = require("@dxos/debug");
|
|
2388
|
-
var
|
|
2858
|
+
var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2389
2859
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
2390
2860
|
var spaceGenesis = async (keyring, signingContext, space) => {
|
|
2391
2861
|
var _a, _b, _c, _d;
|
|
2392
2862
|
const credentials = [
|
|
2393
|
-
await (0,
|
|
2863
|
+
await (0, import_credentials12.createCredential)({
|
|
2394
2864
|
signer: keyring,
|
|
2395
2865
|
issuer: space.key,
|
|
2396
2866
|
subject: space.key,
|
|
@@ -2399,14 +2869,14 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2399
2869
|
spaceKey: space.key
|
|
2400
2870
|
}
|
|
2401
2871
|
}),
|
|
2402
|
-
await (0,
|
|
2872
|
+
await (0, import_credentials12.createCredential)({
|
|
2403
2873
|
signer: keyring,
|
|
2404
2874
|
issuer: space.key,
|
|
2405
2875
|
subject: signingContext.identityKey,
|
|
2406
2876
|
assertion: {
|
|
2407
2877
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
2408
2878
|
spaceKey: space.key,
|
|
2409
|
-
role:
|
|
2879
|
+
role: import_credentials13.SpaceMember.Role.ADMIN,
|
|
2410
2880
|
profile: signingContext.profile,
|
|
2411
2881
|
genesisFeedKey: (_a = space.controlFeedKey) != null ? _a : (0, import_debug5.failUndefined)()
|
|
2412
2882
|
}
|
|
@@ -2418,7 +2888,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2418
2888
|
spaceKey: space.key,
|
|
2419
2889
|
identityKey: signingContext.identityKey,
|
|
2420
2890
|
deviceKey: signingContext.deviceKey,
|
|
2421
|
-
designation:
|
|
2891
|
+
designation: import_credentials13.AdmittedFeed.Designation.CONTROL
|
|
2422
2892
|
}
|
|
2423
2893
|
}),
|
|
2424
2894
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -2428,7 +2898,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2428
2898
|
spaceKey: space.key,
|
|
2429
2899
|
identityKey: signingContext.identityKey,
|
|
2430
2900
|
deviceKey: signingContext.deviceKey,
|
|
2431
|
-
designation:
|
|
2901
|
+
designation: import_credentials13.AdmittedFeed.Designation.DATA
|
|
2432
2902
|
}
|
|
2433
2903
|
}),
|
|
2434
2904
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -2453,7 +2923,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2453
2923
|
};
|
|
2454
2924
|
|
|
2455
2925
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2456
|
-
function
|
|
2926
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
2457
2927
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2458
2928
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2459
2929
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2463,7 +2933,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
2463
2933
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2464
2934
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2465
2935
|
}
|
|
2466
|
-
var
|
|
2936
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
2467
2937
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
2468
2938
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
2469
2939
|
this._spaceManager = _spaceManager;
|
|
@@ -2472,7 +2942,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2472
2942
|
this._keyring = _keyring;
|
|
2473
2943
|
this._signingContext = _signingContext;
|
|
2474
2944
|
this._feedStore = _feedStore;
|
|
2475
|
-
this._ctx = new
|
|
2945
|
+
this._ctx = new import_context7.Context();
|
|
2476
2946
|
this.updated = new import_async9.Event();
|
|
2477
2947
|
this._spaces = new import_util4.ComplexMap(import_keys7.PublicKey.hash);
|
|
2478
2948
|
this._isOpen = false;
|
|
@@ -2483,50 +2953,50 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2483
2953
|
return this._spaces;
|
|
2484
2954
|
}
|
|
2485
2955
|
async open() {
|
|
2486
|
-
(0,
|
|
2487
|
-
F:
|
|
2488
|
-
L:
|
|
2956
|
+
(0, import_log11.log)("open", void 0, {
|
|
2957
|
+
F: __dxlog_file13,
|
|
2958
|
+
L: 79,
|
|
2489
2959
|
S: this,
|
|
2490
2960
|
C: (f, a) => f(...a)
|
|
2491
2961
|
});
|
|
2492
|
-
|
|
2962
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols7.trace.begin({
|
|
2493
2963
|
id: this._instanceId
|
|
2494
2964
|
}), {
|
|
2495
|
-
F:
|
|
2496
|
-
L:
|
|
2965
|
+
F: __dxlog_file13,
|
|
2966
|
+
L: 80,
|
|
2497
2967
|
S: this,
|
|
2498
2968
|
C: (f, a) => f(...a)
|
|
2499
2969
|
});
|
|
2500
2970
|
await this._metadataStore.load();
|
|
2501
|
-
(0,
|
|
2971
|
+
(0, import_log11.log)("metadata loaded", {
|
|
2502
2972
|
spaces: this._metadataStore.spaces.length
|
|
2503
2973
|
}, {
|
|
2504
|
-
F:
|
|
2505
|
-
L:
|
|
2974
|
+
F: __dxlog_file13,
|
|
2975
|
+
L: 82,
|
|
2506
2976
|
S: this,
|
|
2507
2977
|
C: (f, a) => f(...a)
|
|
2508
2978
|
});
|
|
2509
2979
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2510
2980
|
try {
|
|
2511
|
-
(0,
|
|
2981
|
+
(0, import_log11.log)("load space", {
|
|
2512
2982
|
spaceMetadata
|
|
2513
2983
|
}, {
|
|
2514
|
-
F:
|
|
2515
|
-
L:
|
|
2984
|
+
F: __dxlog_file13,
|
|
2985
|
+
L: 86,
|
|
2516
2986
|
S: this,
|
|
2517
2987
|
C: (f, a) => f(...a)
|
|
2518
2988
|
});
|
|
2519
2989
|
const space = await this._constructSpace(spaceMetadata);
|
|
2520
|
-
if (spaceMetadata.state !==
|
|
2990
|
+
if (spaceMetadata.state !== import_services8.SpaceState.INACTIVE) {
|
|
2521
2991
|
space.initializeDataPipelineAsync();
|
|
2522
2992
|
}
|
|
2523
2993
|
} catch (err) {
|
|
2524
|
-
|
|
2994
|
+
import_log11.log.error("Error loading space", {
|
|
2525
2995
|
spaceMetadata,
|
|
2526
2996
|
err
|
|
2527
2997
|
}, {
|
|
2528
|
-
F:
|
|
2529
|
-
L:
|
|
2998
|
+
F: __dxlog_file13,
|
|
2999
|
+
L: 92,
|
|
2530
3000
|
S: this,
|
|
2531
3001
|
C: (f, a) => f(...a)
|
|
2532
3002
|
});
|
|
@@ -2534,19 +3004,19 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2534
3004
|
}
|
|
2535
3005
|
this._isOpen = true;
|
|
2536
3006
|
this.updated.emit();
|
|
2537
|
-
|
|
3007
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols7.trace.end({
|
|
2538
3008
|
id: this._instanceId
|
|
2539
3009
|
}), {
|
|
2540
|
-
F:
|
|
2541
|
-
L:
|
|
3010
|
+
F: __dxlog_file13,
|
|
3011
|
+
L: 98,
|
|
2542
3012
|
S: this,
|
|
2543
3013
|
C: (f, a) => f(...a)
|
|
2544
3014
|
});
|
|
2545
3015
|
}
|
|
2546
3016
|
async close() {
|
|
2547
|
-
(0,
|
|
2548
|
-
F:
|
|
2549
|
-
L:
|
|
3017
|
+
(0, import_log11.log)("close", void 0, {
|
|
3018
|
+
F: __dxlog_file13,
|
|
3019
|
+
L: 103,
|
|
2550
3020
|
S: this,
|
|
2551
3021
|
C: (f, a) => f(...a)
|
|
2552
3022
|
});
|
|
@@ -2560,7 +3030,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2560
3030
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
2561
3031
|
*/
|
|
2562
3032
|
async createSpace() {
|
|
2563
|
-
(0,
|
|
3033
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3034
|
+
F: __dxlog_file13,
|
|
3035
|
+
L: 116,
|
|
3036
|
+
S: this,
|
|
3037
|
+
A: [
|
|
3038
|
+
"this._isOpen",
|
|
3039
|
+
"'Not open.'"
|
|
3040
|
+
]
|
|
3041
|
+
});
|
|
2564
3042
|
const spaceKey = await this._keyring.createKey();
|
|
2565
3043
|
const controlFeedKey = await this._keyring.createKey();
|
|
2566
3044
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -2569,13 +3047,13 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2569
3047
|
genesisFeedKey: controlFeedKey,
|
|
2570
3048
|
controlFeedKey,
|
|
2571
3049
|
dataFeedKey,
|
|
2572
|
-
state:
|
|
3050
|
+
state: import_services8.SpaceState.ACTIVE
|
|
2573
3051
|
};
|
|
2574
|
-
(0,
|
|
3052
|
+
(0, import_log11.log)("creating space...", {
|
|
2575
3053
|
spaceKey
|
|
2576
3054
|
}, {
|
|
2577
|
-
F:
|
|
2578
|
-
L:
|
|
3055
|
+
F: __dxlog_file13,
|
|
3056
|
+
L: 128,
|
|
2579
3057
|
S: this,
|
|
2580
3058
|
C: (f, a) => f(...a)
|
|
2581
3059
|
});
|
|
@@ -2583,7 +3061,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2583
3061
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2584
3062
|
await this._metadataStore.addSpace(metadata);
|
|
2585
3063
|
const memberCredential = credentials[1];
|
|
2586
|
-
(0,
|
|
3064
|
+
(0, import_invariant11.invariant)((0, import_credentials14.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3065
|
+
F: __dxlog_file13,
|
|
3066
|
+
L: 135,
|
|
3067
|
+
S: this,
|
|
3068
|
+
A: [
|
|
3069
|
+
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
3070
|
+
""
|
|
3071
|
+
]
|
|
3072
|
+
});
|
|
2587
3073
|
await this._signingContext.recordCredential(memberCredential);
|
|
2588
3074
|
await space.initializeDataPipeline();
|
|
2589
3075
|
this.updated.emit();
|
|
@@ -2591,16 +3077,32 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2591
3077
|
}
|
|
2592
3078
|
// TODO(burdon): Rename join space.
|
|
2593
3079
|
async acceptSpace(opts) {
|
|
2594
|
-
(0,
|
|
3080
|
+
(0, import_log11.log)("accept space", {
|
|
2595
3081
|
opts
|
|
2596
3082
|
}, {
|
|
2597
|
-
F:
|
|
2598
|
-
L:
|
|
3083
|
+
F: __dxlog_file13,
|
|
3084
|
+
L: 147,
|
|
2599
3085
|
S: this,
|
|
2600
3086
|
C: (f, a) => f(...a)
|
|
2601
3087
|
});
|
|
2602
|
-
(0,
|
|
2603
|
-
|
|
3088
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3089
|
+
F: __dxlog_file13,
|
|
3090
|
+
L: 148,
|
|
3091
|
+
S: this,
|
|
3092
|
+
A: [
|
|
3093
|
+
"this._isOpen",
|
|
3094
|
+
"'Not open.'"
|
|
3095
|
+
]
|
|
3096
|
+
});
|
|
3097
|
+
(0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3098
|
+
F: __dxlog_file13,
|
|
3099
|
+
L: 149,
|
|
3100
|
+
S: this,
|
|
3101
|
+
A: [
|
|
3102
|
+
"!this._spaces.has(opts.spaceKey)",
|
|
3103
|
+
"'Space already exists.'"
|
|
3104
|
+
]
|
|
3105
|
+
});
|
|
2604
3106
|
const metadata = {
|
|
2605
3107
|
key: opts.spaceKey,
|
|
2606
3108
|
genesisFeedKey: opts.genesisFeedKey,
|
|
@@ -2619,17 +3121,17 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2619
3121
|
* TODO(dmaretskyi): Consider removing.
|
|
2620
3122
|
*/
|
|
2621
3123
|
async waitUntilSpaceReady(spaceKey) {
|
|
2622
|
-
await (0,
|
|
3124
|
+
await (0, import_context7.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
2623
3125
|
const space = this._spaces.get(spaceKey);
|
|
2624
|
-
return !!space && space.state ===
|
|
3126
|
+
return !!space && space.state === import_services8.SpaceState.READY;
|
|
2625
3127
|
}));
|
|
2626
3128
|
}
|
|
2627
3129
|
async _constructSpace(metadata) {
|
|
2628
|
-
(0,
|
|
3130
|
+
(0, import_log11.log)("construct space", {
|
|
2629
3131
|
metadata
|
|
2630
3132
|
}, {
|
|
2631
|
-
F:
|
|
2632
|
-
L:
|
|
3133
|
+
F: __dxlog_file13,
|
|
3134
|
+
L: 182,
|
|
2633
3135
|
S: this,
|
|
2634
3136
|
C: (f, a) => f(...a)
|
|
2635
3137
|
});
|
|
@@ -2637,7 +3139,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2637
3139
|
localPeerId: this._signingContext.deviceKey
|
|
2638
3140
|
});
|
|
2639
3141
|
const presence = new import_teleport_extension_gossip.Presence({
|
|
2640
|
-
announceInterval:
|
|
3142
|
+
announceInterval: 1e3,
|
|
2641
3143
|
offlineTimeout: 5e3,
|
|
2642
3144
|
identityKey: this._signingContext.identityKey,
|
|
2643
3145
|
gossip
|
|
@@ -2663,9 +3165,9 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2663
3165
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
2664
3166
|
},
|
|
2665
3167
|
onAuthFailure: () => {
|
|
2666
|
-
|
|
2667
|
-
F:
|
|
2668
|
-
L:
|
|
3168
|
+
import_log11.log.warn("auth failure", void 0, {
|
|
3169
|
+
F: __dxlog_file13,
|
|
3170
|
+
L: 213,
|
|
2669
3171
|
S: this,
|
|
2670
3172
|
C: (f, a) => f(...a)
|
|
2671
3173
|
});
|
|
@@ -2676,7 +3178,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2676
3178
|
dataFeed && space.setDataFeed(dataFeed);
|
|
2677
3179
|
const dataSpace = new DataSpace({
|
|
2678
3180
|
inner: space,
|
|
2679
|
-
initialState: metadata.state ===
|
|
3181
|
+
initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
|
|
2680
3182
|
metadataStore: this._metadataStore,
|
|
2681
3183
|
gossip,
|
|
2682
3184
|
presence,
|
|
@@ -2685,23 +3187,23 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2685
3187
|
signingContext: this._signingContext,
|
|
2686
3188
|
callbacks: {
|
|
2687
3189
|
beforeReady: async () => {
|
|
2688
|
-
(0,
|
|
3190
|
+
(0, import_log11.log)("before space ready", {
|
|
2689
3191
|
space: space.key
|
|
2690
3192
|
}, {
|
|
2691
|
-
F:
|
|
2692
|
-
L:
|
|
3193
|
+
F: __dxlog_file13,
|
|
3194
|
+
L: 231,
|
|
2693
3195
|
S: this,
|
|
2694
3196
|
C: (f, a) => f(...a)
|
|
2695
3197
|
});
|
|
2696
3198
|
await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2697
3199
|
},
|
|
2698
3200
|
afterReady: async () => {
|
|
2699
|
-
(0,
|
|
3201
|
+
(0, import_log11.log)("after space ready", {
|
|
2700
3202
|
space: space.key,
|
|
2701
3203
|
open: this._isOpen
|
|
2702
3204
|
}, {
|
|
2703
|
-
F:
|
|
2704
|
-
L:
|
|
3205
|
+
F: __dxlog_file13,
|
|
3206
|
+
L: 238,
|
|
2705
3207
|
S: this,
|
|
2706
3208
|
C: (f, a) => f(...a)
|
|
2707
3209
|
});
|
|
@@ -2710,11 +3212,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2710
3212
|
}
|
|
2711
3213
|
},
|
|
2712
3214
|
beforeClose: async () => {
|
|
2713
|
-
(0,
|
|
3215
|
+
(0, import_log11.log)("before space close", {
|
|
2714
3216
|
space: space.key
|
|
2715
3217
|
}, {
|
|
2716
|
-
F:
|
|
2717
|
-
L:
|
|
3218
|
+
F: __dxlog_file13,
|
|
3219
|
+
L: 244,
|
|
2718
3220
|
S: this,
|
|
2719
3221
|
C: (f, a) => f(...a)
|
|
2720
3222
|
});
|
|
@@ -2723,7 +3225,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2723
3225
|
},
|
|
2724
3226
|
cache: metadata.cache
|
|
2725
3227
|
});
|
|
2726
|
-
if (metadata.state !==
|
|
3228
|
+
if (metadata.state !== import_services8.SpaceState.INACTIVE) {
|
|
2727
3229
|
await dataSpace.open();
|
|
2728
3230
|
}
|
|
2729
3231
|
if (metadata.controlTimeframe) {
|
|
@@ -2736,33 +3238,33 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2736
3238
|
return dataSpace;
|
|
2737
3239
|
}
|
|
2738
3240
|
};
|
|
2739
|
-
|
|
3241
|
+
_ts_decorate4([
|
|
2740
3242
|
import_async9.synchronized
|
|
2741
3243
|
], DataSpaceManager.prototype, "open", null);
|
|
2742
|
-
|
|
3244
|
+
_ts_decorate4([
|
|
2743
3245
|
import_async9.synchronized
|
|
2744
3246
|
], DataSpaceManager.prototype, "close", null);
|
|
2745
|
-
|
|
3247
|
+
_ts_decorate4([
|
|
2746
3248
|
import_async9.synchronized
|
|
2747
3249
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
2748
|
-
|
|
3250
|
+
_ts_decorate4([
|
|
2749
3251
|
import_async9.synchronized
|
|
2750
3252
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
2751
|
-
DataSpaceManager =
|
|
3253
|
+
DataSpaceManager = _ts_decorate4([
|
|
2752
3254
|
(0, import_async9.trackLeaks)("open", "close")
|
|
2753
3255
|
], DataSpaceManager);
|
|
2754
3256
|
|
|
2755
3257
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
2756
3258
|
var import_async10 = require("@dxos/async");
|
|
2757
|
-
var
|
|
3259
|
+
var import_codec_protobuf5 = require("@dxos/codec-protobuf");
|
|
2758
3260
|
var import_debug6 = require("@dxos/debug");
|
|
2759
3261
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
2760
3262
|
var import_errors4 = require("@dxos/errors");
|
|
2761
|
-
var
|
|
2762
|
-
var
|
|
2763
|
-
var
|
|
3263
|
+
var import_log12 = require("@dxos/log");
|
|
3264
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
3265
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2764
3266
|
var import_util5 = require("@dxos/util");
|
|
2765
|
-
var
|
|
3267
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
2766
3268
|
var SpacesServiceImpl = class {
|
|
2767
3269
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
2768
3270
|
this._identityManager = _identityManager;
|
|
@@ -2784,10 +3286,10 @@ var SpacesServiceImpl = class {
|
|
|
2784
3286
|
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
2785
3287
|
if (state) {
|
|
2786
3288
|
switch (state) {
|
|
2787
|
-
case
|
|
3289
|
+
case import_services9.SpaceState.ACTIVE:
|
|
2788
3290
|
await space.activate();
|
|
2789
3291
|
break;
|
|
2790
|
-
case
|
|
3292
|
+
case import_services9.SpaceState.INACTIVE:
|
|
2791
3293
|
await space.deactivate();
|
|
2792
3294
|
break;
|
|
2793
3295
|
default:
|
|
@@ -2796,14 +3298,14 @@ var SpacesServiceImpl = class {
|
|
|
2796
3298
|
}
|
|
2797
3299
|
}
|
|
2798
3300
|
querySpaces() {
|
|
2799
|
-
return new
|
|
3301
|
+
return new import_codec_protobuf5.Stream(({ next, ctx }) => {
|
|
2800
3302
|
const scheduler = new import_async10.UpdateScheduler(ctx, async () => {
|
|
2801
3303
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2802
3304
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
2803
|
-
(0,
|
|
3305
|
+
(0, import_log12.log)("update", {
|
|
2804
3306
|
spaces
|
|
2805
3307
|
}, {
|
|
2806
|
-
F:
|
|
3308
|
+
F: __dxlog_file14,
|
|
2807
3309
|
L: 78,
|
|
2808
3310
|
S: this,
|
|
2809
3311
|
C: (f, a) => f(...a)
|
|
@@ -2851,7 +3353,7 @@ var SpacesServiceImpl = class {
|
|
|
2851
3353
|
await space.postMessage(getChannelId(channel), message);
|
|
2852
3354
|
}
|
|
2853
3355
|
subscribeMessages({ spaceKey, channel }) {
|
|
2854
|
-
return new
|
|
3356
|
+
return new import_codec_protobuf5.Stream(({ ctx, next }) => {
|
|
2855
3357
|
(0, import_async10.scheduleTask)(ctx, async () => {
|
|
2856
3358
|
var _a;
|
|
2857
3359
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
@@ -2864,7 +3366,7 @@ var SpacesServiceImpl = class {
|
|
|
2864
3366
|
});
|
|
2865
3367
|
}
|
|
2866
3368
|
queryCredentials({ spaceKey }) {
|
|
2867
|
-
return new
|
|
3369
|
+
return new import_codec_protobuf5.Stream(({ ctx, next }) => {
|
|
2868
3370
|
var _a;
|
|
2869
3371
|
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
2870
3372
|
const processor = {
|
|
@@ -2898,7 +3400,7 @@ var SpacesServiceImpl = class {
|
|
|
2898
3400
|
return {
|
|
2899
3401
|
spaceKey: space.key,
|
|
2900
3402
|
state: space.state,
|
|
2901
|
-
error: space.error ? (0,
|
|
3403
|
+
error: space.error ? (0, import_protocols8.encodeError)(space.error) : void 0,
|
|
2902
3404
|
pipeline: {
|
|
2903
3405
|
currentEpoch: space.dataPipeline.currentEpoch,
|
|
2904
3406
|
appliedEpoch: space.dataPipeline.appliedEpoch,
|
|
@@ -2914,14 +3416,20 @@ var SpacesServiceImpl = class {
|
|
|
2914
3416
|
},
|
|
2915
3417
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
2916
3418
|
var _a2, _b2, _c2;
|
|
3419
|
+
const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
|
|
3420
|
+
const isMe = (_a2 = this._identityManager.identity) == null ? void 0 : _a2.identityKey.equals(member.key);
|
|
3421
|
+
if (isMe) {
|
|
3422
|
+
peers.push(space.presence.getLocalState());
|
|
3423
|
+
}
|
|
2917
3424
|
return {
|
|
2918
3425
|
identity: {
|
|
2919
3426
|
identityKey: member.key,
|
|
2920
3427
|
profile: {
|
|
2921
|
-
displayName: (
|
|
3428
|
+
displayName: (_c2 = (_b2 = member.assertion.profile) == null ? void 0 : _b2.displayName) != null ? _c2 : (0, import_util5.humanize)(member.key)
|
|
2922
3429
|
}
|
|
2923
3430
|
},
|
|
2924
|
-
presence:
|
|
3431
|
+
presence: isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
|
|
3432
|
+
peerStates: peers
|
|
2925
3433
|
};
|
|
2926
3434
|
}),
|
|
2927
3435
|
creator: (_g = space.inner.spaceState.creator) == null ? void 0 : _g.key,
|
|
@@ -2933,8 +3441,18 @@ var SpacesServiceImpl = class {
|
|
|
2933
3441
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
2934
3442
|
|
|
2935
3443
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
2936
|
-
|
|
2937
|
-
var
|
|
3444
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
3445
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3446
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3447
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3448
|
+
else
|
|
3449
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3450
|
+
if (d = decorators[i])
|
|
3451
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3452
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3453
|
+
}
|
|
3454
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
3455
|
+
var ServiceContext = class ServiceContext2 {
|
|
2938
3456
|
// prettier-ignore
|
|
2939
3457
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
2940
3458
|
this.storage = storage;
|
|
@@ -2968,54 +3486,54 @@ var ServiceContext = class {
|
|
|
2968
3486
|
});
|
|
2969
3487
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
2970
3488
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
2971
|
-
this._handlerFactories.set(
|
|
3489
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
|
|
2972
3490
|
var _a;
|
|
2973
3491
|
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
|
|
2974
3492
|
}, this._acceptIdentity.bind(this)));
|
|
2975
3493
|
}
|
|
2976
|
-
async open() {
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
L: 126,
|
|
3494
|
+
async open(ctx) {
|
|
3495
|
+
await this._checkStorageVersion();
|
|
3496
|
+
(0, import_log13.log)("opening...", void 0, {
|
|
3497
|
+
F: __dxlog_file15,
|
|
3498
|
+
L: 131,
|
|
2982
3499
|
S: this,
|
|
2983
3500
|
C: (f, a) => f(...a)
|
|
2984
3501
|
});
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
3502
|
+
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.begin({
|
|
3503
|
+
id: this._instanceId
|
|
3504
|
+
}), {
|
|
3505
|
+
F: __dxlog_file15,
|
|
3506
|
+
L: 132,
|
|
2989
3507
|
S: this,
|
|
2990
3508
|
C: (f, a) => f(...a)
|
|
2991
3509
|
});
|
|
2992
3510
|
await this.signalManager.open();
|
|
2993
3511
|
await this.networkManager.open();
|
|
2994
3512
|
await this.spaceManager.open();
|
|
2995
|
-
await this.identityManager.open();
|
|
3513
|
+
await this.identityManager.open(ctx);
|
|
2996
3514
|
if (this.identityManager.identity) {
|
|
2997
|
-
await this._initialize();
|
|
3515
|
+
await this._initialize(ctx);
|
|
2998
3516
|
}
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3517
|
+
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.end({
|
|
3518
|
+
id: this._instanceId
|
|
3519
|
+
}), {
|
|
3520
|
+
F: __dxlog_file15,
|
|
3521
|
+
L: 140,
|
|
3002
3522
|
S: this,
|
|
3003
3523
|
C: (f, a) => f(...a)
|
|
3004
3524
|
});
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
F: __dxlog_file12,
|
|
3009
|
-
L: 139,
|
|
3525
|
+
(0, import_log13.log)("opened", void 0, {
|
|
3526
|
+
F: __dxlog_file15,
|
|
3527
|
+
L: 141,
|
|
3010
3528
|
S: this,
|
|
3011
3529
|
C: (f, a) => f(...a)
|
|
3012
3530
|
});
|
|
3013
3531
|
}
|
|
3014
3532
|
async close() {
|
|
3015
3533
|
var _a;
|
|
3016
|
-
(0,
|
|
3017
|
-
F:
|
|
3018
|
-
L:
|
|
3534
|
+
(0, import_log13.log)("closing...", void 0, {
|
|
3535
|
+
F: __dxlog_file15,
|
|
3536
|
+
L: 145,
|
|
3019
3537
|
S: this,
|
|
3020
3538
|
C: (f, a) => f(...a)
|
|
3021
3539
|
});
|
|
@@ -3029,40 +3547,48 @@ var ServiceContext = class {
|
|
|
3029
3547
|
await this.networkManager.close();
|
|
3030
3548
|
await this.signalManager.close();
|
|
3031
3549
|
this.dataServiceSubscriptions.clear();
|
|
3032
|
-
(0,
|
|
3033
|
-
F:
|
|
3034
|
-
L:
|
|
3550
|
+
(0, import_log13.log)("closed", void 0, {
|
|
3551
|
+
F: __dxlog_file15,
|
|
3552
|
+
L: 156,
|
|
3035
3553
|
S: this,
|
|
3036
3554
|
C: (f, a) => f(...a)
|
|
3037
3555
|
});
|
|
3038
3556
|
}
|
|
3039
3557
|
async createIdentity(params = {}) {
|
|
3040
3558
|
const identity = await this.identityManager.createIdentity(params);
|
|
3041
|
-
await this._initialize();
|
|
3559
|
+
await this._initialize(new import_context8.Context());
|
|
3042
3560
|
return identity;
|
|
3043
3561
|
}
|
|
3044
3562
|
getInvitationHandler(invitation) {
|
|
3045
3563
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3046
|
-
(0,
|
|
3564
|
+
(0, import_invariant12.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
3565
|
+
F: __dxlog_file15,
|
|
3566
|
+
L: 168,
|
|
3567
|
+
S: this,
|
|
3568
|
+
A: [
|
|
3569
|
+
"factory",
|
|
3570
|
+
"`Unknown invitation kind: ${invitation.kind}`"
|
|
3571
|
+
]
|
|
3572
|
+
});
|
|
3047
3573
|
return factory(invitation);
|
|
3048
3574
|
}
|
|
3049
3575
|
async _acceptIdentity(params) {
|
|
3050
3576
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
3051
|
-
await this._initialize();
|
|
3577
|
+
await this._initialize(new import_context8.Context());
|
|
3052
3578
|
return identity;
|
|
3053
3579
|
}
|
|
3054
3580
|
async _checkStorageVersion() {
|
|
3055
3581
|
await this.metadataStore.load();
|
|
3056
|
-
if (this.metadataStore.version !==
|
|
3057
|
-
throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${
|
|
3582
|
+
if (this.metadataStore.version !== import_protocols9.STORAGE_VERSION) {
|
|
3583
|
+
throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${import_protocols9.STORAGE_VERSION}`);
|
|
3058
3584
|
}
|
|
3059
3585
|
}
|
|
3060
3586
|
// Called when identity is created.
|
|
3061
|
-
async _initialize() {
|
|
3587
|
+
async _initialize(ctx) {
|
|
3062
3588
|
var _a;
|
|
3063
|
-
(0,
|
|
3064
|
-
F:
|
|
3065
|
-
L:
|
|
3589
|
+
(0, import_log13.log)("initializing spaces...", void 0, {
|
|
3590
|
+
F: __dxlog_file15,
|
|
3591
|
+
L: 190,
|
|
3066
3592
|
S: this,
|
|
3067
3593
|
C: (f, a) => f(...a)
|
|
3068
3594
|
});
|
|
@@ -3082,14 +3608,22 @@ var ServiceContext = class {
|
|
|
3082
3608
|
};
|
|
3083
3609
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3084
3610
|
await this.dataSpaceManager.open();
|
|
3085
|
-
this._handlerFactories.set(
|
|
3086
|
-
(0,
|
|
3611
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
|
|
3612
|
+
(0, import_invariant12.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
3613
|
+
F: __dxlog_file15,
|
|
3614
|
+
L: 213,
|
|
3615
|
+
S: this,
|
|
3616
|
+
A: [
|
|
3617
|
+
"this.dataSpaceManager",
|
|
3618
|
+
"'dataSpaceManager not initialized yet'"
|
|
3619
|
+
]
|
|
3620
|
+
});
|
|
3087
3621
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3088
3622
|
});
|
|
3089
3623
|
this.initialized.wake();
|
|
3090
3624
|
this._deviceSpaceSync = {
|
|
3091
3625
|
processCredential: async (credential) => {
|
|
3092
|
-
const assertion = (0,
|
|
3626
|
+
const assertion = (0, import_credentials15.getCredentialAssertion)(credential);
|
|
3093
3627
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
3094
3628
|
return;
|
|
3095
3629
|
}
|
|
@@ -3097,33 +3631,33 @@ var ServiceContext = class {
|
|
|
3097
3631
|
return;
|
|
3098
3632
|
}
|
|
3099
3633
|
if (!this.dataSpaceManager) {
|
|
3100
|
-
(0,
|
|
3634
|
+
(0, import_log13.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3101
3635
|
details: assertion
|
|
3102
3636
|
}, {
|
|
3103
|
-
F:
|
|
3104
|
-
L:
|
|
3637
|
+
F: __dxlog_file15,
|
|
3638
|
+
L: 229,
|
|
3105
3639
|
S: this,
|
|
3106
3640
|
C: (f, a) => f(...a)
|
|
3107
3641
|
});
|
|
3108
3642
|
return;
|
|
3109
3643
|
}
|
|
3110
3644
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
3111
|
-
(0,
|
|
3645
|
+
(0, import_log13.log)("space already exists, ignoring space admission", {
|
|
3112
3646
|
details: assertion
|
|
3113
3647
|
}, {
|
|
3114
|
-
F:
|
|
3115
|
-
L:
|
|
3648
|
+
F: __dxlog_file15,
|
|
3649
|
+
L: 233,
|
|
3116
3650
|
S: this,
|
|
3117
3651
|
C: (f, a) => f(...a)
|
|
3118
3652
|
});
|
|
3119
3653
|
return;
|
|
3120
3654
|
}
|
|
3121
3655
|
try {
|
|
3122
|
-
(0,
|
|
3656
|
+
(0, import_log13.log)("accepting space recorded in halo", {
|
|
3123
3657
|
details: assertion
|
|
3124
3658
|
}, {
|
|
3125
|
-
F:
|
|
3126
|
-
L:
|
|
3659
|
+
F: __dxlog_file15,
|
|
3660
|
+
L: 238,
|
|
3127
3661
|
S: this,
|
|
3128
3662
|
C: (f, a) => f(...a)
|
|
3129
3663
|
});
|
|
@@ -3132,9 +3666,9 @@ var ServiceContext = class {
|
|
|
3132
3666
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3133
3667
|
});
|
|
3134
3668
|
} catch (err) {
|
|
3135
|
-
|
|
3136
|
-
F:
|
|
3137
|
-
L:
|
|
3669
|
+
import_log13.log.catch(err, void 0, {
|
|
3670
|
+
F: __dxlog_file15,
|
|
3671
|
+
L: 244,
|
|
3138
3672
|
S: this,
|
|
3139
3673
|
C: (f, a) => f(...a)
|
|
3140
3674
|
});
|
|
@@ -3144,26 +3678,37 @@ var ServiceContext = class {
|
|
|
3144
3678
|
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
3145
3679
|
}
|
|
3146
3680
|
};
|
|
3681
|
+
_ts_decorate5([
|
|
3682
|
+
import_tracing3.trace.span()
|
|
3683
|
+
], ServiceContext.prototype, "open", null);
|
|
3684
|
+
_ts_decorate5([
|
|
3685
|
+
import_tracing3.trace.span()
|
|
3686
|
+
], ServiceContext.prototype, "_initialize", null);
|
|
3687
|
+
ServiceContext = _ts_decorate5([
|
|
3688
|
+
import_tracing3.trace.resource()
|
|
3689
|
+
], ServiceContext);
|
|
3147
3690
|
|
|
3148
3691
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3149
|
-
var import_tiny_invariant13 = __toESM(require("tiny-invariant"));
|
|
3150
3692
|
var import_async17 = require("@dxos/async");
|
|
3151
3693
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
3152
|
-
var
|
|
3694
|
+
var import_context10 = require("@dxos/context");
|
|
3695
|
+
var import_document_model2 = require("@dxos/document-model");
|
|
3153
3696
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
3697
|
+
var import_invariant14 = require("@dxos/invariant");
|
|
3154
3698
|
var import_keys12 = require("@dxos/keys");
|
|
3155
|
-
var
|
|
3699
|
+
var import_log16 = require("@dxos/log");
|
|
3156
3700
|
var import_messaging = require("@dxos/messaging");
|
|
3157
3701
|
var import_model_factory = require("@dxos/model-factory");
|
|
3158
3702
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
3159
|
-
var
|
|
3160
|
-
var
|
|
3703
|
+
var import_protocols10 = require("@dxos/protocols");
|
|
3704
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3161
3705
|
var import_text_model = require("@dxos/text-model");
|
|
3706
|
+
var import_tracing4 = require("@dxos/tracing");
|
|
3162
3707
|
|
|
3163
3708
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3164
3709
|
var import_async12 = require("@dxos/async");
|
|
3165
|
-
var
|
|
3166
|
-
var
|
|
3710
|
+
var import_codec_protobuf6 = require("@dxos/codec-protobuf");
|
|
3711
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3167
3712
|
var DevicesServiceImpl = class {
|
|
3168
3713
|
constructor(_identityManager) {
|
|
3169
3714
|
this._identityManager = _identityManager;
|
|
@@ -3172,7 +3717,7 @@ var DevicesServiceImpl = class {
|
|
|
3172
3717
|
throw new Error("Method not implemented.");
|
|
3173
3718
|
}
|
|
3174
3719
|
queryDevices() {
|
|
3175
|
-
return new
|
|
3720
|
+
return new import_codec_protobuf6.Stream(({ next }) => {
|
|
3176
3721
|
const update = () => {
|
|
3177
3722
|
var _a;
|
|
3178
3723
|
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
@@ -3186,7 +3731,7 @@ var DevicesServiceImpl = class {
|
|
|
3186
3731
|
var _a2;
|
|
3187
3732
|
return {
|
|
3188
3733
|
deviceKey: key,
|
|
3189
|
-
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ?
|
|
3734
|
+
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services11.DeviceKind.CURRENT : import_services11.DeviceKind.TRUSTED
|
|
3190
3735
|
};
|
|
3191
3736
|
})
|
|
3192
3737
|
});
|
|
@@ -3209,16 +3754,16 @@ var DevicesServiceImpl = class {
|
|
|
3209
3754
|
|
|
3210
3755
|
// packages/sdk/client-services/src/packlets/devtools/devtools.ts
|
|
3211
3756
|
var import_async15 = require("@dxos/async");
|
|
3212
|
-
var
|
|
3757
|
+
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
3213
3758
|
|
|
3214
3759
|
// packages/sdk/client-services/src/packlets/devtools/feeds.ts
|
|
3215
3760
|
var import_async13 = require("@dxos/async");
|
|
3216
|
-
var
|
|
3761
|
+
var import_codec_protobuf7 = require("@dxos/codec-protobuf");
|
|
3217
3762
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
3218
3763
|
var import_keys9 = require("@dxos/keys");
|
|
3219
3764
|
var import_util6 = require("@dxos/util");
|
|
3220
3765
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
3221
|
-
return new
|
|
3766
|
+
return new import_codec_protobuf7.Stream(({ next }) => {
|
|
3222
3767
|
const subscriptions = new import_async13.EventSubscriptions();
|
|
3223
3768
|
const feedMap = new import_util6.ComplexMap(import_keys9.PublicKey.hash);
|
|
3224
3769
|
const update = () => {
|
|
@@ -3250,7 +3795,7 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
3250
3795
|
});
|
|
3251
3796
|
};
|
|
3252
3797
|
var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
|
|
3253
|
-
return new
|
|
3798
|
+
return new import_codec_protobuf7.Stream(({ next }) => {
|
|
3254
3799
|
if (!feedKey) {
|
|
3255
3800
|
return;
|
|
3256
3801
|
}
|
|
@@ -3290,8 +3835,8 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
|
|
|
3290
3835
|
|
|
3291
3836
|
// packages/sdk/client-services/src/packlets/devtools/keys.ts
|
|
3292
3837
|
var import_async14 = require("@dxos/async");
|
|
3293
|
-
var
|
|
3294
|
-
var subscribeToKeyringKeys = ({ keyring }) => new
|
|
3838
|
+
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
3839
|
+
var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf8.Stream(({ next, ctx }) => {
|
|
3295
3840
|
const update = async () => {
|
|
3296
3841
|
next({
|
|
3297
3842
|
keys: await keyring.list()
|
|
@@ -3302,8 +3847,8 @@ var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf7.Stream(
|
|
|
3302
3847
|
});
|
|
3303
3848
|
|
|
3304
3849
|
// packages/sdk/client-services/src/packlets/devtools/metadata.ts
|
|
3305
|
-
var
|
|
3306
|
-
var subscribeToMetadata = ({ context }) => new
|
|
3850
|
+
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
3851
|
+
var subscribeToMetadata = ({ context }) => new import_codec_protobuf9.Stream(({ next, ctx }) => {
|
|
3307
3852
|
context.metadataStore.update.on(ctx, (data) => next({
|
|
3308
3853
|
metadata: data
|
|
3309
3854
|
}));
|
|
@@ -3313,10 +3858,10 @@ var subscribeToMetadata = ({ context }) => new import_codec_protobuf8.Stream(({
|
|
|
3313
3858
|
});
|
|
3314
3859
|
|
|
3315
3860
|
// packages/sdk/client-services/src/packlets/devtools/network.ts
|
|
3316
|
-
var
|
|
3317
|
-
var
|
|
3861
|
+
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
3862
|
+
var import_context9 = require("@dxos/context");
|
|
3318
3863
|
var import_keys10 = require("@dxos/keys");
|
|
3319
|
-
var subscribeToNetworkStatus = ({ signalManager }) => new
|
|
3864
|
+
var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf10.Stream(({ next, close }) => {
|
|
3320
3865
|
const update = () => {
|
|
3321
3866
|
try {
|
|
3322
3867
|
const status = signalManager.getStatus();
|
|
@@ -3330,8 +3875,8 @@ var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf9
|
|
|
3330
3875
|
signalManager.statusChanged.on(() => update());
|
|
3331
3876
|
update();
|
|
3332
3877
|
});
|
|
3333
|
-
var subscribeToSignal = ({ signalManager }) => new
|
|
3334
|
-
const ctx = new
|
|
3878
|
+
var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf10.Stream(({ next }) => {
|
|
3879
|
+
const ctx = new import_context9.Context();
|
|
3335
3880
|
signalManager.onMessage.on(ctx, (message) => {
|
|
3336
3881
|
next({
|
|
3337
3882
|
message: {
|
|
@@ -3352,7 +3897,7 @@ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf9.Stream
|
|
|
3352
3897
|
return ctx.dispose();
|
|
3353
3898
|
};
|
|
3354
3899
|
});
|
|
3355
|
-
var subscribeToSwarmInfo = ({ networkManager }) => new
|
|
3900
|
+
var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf10.Stream(({ next }) => {
|
|
3356
3901
|
var _a;
|
|
3357
3902
|
const update = () => {
|
|
3358
3903
|
var _a2;
|
|
@@ -3368,9 +3913,9 @@ var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf9.St
|
|
|
3368
3913
|
});
|
|
3369
3914
|
|
|
3370
3915
|
// packages/sdk/client-services/src/packlets/devtools/spaces.ts
|
|
3371
|
-
var
|
|
3916
|
+
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
3372
3917
|
var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
3373
|
-
return new
|
|
3918
|
+
return new import_codec_protobuf11.Stream(({ next }) => {
|
|
3374
3919
|
let unsubscribe;
|
|
3375
3920
|
const update = async () => {
|
|
3376
3921
|
const spaces = [
|
|
@@ -3414,7 +3959,7 @@ var DevtoolsServiceImpl = class {
|
|
|
3414
3959
|
this.params = params;
|
|
3415
3960
|
}
|
|
3416
3961
|
events(request) {
|
|
3417
|
-
return new
|
|
3962
|
+
return new import_codec_protobuf12.Stream(({ next }) => {
|
|
3418
3963
|
this.params.events.ready.on(() => {
|
|
3419
3964
|
next({
|
|
3420
3965
|
ready: {}
|
|
@@ -3521,10 +4066,10 @@ var DevtoolsServiceImpl = class {
|
|
|
3521
4066
|
};
|
|
3522
4067
|
|
|
3523
4068
|
// packages/sdk/client-services/src/packlets/locks/node.ts
|
|
3524
|
-
var
|
|
4069
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
3525
4070
|
var import_lock_file = require("@dxos/lock-file");
|
|
3526
|
-
var
|
|
3527
|
-
function
|
|
4071
|
+
var import_log14 = require("@dxos/log");
|
|
4072
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
3528
4073
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3529
4074
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3530
4075
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3534,7 +4079,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
3534
4079
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3535
4080
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3536
4081
|
}
|
|
3537
|
-
var
|
|
4082
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
3538
4083
|
var Lock = class {
|
|
3539
4084
|
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
3540
4085
|
this._lockPath = lockPath;
|
|
@@ -3546,16 +4091,16 @@ var Lock = class {
|
|
|
3546
4091
|
}
|
|
3547
4092
|
async acquire() {
|
|
3548
4093
|
var _a;
|
|
3549
|
-
(0,
|
|
3550
|
-
F:
|
|
4094
|
+
(0, import_log14.log)("acquiring lock...", void 0, {
|
|
4095
|
+
F: __dxlog_file16,
|
|
3551
4096
|
L: 32,
|
|
3552
4097
|
S: this,
|
|
3553
4098
|
C: (f, a) => f(...a)
|
|
3554
4099
|
});
|
|
3555
4100
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
3556
4101
|
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
3557
|
-
(0,
|
|
3558
|
-
F:
|
|
4102
|
+
(0, import_log14.log)("acquired lock", void 0, {
|
|
4103
|
+
F: __dxlog_file16,
|
|
3559
4104
|
L: 37,
|
|
3560
4105
|
S: this,
|
|
3561
4106
|
C: (f, a) => f(...a)
|
|
@@ -3564,33 +4109,42 @@ var Lock = class {
|
|
|
3564
4109
|
async release() {
|
|
3565
4110
|
var _a;
|
|
3566
4111
|
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
3567
|
-
(0,
|
|
4112
|
+
(0, import_invariant13.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
4113
|
+
F: __dxlog_file16,
|
|
4114
|
+
L: 42,
|
|
4115
|
+
S: this,
|
|
4116
|
+
A: [
|
|
4117
|
+
"this._fileHandle",
|
|
4118
|
+
"'Lock is not acquired'"
|
|
4119
|
+
]
|
|
4120
|
+
});
|
|
3568
4121
|
await import_lock_file.LockFile.release(this._fileHandle);
|
|
3569
4122
|
}
|
|
3570
4123
|
};
|
|
3571
|
-
|
|
3572
|
-
|
|
4124
|
+
_ts_decorate6([
|
|
4125
|
+
import_log14.logInfo
|
|
3573
4126
|
], Lock.prototype, "lockKey", null);
|
|
3574
4127
|
|
|
3575
4128
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
3576
4129
|
var import_async16 = require("@dxos/async");
|
|
3577
|
-
var
|
|
3578
|
-
var
|
|
3579
|
-
var
|
|
4130
|
+
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
4131
|
+
var import_log15 = require("@dxos/log");
|
|
4132
|
+
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3580
4133
|
var import_util7 = require("@dxos/util");
|
|
3581
4134
|
var LoggingServiceImpl = class {
|
|
3582
4135
|
constructor() {
|
|
3583
4136
|
this._logs = new import_async16.Event();
|
|
4137
|
+
this._started = new Date();
|
|
3584
4138
|
this._logProcessor = (_config, entry2) => {
|
|
3585
4139
|
this._logs.emit(entry2);
|
|
3586
4140
|
};
|
|
3587
4141
|
}
|
|
3588
4142
|
async open() {
|
|
3589
|
-
|
|
4143
|
+
import_log15.log.runtimeConfig.processors.push(this._logProcessor);
|
|
3590
4144
|
}
|
|
3591
4145
|
async close() {
|
|
3592
|
-
const index =
|
|
3593
|
-
|
|
4146
|
+
const index = import_log15.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
4147
|
+
import_log15.log.runtimeConfig.processors.splice(index, 1);
|
|
3594
4148
|
}
|
|
3595
4149
|
async controlMetrics({ reset, record }) {
|
|
3596
4150
|
if (reset) {
|
|
@@ -3605,35 +4159,41 @@ var LoggingServiceImpl = class {
|
|
|
3605
4159
|
recording: import_util7.tracer.recording
|
|
3606
4160
|
};
|
|
3607
4161
|
}
|
|
3608
|
-
|
|
3609
|
-
|
|
4162
|
+
/**
|
|
4163
|
+
* @deprecated (Move to diagnostics).
|
|
4164
|
+
*/
|
|
4165
|
+
queryMetrics({ interval = 5e3 }) {
|
|
4166
|
+
const getNumericalValues = (key) => {
|
|
3610
4167
|
var _a;
|
|
3611
|
-
const
|
|
4168
|
+
const events = (_a = import_util7.tracer.get(key)) != null ? _a : [];
|
|
3612
4169
|
return {
|
|
3613
4170
|
key,
|
|
3614
|
-
stats: (0, import_util7.numericalValues)(
|
|
4171
|
+
stats: (0, import_util7.numericalValues)(events, "duration")
|
|
3615
4172
|
};
|
|
3616
4173
|
};
|
|
3617
|
-
return new
|
|
4174
|
+
return new import_codec_protobuf13.Stream(({ next }) => {
|
|
3618
4175
|
const update = () => {
|
|
3619
4176
|
const metrics = {
|
|
3620
4177
|
timestamp: new Date(),
|
|
3621
4178
|
values: [
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
]
|
|
4179
|
+
getNumericalValues("dxos.echo.pipeline.control"),
|
|
4180
|
+
getNumericalValues("dxos.echo.pipeline.data")
|
|
4181
|
+
].filter(Boolean)
|
|
3625
4182
|
};
|
|
3626
|
-
next(
|
|
4183
|
+
next({
|
|
4184
|
+
timestamp: new Date(),
|
|
4185
|
+
metrics
|
|
4186
|
+
});
|
|
3627
4187
|
};
|
|
3628
4188
|
update();
|
|
3629
|
-
const i = setInterval(update, interval);
|
|
4189
|
+
const i = setInterval(update, Math.max(interval, 1e3));
|
|
3630
4190
|
return () => {
|
|
3631
4191
|
clearInterval(i);
|
|
3632
4192
|
};
|
|
3633
4193
|
});
|
|
3634
4194
|
}
|
|
3635
4195
|
queryLogs(request) {
|
|
3636
|
-
return new
|
|
4196
|
+
return new import_codec_protobuf13.Stream(({ ctx, next }) => {
|
|
3637
4197
|
const handler = (entry2) => {
|
|
3638
4198
|
var _a, _b, _c, _d, _e;
|
|
3639
4199
|
if (LOG_PROCESSING > 0) {
|
|
@@ -3647,7 +4207,7 @@ var LoggingServiceImpl = class {
|
|
|
3647
4207
|
}
|
|
3648
4208
|
const record = {
|
|
3649
4209
|
...entry2,
|
|
3650
|
-
context: (0, import_util7.jsonify)((0,
|
|
4210
|
+
context: (0, import_util7.jsonify)((0, import_log15.getContextFromEntry)(entry2)),
|
|
3651
4211
|
timestamp: new Date(),
|
|
3652
4212
|
meta: {
|
|
3653
4213
|
// TODO(dmaretskyi): Fix proto.
|
|
@@ -3668,17 +4228,17 @@ var LoggingServiceImpl = class {
|
|
|
3668
4228
|
};
|
|
3669
4229
|
var matchFilter = (filter, level, path, options) => {
|
|
3670
4230
|
switch (options) {
|
|
3671
|
-
case
|
|
4231
|
+
case import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
3672
4232
|
return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
3673
|
-
case
|
|
4233
|
+
case import_services12.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
3674
4234
|
return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
3675
4235
|
}
|
|
3676
4236
|
};
|
|
3677
4237
|
var shouldLog = (entry2, request) => {
|
|
3678
4238
|
var _a;
|
|
3679
|
-
const options = (_a = request.options) != null ? _a :
|
|
4239
|
+
const options = (_a = request.options) != null ? _a : import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
3680
4240
|
if (request.filters === void 0) {
|
|
3681
|
-
return options ===
|
|
4241
|
+
return options === import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
3682
4242
|
} else {
|
|
3683
4243
|
return request.filters.some((filter) => {
|
|
3684
4244
|
var _a2, _b;
|
|
@@ -3689,14 +4249,14 @@ var shouldLog = (entry2, request) => {
|
|
|
3689
4249
|
var LOG_PROCESSING = 0;
|
|
3690
4250
|
|
|
3691
4251
|
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
3692
|
-
var
|
|
4252
|
+
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
3693
4253
|
var NetworkServiceImpl = class {
|
|
3694
4254
|
constructor(networkManager, signalManager) {
|
|
3695
4255
|
this.networkManager = networkManager;
|
|
3696
4256
|
this.signalManager = signalManager;
|
|
3697
4257
|
}
|
|
3698
4258
|
queryStatus() {
|
|
3699
|
-
return new
|
|
4259
|
+
return new import_codec_protobuf14.Stream(({ next }) => {
|
|
3700
4260
|
const update = () => {
|
|
3701
4261
|
next({
|
|
3702
4262
|
swarm: this.networkManager.connectionState,
|
|
@@ -3770,12 +4330,15 @@ var toStorageType = (type) => {
|
|
|
3770
4330
|
};
|
|
3771
4331
|
|
|
3772
4332
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
3773
|
-
var
|
|
4333
|
+
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
4334
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4335
|
+
var import_util9 = require("@dxos/util");
|
|
3774
4336
|
var SystemServiceImpl = class {
|
|
3775
|
-
constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
4337
|
+
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
3776
4338
|
this._config = config;
|
|
3777
4339
|
this._statusUpdate = statusUpdate;
|
|
3778
4340
|
this._getCurrentStatus = getCurrentStatus;
|
|
4341
|
+
this._getDiagnostics = getDiagnostics;
|
|
3779
4342
|
this._onUpdateStatus = onUpdateStatus;
|
|
3780
4343
|
this._onReset = onReset;
|
|
3781
4344
|
}
|
|
@@ -3783,12 +4346,25 @@ var SystemServiceImpl = class {
|
|
|
3783
4346
|
var _a, _b;
|
|
3784
4347
|
return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
|
|
3785
4348
|
}
|
|
4349
|
+
/**
|
|
4350
|
+
* NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
|
|
4351
|
+
*/
|
|
4352
|
+
async getDiagnostics({ keys } = {}) {
|
|
4353
|
+
const diagnostics = await this._getDiagnostics();
|
|
4354
|
+
return {
|
|
4355
|
+
timestamp: new Date(),
|
|
4356
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util9.jsonKeyReplacer)({
|
|
4357
|
+
truncate: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
4358
|
+
humanize: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
4359
|
+
})))
|
|
4360
|
+
};
|
|
4361
|
+
}
|
|
3786
4362
|
async updateStatus({ status }) {
|
|
3787
4363
|
await this._onUpdateStatus(status);
|
|
3788
4364
|
}
|
|
3789
4365
|
// TODO(burdon): Standardize interval option in stream request?
|
|
3790
4366
|
queryStatus({ interval = 3e3 } = {}) {
|
|
3791
|
-
return new
|
|
4367
|
+
return new import_codec_protobuf15.Stream(({ next }) => {
|
|
3792
4368
|
const update = () => {
|
|
3793
4369
|
next({
|
|
3794
4370
|
status: this._getCurrentStatus()
|
|
@@ -3833,7 +4409,7 @@ var ServiceRegistry = class {
|
|
|
3833
4409
|
};
|
|
3834
4410
|
|
|
3835
4411
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3836
|
-
function
|
|
4412
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
3837
4413
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3838
4414
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3839
4415
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3843,23 +4419,22 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3843
4419
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3844
4420
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3845
4421
|
}
|
|
3846
|
-
var
|
|
4422
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
3847
4423
|
var createDefaultModelFactory = () => {
|
|
3848
|
-
return new import_model_factory.ModelFactory().registerModel(
|
|
4424
|
+
return new import_model_factory.ModelFactory().registerModel(import_document_model2.DocumentModel).registerModel(import_text_model.TextModel);
|
|
3849
4425
|
};
|
|
3850
|
-
var ClientServicesHost = class {
|
|
4426
|
+
var ClientServicesHost = class ClientServicesHost2 {
|
|
3851
4427
|
constructor({
|
|
3852
4428
|
config,
|
|
3853
4429
|
modelFactory = createDefaultModelFactory(),
|
|
3854
|
-
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
3855
4430
|
transportFactory,
|
|
3856
4431
|
signalManager,
|
|
3857
|
-
connectionLog,
|
|
3858
4432
|
storage,
|
|
3859
4433
|
// TODO(wittjosiah): Turn this on by default.
|
|
3860
4434
|
lockKey,
|
|
3861
4435
|
callbacks
|
|
3862
4436
|
} = {}) {
|
|
4437
|
+
this._tracingService = import_tracing4.TRACE_PROCESSOR.createTraceSender();
|
|
3863
4438
|
this._statusUpdate = new import_async17.Event();
|
|
3864
4439
|
this._opening = false;
|
|
3865
4440
|
this._open = false;
|
|
@@ -3878,7 +4453,7 @@ var ClientServicesHost = class {
|
|
|
3878
4453
|
lockKey,
|
|
3879
4454
|
onAcquire: () => {
|
|
3880
4455
|
if (!this._opening) {
|
|
3881
|
-
void this.open();
|
|
4456
|
+
void this.open(new import_context10.Context());
|
|
3882
4457
|
}
|
|
3883
4458
|
},
|
|
3884
4459
|
onRelease: () => this.close()
|
|
@@ -3887,12 +4462,15 @@ var ClientServicesHost = class {
|
|
|
3887
4462
|
this._systemService = new SystemServiceImpl({
|
|
3888
4463
|
config: this._config,
|
|
3889
4464
|
statusUpdate: this._statusUpdate,
|
|
3890
|
-
getCurrentStatus: () => this.isOpen ?
|
|
4465
|
+
getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
|
|
4466
|
+
getDiagnostics: () => {
|
|
4467
|
+
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
4468
|
+
},
|
|
3891
4469
|
onUpdateStatus: async (status) => {
|
|
3892
4470
|
var _a, _b;
|
|
3893
|
-
if (!this.isOpen && status ===
|
|
4471
|
+
if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
|
|
3894
4472
|
await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
|
|
3895
|
-
} else if (this.isOpen && status ===
|
|
4473
|
+
} else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
|
|
3896
4474
|
await ((_b = this._resourceLock) == null ? void 0 : _b.release());
|
|
3897
4475
|
}
|
|
3898
4476
|
},
|
|
@@ -3902,12 +4480,19 @@ var ClientServicesHost = class {
|
|
|
3902
4480
|
});
|
|
3903
4481
|
this._loggingService = new LoggingServiceImpl();
|
|
3904
4482
|
this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
|
|
3905
|
-
SystemService: this._systemService
|
|
4483
|
+
SystemService: this._systemService,
|
|
4484
|
+
TracingService: this._tracingService
|
|
3906
4485
|
});
|
|
3907
4486
|
}
|
|
3908
4487
|
get isOpen() {
|
|
3909
4488
|
return this._open;
|
|
3910
4489
|
}
|
|
4490
|
+
get config() {
|
|
4491
|
+
return this._config;
|
|
4492
|
+
}
|
|
4493
|
+
get context() {
|
|
4494
|
+
return this._serviceContext;
|
|
4495
|
+
}
|
|
3911
4496
|
get serviceRegistry() {
|
|
3912
4497
|
return this._serviceRegistry;
|
|
3913
4498
|
}
|
|
@@ -3924,9 +4509,31 @@ var ClientServicesHost = class {
|
|
|
3924
4509
|
*/
|
|
3925
4510
|
initialize({ config, ...options }) {
|
|
3926
4511
|
var _a, _b, _c;
|
|
3927
|
-
(0,
|
|
4512
|
+
(0, import_invariant14.invariant)(!this._open, "service host is open", {
|
|
4513
|
+
F: __dxlog_file17,
|
|
4514
|
+
L: 181,
|
|
4515
|
+
S: this,
|
|
4516
|
+
A: [
|
|
4517
|
+
"!this._open",
|
|
4518
|
+
"'service host is open'"
|
|
4519
|
+
]
|
|
4520
|
+
});
|
|
4521
|
+
import_log16.log.info("initializing...", void 0, {
|
|
4522
|
+
F: __dxlog_file17,
|
|
4523
|
+
L: 182,
|
|
4524
|
+
S: this,
|
|
4525
|
+
C: (f, a) => f(...a)
|
|
4526
|
+
});
|
|
3928
4527
|
if (config) {
|
|
3929
|
-
(0,
|
|
4528
|
+
(0, import_invariant14.invariant)(!this._config, "config already set", {
|
|
4529
|
+
F: __dxlog_file17,
|
|
4530
|
+
L: 185,
|
|
4531
|
+
S: this,
|
|
4532
|
+
A: [
|
|
4533
|
+
"!this._config",
|
|
4534
|
+
"'config already set'"
|
|
4535
|
+
]
|
|
4536
|
+
});
|
|
3930
4537
|
this._config = config;
|
|
3931
4538
|
if (!this._storage) {
|
|
3932
4539
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
@@ -3936,37 +4543,83 @@ var ClientServicesHost = class {
|
|
|
3936
4543
|
iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
|
|
3937
4544
|
}), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
|
|
3938
4545
|
this._signalManager = signalManager;
|
|
3939
|
-
(0,
|
|
4546
|
+
(0, import_invariant14.invariant)(!this._networkManager, "network manager already set", {
|
|
4547
|
+
F: __dxlog_file17,
|
|
4548
|
+
L: 201,
|
|
4549
|
+
S: this,
|
|
4550
|
+
A: [
|
|
4551
|
+
"!this._networkManager",
|
|
4552
|
+
"'network manager already set'"
|
|
4553
|
+
]
|
|
4554
|
+
});
|
|
3940
4555
|
this._networkManager = new import_network_manager2.NetworkManager({
|
|
3941
4556
|
log: connectionLog,
|
|
3942
4557
|
transportFactory,
|
|
3943
4558
|
signalManager
|
|
3944
4559
|
});
|
|
4560
|
+
import_log16.log.info("initialized", void 0, {
|
|
4561
|
+
F: __dxlog_file17,
|
|
4562
|
+
L: 208,
|
|
4563
|
+
S: this,
|
|
4564
|
+
C: (f, a) => f(...a)
|
|
4565
|
+
});
|
|
3945
4566
|
}
|
|
3946
|
-
async open() {
|
|
4567
|
+
async open(ctx) {
|
|
3947
4568
|
var _a, _b, _c;
|
|
3948
4569
|
if (this._open) {
|
|
3949
4570
|
return;
|
|
3950
4571
|
}
|
|
3951
4572
|
const traceId = import_keys12.PublicKey.random().toHex();
|
|
3952
|
-
|
|
4573
|
+
import_log16.log.trace("dxos.client-services.host.open", import_protocols10.trace.begin({
|
|
3953
4574
|
id: traceId
|
|
3954
4575
|
}), {
|
|
3955
|
-
F:
|
|
3956
|
-
L:
|
|
4576
|
+
F: __dxlog_file17,
|
|
4577
|
+
L: 219,
|
|
3957
4578
|
S: this,
|
|
3958
4579
|
C: (f, a) => f(...a)
|
|
3959
4580
|
});
|
|
3960
|
-
(0,
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
4581
|
+
(0, import_invariant14.invariant)(this._config, "config not set", {
|
|
4582
|
+
F: __dxlog_file17,
|
|
4583
|
+
L: 221,
|
|
4584
|
+
S: this,
|
|
4585
|
+
A: [
|
|
4586
|
+
"this._config",
|
|
4587
|
+
"'config not set'"
|
|
4588
|
+
]
|
|
4589
|
+
});
|
|
4590
|
+
(0, import_invariant14.invariant)(this._storage, "storage not set", {
|
|
4591
|
+
F: __dxlog_file17,
|
|
4592
|
+
L: 222,
|
|
4593
|
+
S: this,
|
|
4594
|
+
A: [
|
|
4595
|
+
"this._storage",
|
|
4596
|
+
"'storage not set'"
|
|
4597
|
+
]
|
|
4598
|
+
});
|
|
4599
|
+
(0, import_invariant14.invariant)(this._signalManager, "signal manager not set", {
|
|
4600
|
+
F: __dxlog_file17,
|
|
4601
|
+
L: 223,
|
|
4602
|
+
S: this,
|
|
4603
|
+
A: [
|
|
4604
|
+
"this._signalManager",
|
|
4605
|
+
"'signal manager not set'"
|
|
4606
|
+
]
|
|
4607
|
+
});
|
|
4608
|
+
(0, import_invariant14.invariant)(this._networkManager, "network manager not set", {
|
|
4609
|
+
F: __dxlog_file17,
|
|
4610
|
+
L: 224,
|
|
4611
|
+
S: this,
|
|
4612
|
+
A: [
|
|
4613
|
+
"this._networkManager",
|
|
4614
|
+
"'network manager not set'"
|
|
4615
|
+
]
|
|
4616
|
+
});
|
|
3964
4617
|
this._opening = true;
|
|
3965
|
-
|
|
4618
|
+
import_log16.log.info("opening...", {
|
|
3966
4619
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
3967
4620
|
}, {
|
|
3968
|
-
F:
|
|
3969
|
-
L:
|
|
4621
|
+
F: __dxlog_file17,
|
|
4622
|
+
L: 227,
|
|
3970
4623
|
S: this,
|
|
3971
4624
|
C: (f, a) => f(...a)
|
|
3972
4625
|
});
|
|
@@ -3985,6 +4638,7 @@ var ClientServicesHost = class {
|
|
|
3985
4638
|
DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
3986
4639
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
3987
4640
|
LoggingService: this._loggingService,
|
|
4641
|
+
TracingService: this._tracingService,
|
|
3988
4642
|
// TODO(burdon): Move to new protobuf definitions.
|
|
3989
4643
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
3990
4644
|
events: new DevtoolsHostEvents(),
|
|
@@ -3992,24 +4646,24 @@ var ClientServicesHost = class {
|
|
|
3992
4646
|
context: this._serviceContext
|
|
3993
4647
|
})
|
|
3994
4648
|
});
|
|
3995
|
-
await this._serviceContext.open();
|
|
4649
|
+
await this._serviceContext.open(ctx);
|
|
3996
4650
|
this._opening = false;
|
|
3997
4651
|
this._open = true;
|
|
3998
4652
|
this._statusUpdate.emit();
|
|
3999
4653
|
const deviceKey = (_c = this._serviceContext.identityManager.identity) == null ? void 0 : _c.deviceKey;
|
|
4000
|
-
|
|
4654
|
+
import_log16.log.info("opened", {
|
|
4001
4655
|
deviceKey
|
|
4002
4656
|
}, {
|
|
4003
|
-
F:
|
|
4004
|
-
L:
|
|
4657
|
+
F: __dxlog_file17,
|
|
4658
|
+
L: 280,
|
|
4005
4659
|
S: this,
|
|
4006
4660
|
C: (f, a) => f(...a)
|
|
4007
4661
|
});
|
|
4008
|
-
|
|
4662
|
+
import_log16.log.trace("dxos.client-services.host.open", import_protocols10.trace.end({
|
|
4009
4663
|
id: traceId
|
|
4010
4664
|
}), {
|
|
4011
|
-
F:
|
|
4012
|
-
L:
|
|
4665
|
+
F: __dxlog_file17,
|
|
4666
|
+
L: 281,
|
|
4013
4667
|
S: this,
|
|
4014
4668
|
C: (f, a) => f(...a)
|
|
4015
4669
|
});
|
|
@@ -4020,11 +4674,11 @@ var ClientServicesHost = class {
|
|
|
4020
4674
|
return;
|
|
4021
4675
|
}
|
|
4022
4676
|
const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
|
|
4023
|
-
|
|
4677
|
+
import_log16.log.info("closing...", {
|
|
4024
4678
|
deviceKey
|
|
4025
4679
|
}, {
|
|
4026
|
-
F:
|
|
4027
|
-
L:
|
|
4680
|
+
F: __dxlog_file17,
|
|
4681
|
+
L: 292,
|
|
4028
4682
|
S: this,
|
|
4029
4683
|
C: (f, a) => f(...a)
|
|
4030
4684
|
});
|
|
@@ -4035,11 +4689,11 @@ var ClientServicesHost = class {
|
|
|
4035
4689
|
await this._serviceContext.close();
|
|
4036
4690
|
this._open = false;
|
|
4037
4691
|
this._statusUpdate.emit();
|
|
4038
|
-
|
|
4692
|
+
import_log16.log.info("closed", {
|
|
4039
4693
|
deviceKey
|
|
4040
4694
|
}, {
|
|
4041
|
-
F:
|
|
4042
|
-
L:
|
|
4695
|
+
F: __dxlog_file17,
|
|
4696
|
+
L: 298,
|
|
4043
4697
|
S: this,
|
|
4044
4698
|
C: (f, a) => f(...a)
|
|
4045
4699
|
});
|
|
@@ -4047,47 +4701,59 @@ var ClientServicesHost = class {
|
|
|
4047
4701
|
async reset() {
|
|
4048
4702
|
var _a, _b, _c;
|
|
4049
4703
|
const traceId = import_keys12.PublicKey.random().toHex();
|
|
4050
|
-
|
|
4704
|
+
import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.begin({
|
|
4051
4705
|
id: traceId
|
|
4052
4706
|
}), {
|
|
4053
|
-
F:
|
|
4054
|
-
L:
|
|
4707
|
+
F: __dxlog_file17,
|
|
4708
|
+
L: 303,
|
|
4055
4709
|
S: this,
|
|
4056
4710
|
C: (f, a) => f(...a)
|
|
4057
4711
|
});
|
|
4058
|
-
(0,
|
|
4059
|
-
F:
|
|
4060
|
-
L:
|
|
4712
|
+
(0, import_log16.log)("resetting...", void 0, {
|
|
4713
|
+
F: __dxlog_file17,
|
|
4714
|
+
L: 305,
|
|
4061
4715
|
S: this,
|
|
4062
4716
|
C: (f, a) => f(...a)
|
|
4063
4717
|
});
|
|
4064
4718
|
await ((_a = this._serviceContext) == null ? void 0 : _a.close());
|
|
4065
4719
|
await this._storage.reset();
|
|
4066
|
-
(0,
|
|
4067
|
-
F:
|
|
4068
|
-
L:
|
|
4720
|
+
(0, import_log16.log)("reset", void 0, {
|
|
4721
|
+
F: __dxlog_file17,
|
|
4722
|
+
L: 308,
|
|
4069
4723
|
S: this,
|
|
4070
4724
|
C: (f, a) => f(...a)
|
|
4071
4725
|
});
|
|
4072
|
-
|
|
4726
|
+
import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.end({
|
|
4073
4727
|
id: traceId
|
|
4074
4728
|
}), {
|
|
4075
|
-
F:
|
|
4076
|
-
L:
|
|
4729
|
+
F: __dxlog_file17,
|
|
4730
|
+
L: 309,
|
|
4077
4731
|
S: this,
|
|
4078
4732
|
C: (f, a) => f(...a)
|
|
4079
4733
|
});
|
|
4080
4734
|
await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
|
|
4081
4735
|
}
|
|
4082
4736
|
};
|
|
4083
|
-
|
|
4084
|
-
|
|
4737
|
+
_ts_decorate7([
|
|
4738
|
+
import_tracing4.trace.info()
|
|
4739
|
+
], ClientServicesHost.prototype, "_opening", void 0);
|
|
4740
|
+
_ts_decorate7([
|
|
4741
|
+
import_tracing4.trace.info()
|
|
4742
|
+
], ClientServicesHost.prototype, "_open", void 0);
|
|
4743
|
+
_ts_decorate7([
|
|
4744
|
+
import_async17.synchronized,
|
|
4745
|
+
import_tracing4.trace.span()
|
|
4085
4746
|
], ClientServicesHost.prototype, "open", null);
|
|
4086
|
-
|
|
4087
|
-
import_async17.synchronized
|
|
4747
|
+
_ts_decorate7([
|
|
4748
|
+
import_async17.synchronized,
|
|
4749
|
+
import_tracing4.trace.span()
|
|
4088
4750
|
], ClientServicesHost.prototype, "close", null);
|
|
4751
|
+
ClientServicesHost = _ts_decorate7([
|
|
4752
|
+
import_tracing4.trace.resource()
|
|
4753
|
+
], ClientServicesHost);
|
|
4089
4754
|
|
|
4090
4755
|
// packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
|
|
4756
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/testing/invitation-utils.ts";
|
|
4091
4757
|
var sanitizeInvitation = (invitation) => {
|
|
4092
4758
|
return {
|
|
4093
4759
|
invitationId: invitation.invitationId,
|
|
@@ -4107,7 +4773,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4107
4773
|
hostObservable.subscribe(async (hostInvitation) => {
|
|
4108
4774
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
4109
4775
|
switch (hostInvitation.state) {
|
|
4110
|
-
case
|
|
4776
|
+
case import_services15.Invitation.State.CONNECTING: {
|
|
4111
4777
|
if ((_b = (_a = hooks == null ? void 0 : hooks.host) == null ? void 0 : _a.onConnecting) == null ? void 0 : _b.call(_a, hostObservable)) {
|
|
4112
4778
|
break;
|
|
4113
4779
|
}
|
|
@@ -4115,29 +4781,37 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4115
4781
|
guestObservable.subscribe(async (guestInvitation) => {
|
|
4116
4782
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
|
|
4117
4783
|
switch (guestInvitation.state) {
|
|
4118
|
-
case
|
|
4784
|
+
case import_services15.Invitation.State.CONNECTING: {
|
|
4119
4785
|
if ((_b2 = (_a2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _a2.onConnecting) == null ? void 0 : _b2.call(_a2, guestObservable)) {
|
|
4120
4786
|
break;
|
|
4121
4787
|
}
|
|
4122
|
-
(0,
|
|
4788
|
+
(0, import_invariant15.invariant)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey), void 0, {
|
|
4789
|
+
F: __dxlog_file18,
|
|
4790
|
+
L: 84,
|
|
4791
|
+
S: void 0,
|
|
4792
|
+
A: [
|
|
4793
|
+
"hostInvitation.swarmKey!.equals(guestInvitation.swarmKey!)",
|
|
4794
|
+
""
|
|
4795
|
+
]
|
|
4796
|
+
});
|
|
4123
4797
|
break;
|
|
4124
4798
|
}
|
|
4125
|
-
case
|
|
4799
|
+
case import_services15.Invitation.State.CONNECTED: {
|
|
4126
4800
|
(_d2 = (_c2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _c2.onConnected) == null ? void 0 : _d2.call(_c2, guestObservable);
|
|
4127
4801
|
break;
|
|
4128
4802
|
}
|
|
4129
|
-
case
|
|
4803
|
+
case import_services15.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
4130
4804
|
if ((_f2 = (_e2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _e2.onReady) == null ? void 0 : _f2.call(_e2, guestObservable)) {
|
|
4131
4805
|
break;
|
|
4132
4806
|
}
|
|
4133
4807
|
await guestObservable.authenticate(await authCode.wait());
|
|
4134
4808
|
break;
|
|
4135
4809
|
}
|
|
4136
|
-
case
|
|
4810
|
+
case import_services15.Invitation.State.AUTHENTICATING: {
|
|
4137
4811
|
(_h2 = (_g2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _g2.onAuthenticating) == null ? void 0 : _h2.call(_g2, guestObservable);
|
|
4138
4812
|
break;
|
|
4139
4813
|
}
|
|
4140
|
-
case
|
|
4814
|
+
case import_services15.Invitation.State.SUCCESS: {
|
|
4141
4815
|
if ((_j2 = (_i2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _i2.onSuccess) == null ? void 0 : _j2.call(_i2, guestObservable)) {
|
|
4142
4816
|
break;
|
|
4143
4817
|
}
|
|
@@ -4146,7 +4820,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4146
4820
|
});
|
|
4147
4821
|
break;
|
|
4148
4822
|
}
|
|
4149
|
-
case
|
|
4823
|
+
case import_services15.Invitation.State.CANCELLED: {
|
|
4150
4824
|
if ((_l2 = (_k2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _k2.onCancelled) == null ? void 0 : _l2.call(_k2, guestObservable)) {
|
|
4151
4825
|
break;
|
|
4152
4826
|
}
|
|
@@ -4155,7 +4829,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4155
4829
|
});
|
|
4156
4830
|
break;
|
|
4157
4831
|
}
|
|
4158
|
-
case
|
|
4832
|
+
case import_services15.Invitation.State.TIMEOUT: {
|
|
4159
4833
|
if ((_n2 = (_m2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _m2.onTimeout) == null ? void 0 : _n2.call(_m2, guestObservable)) {
|
|
4160
4834
|
return;
|
|
4161
4835
|
}
|
|
@@ -4175,11 +4849,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4175
4849
|
});
|
|
4176
4850
|
break;
|
|
4177
4851
|
}
|
|
4178
|
-
case
|
|
4852
|
+
case import_services15.Invitation.State.CONNECTED: {
|
|
4179
4853
|
(_d = (_c = hooks == null ? void 0 : hooks.host) == null ? void 0 : _c.onConnected) == null ? void 0 : _d.call(_c, hostObservable);
|
|
4180
4854
|
break;
|
|
4181
4855
|
}
|
|
4182
|
-
case
|
|
4856
|
+
case import_services15.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
4183
4857
|
if ((_f = (_e = hooks == null ? void 0 : hooks.host) == null ? void 0 : _e.onReady) == null ? void 0 : _f.call(_e, hostObservable)) {
|
|
4184
4858
|
break;
|
|
4185
4859
|
}
|
|
@@ -4188,11 +4862,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4188
4862
|
}
|
|
4189
4863
|
break;
|
|
4190
4864
|
}
|
|
4191
|
-
case
|
|
4865
|
+
case import_services15.Invitation.State.AUTHENTICATING: {
|
|
4192
4866
|
(_h = (_g = hooks == null ? void 0 : hooks.host) == null ? void 0 : _g.onAuthenticating) == null ? void 0 : _h.call(_g, hostObservable);
|
|
4193
4867
|
break;
|
|
4194
4868
|
}
|
|
4195
|
-
case
|
|
4869
|
+
case import_services15.Invitation.State.SUCCESS: {
|
|
4196
4870
|
if ((_j = (_i = hooks == null ? void 0 : hooks.host) == null ? void 0 : _i.onSuccess) == null ? void 0 : _j.call(_i, hostObservable)) {
|
|
4197
4871
|
break;
|
|
4198
4872
|
}
|
|
@@ -4201,7 +4875,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4201
4875
|
});
|
|
4202
4876
|
break;
|
|
4203
4877
|
}
|
|
4204
|
-
case
|
|
4878
|
+
case import_services15.Invitation.State.CANCELLED: {
|
|
4205
4879
|
if ((_l = (_k = hooks == null ? void 0 : hooks.host) == null ? void 0 : _k.onCancelled) == null ? void 0 : _l.call(_k, hostObservable)) {
|
|
4206
4880
|
break;
|
|
4207
4881
|
}
|
|
@@ -4210,7 +4884,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4210
4884
|
});
|
|
4211
4885
|
break;
|
|
4212
4886
|
}
|
|
4213
|
-
case
|
|
4887
|
+
case import_services15.Invitation.State.TIMEOUT: {
|
|
4214
4888
|
if ((_n = (_m = hooks == null ? void 0 : hooks.host) == null ? void 0 : _m.onTimeout) == null ? void 0 : _n.call(_m, hostObservable)) {
|
|
4215
4889
|
break;
|
|
4216
4890
|
}
|
|
@@ -4236,12 +4910,12 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4236
4910
|
};
|
|
4237
4911
|
var createInvitation = (host, options) => {
|
|
4238
4912
|
options != null ? options : options = {
|
|
4239
|
-
authMethod:
|
|
4913
|
+
authMethod: import_services15.Invitation.AuthMethod.NONE,
|
|
4240
4914
|
...options != null ? options : {}
|
|
4241
4915
|
};
|
|
4242
4916
|
if (host instanceof ServiceContext) {
|
|
4243
4917
|
const hostHandler = host.getInvitationHandler({
|
|
4244
|
-
kind:
|
|
4918
|
+
kind: import_services15.Invitation.Kind.SPACE,
|
|
4245
4919
|
...options
|
|
4246
4920
|
});
|
|
4247
4921
|
return host.invitations.createInvitation(hostHandler, options);
|
|
@@ -4260,8 +4934,8 @@ var acceptInvitation = (guest, invitation) => {
|
|
|
4260
4934
|
};
|
|
4261
4935
|
|
|
4262
4936
|
// packages/sdk/client-services/src/packlets/testing/test-builder.ts
|
|
4263
|
-
var
|
|
4264
|
-
var
|
|
4937
|
+
var import_context11 = require("@dxos/context");
|
|
4938
|
+
var import_credentials16 = require("@dxos/credentials");
|
|
4265
4939
|
var import_debug8 = require("@dxos/debug");
|
|
4266
4940
|
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
4267
4941
|
var import_testing = require("@dxos/echo-pipeline/testing");
|
|
@@ -4295,7 +4969,7 @@ var createPeers = async (numPeers) => {
|
|
|
4295
4969
|
const peer = createServiceContext({
|
|
4296
4970
|
signalContext
|
|
4297
4971
|
});
|
|
4298
|
-
await peer.open();
|
|
4972
|
+
await peer.open(new import_context11.Context());
|
|
4299
4973
|
return peer;
|
|
4300
4974
|
}));
|
|
4301
4975
|
};
|
|
@@ -4310,7 +4984,7 @@ var syncItemsLocal = async (db1, db2) => {
|
|
|
4310
4984
|
var TestBuilder = class {
|
|
4311
4985
|
constructor() {
|
|
4312
4986
|
this.signalContext = new import_messaging2.MemorySignalManagerContext();
|
|
4313
|
-
this._ctx = new
|
|
4987
|
+
this._ctx = new import_context11.Context();
|
|
4314
4988
|
}
|
|
4315
4989
|
createPeer(peerOptions) {
|
|
4316
4990
|
const peer = new TestPeer(this.signalContext, peerOptions);
|
|
@@ -4406,8 +5080,8 @@ var createSigningContext = async (keyring) => {
|
|
|
4406
5080
|
return {
|
|
4407
5081
|
identityKey,
|
|
4408
5082
|
deviceKey,
|
|
4409
|
-
credentialSigner: (0,
|
|
4410
|
-
credential: await new
|
|
5083
|
+
credentialSigner: (0, import_credentials16.createCredentialSignerWithChain)(keyring, {
|
|
5084
|
+
credential: await new import_credentials16.CredentialGenerator(keyring, identityKey, deviceKey).createDeviceAuthorization(deviceKey)
|
|
4411
5085
|
}, deviceKey),
|
|
4412
5086
|
recordCredential: async () => {
|
|
4413
5087
|
}
|