@dxos/client-services 0.1.53-main.75474bf → 0.1.53-main.8f662cd
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-6ITWCQIT.mjs → chunk-O5T3BZYP.mjs} +83 -76
- package/dist/lib/browser/chunk-O5T3BZYP.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +8 -37
- 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 +6 -6
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +88 -112
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +86 -81
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/services/service-host.d.ts +1 -0
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts +1 -1
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/shell-runtime.d.ts +1 -21
- package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -1
- package/package.json +33 -32
- package/src/packlets/identity/identity-manager.test.ts +1 -1
- package/src/packlets/identity/identity-manager.ts +8 -8
- package/src/packlets/identity/identity-service.ts +2 -2
- package/src/packlets/identity/identity.test.ts +1 -1
- package/src/packlets/identity/identity.ts +2 -2
- package/src/packlets/invitations/device-invitation-protocol.ts +4 -4
- package/src/packlets/invitations/invitation-extension.ts +5 -5
- package/src/packlets/invitations/invitations-handler.ts +6 -6
- package/src/packlets/invitations/invitations-service.ts +3 -3
- package/src/packlets/invitations/space-invitation-protocol.ts +9 -9
- package/src/packlets/locks/node.ts +2 -2
- package/src/packlets/services/service-context.ts +3 -3
- package/src/packlets/services/service-host.ts +16 -9
- package/src/packlets/spaces/data-space-manager.ts +5 -6
- package/src/packlets/spaces/notarization-plugin.ts +4 -4
- package/src/packlets/testing/invitation-utils.ts +2 -2
- package/src/packlets/testing/test-builder.ts +1 -2
- package/src/packlets/vault/iframe-host-runtime.ts +2 -2
- package/src/packlets/vault/iframe-proxy-runtime.ts +2 -2
- package/src/packlets/vault/shell-runtime.ts +3 -49
- package/src/packlets/vault/worker-session.ts +2 -2
- package/dist/lib/browser/chunk-6ITWCQIT.mjs.map +0 -7
|
@@ -61,12 +61,12 @@ var createMockCredential = async ({ signer, issuer }) => (0, import_credentials.
|
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
// packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
|
|
64
|
-
var
|
|
64
|
+
var import_tiny_invariant14 = __toESM(require("tiny-invariant"));
|
|
65
65
|
var import_async18 = require("@dxos/async");
|
|
66
66
|
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
67
67
|
|
|
68
68
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
69
|
-
var
|
|
69
|
+
var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
|
|
70
70
|
var import_async11 = require("@dxos/async");
|
|
71
71
|
var import_credentials14 = require("@dxos/credentials");
|
|
72
72
|
var import_debug6 = require("@dxos/debug");
|
|
@@ -194,7 +194,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
194
194
|
};
|
|
195
195
|
|
|
196
196
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
197
|
-
var
|
|
197
|
+
var import_tiny_invariant = __toESM(require("tiny-invariant"));
|
|
198
198
|
var import_async2 = require("@dxos/async");
|
|
199
199
|
var import_client_protocol = require("@dxos/client-protocol");
|
|
200
200
|
var import_credentials3 = require("@dxos/credentials");
|
|
@@ -276,7 +276,7 @@ var Identity = class {
|
|
|
276
276
|
* Requires identity to be ready.
|
|
277
277
|
*/
|
|
278
278
|
getIdentityCredentialSigner() {
|
|
279
|
-
(0,
|
|
279
|
+
(0, import_tiny_invariant.default)(this._deviceStateMachine.processor.deviceCredentialChain, "Device credential chain is not ready.");
|
|
280
280
|
return (0, import_credentials3.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.processor.deviceCredentialChain, this.deviceKey);
|
|
281
281
|
}
|
|
282
282
|
/**
|
|
@@ -337,7 +337,7 @@ var Identity = class {
|
|
|
337
337
|
};
|
|
338
338
|
|
|
339
339
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
340
|
-
var
|
|
340
|
+
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
341
341
|
var import_async3 = require("@dxos/async");
|
|
342
342
|
var import_credentials5 = require("@dxos/credentials");
|
|
343
343
|
var import_keys2 = require("@dxos/keys");
|
|
@@ -409,7 +409,7 @@ var IdentityManager = class {
|
|
|
409
409
|
}
|
|
410
410
|
async createIdentity({ displayName } = {}) {
|
|
411
411
|
var _a;
|
|
412
|
-
(0,
|
|
412
|
+
(0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
|
|
413
413
|
(0, import_log3.log)("creating identity...", {}, {
|
|
414
414
|
file: "identity-manager.ts",
|
|
415
415
|
line: 94,
|
|
@@ -431,8 +431,8 @@ var IdentityManager = class {
|
|
|
431
431
|
await identity.open();
|
|
432
432
|
{
|
|
433
433
|
const generator = new import_credentials5.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
434
|
-
(0,
|
|
435
|
-
(0,
|
|
434
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
|
|
435
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
|
|
436
436
|
const credentials = [
|
|
437
437
|
// Space genesis.
|
|
438
438
|
...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
|
|
@@ -490,7 +490,7 @@ var IdentityManager = class {
|
|
|
490
490
|
scope: this,
|
|
491
491
|
callSite: (f, a) => f(...a)
|
|
492
492
|
});
|
|
493
|
-
(0,
|
|
493
|
+
(0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
|
|
494
494
|
const identityRecord = {
|
|
495
495
|
identityKey: params.identityKey,
|
|
496
496
|
deviceKey: params.deviceKey,
|
|
@@ -529,7 +529,7 @@ var IdentityManager = class {
|
|
|
529
529
|
return identity;
|
|
530
530
|
}
|
|
531
531
|
async _constructIdentity(identityRecord) {
|
|
532
|
-
(0,
|
|
532
|
+
(0, import_tiny_invariant2.default)(!this._identity);
|
|
533
533
|
(0, import_log3.log)("constructing identity", {
|
|
534
534
|
identityRecord
|
|
535
535
|
}, {
|
|
@@ -538,11 +538,11 @@ var IdentityManager = class {
|
|
|
538
538
|
scope: this,
|
|
539
539
|
callSite: (f, a) => f(...a)
|
|
540
540
|
});
|
|
541
|
-
(0,
|
|
541
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.controlFeedKey);
|
|
542
542
|
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
|
|
543
543
|
writable: true
|
|
544
544
|
});
|
|
545
|
-
(0,
|
|
545
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey);
|
|
546
546
|
const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
|
|
547
547
|
writable: true,
|
|
548
548
|
sparse: true
|
|
@@ -600,7 +600,7 @@ var IdentityManager = class {
|
|
|
600
600
|
};
|
|
601
601
|
|
|
602
602
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
603
|
-
var
|
|
603
|
+
var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
|
|
604
604
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
605
605
|
var import_credentials7 = require("@dxos/credentials");
|
|
606
606
|
var import_debug2 = require("@dxos/debug");
|
|
@@ -636,7 +636,7 @@ var IdentityServiceImpl = class {
|
|
|
636
636
|
};
|
|
637
637
|
}
|
|
638
638
|
async signPresentation({ presentation, nonce }) {
|
|
639
|
-
(0,
|
|
639
|
+
(0, import_tiny_invariant3.default)(this._serviceContext.identityManager.identity, "Identity not initialized.");
|
|
640
640
|
return await (0, import_credentials7.signPresentation)({
|
|
641
641
|
presentation,
|
|
642
642
|
signer: this._serviceContext.keyring,
|
|
@@ -648,7 +648,7 @@ var IdentityServiceImpl = class {
|
|
|
648
648
|
};
|
|
649
649
|
|
|
650
650
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
651
|
-
var
|
|
651
|
+
var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
|
|
652
652
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
653
653
|
var DeviceInvitationProtocol = class {
|
|
654
654
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
@@ -665,7 +665,7 @@ var DeviceInvitationProtocol = class {
|
|
|
665
665
|
};
|
|
666
666
|
}
|
|
667
667
|
async admit(request) {
|
|
668
|
-
(0,
|
|
668
|
+
(0, import_tiny_invariant4.default)(request.device);
|
|
669
669
|
const identity = this._getIdentity();
|
|
670
670
|
await identity.admitDevice(request.device);
|
|
671
671
|
return {
|
|
@@ -693,9 +693,9 @@ var DeviceInvitationProtocol = class {
|
|
|
693
693
|
};
|
|
694
694
|
}
|
|
695
695
|
async accept(response, request) {
|
|
696
|
-
(0,
|
|
696
|
+
(0, import_tiny_invariant4.default)(response.device);
|
|
697
697
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
698
|
-
(0,
|
|
698
|
+
(0, import_tiny_invariant4.default)(request.device);
|
|
699
699
|
const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
|
|
700
700
|
await this._acceptIdentity({
|
|
701
701
|
identityKey,
|
|
@@ -713,7 +713,7 @@ var DeviceInvitationProtocol = class {
|
|
|
713
713
|
};
|
|
714
714
|
|
|
715
715
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
716
|
-
var
|
|
716
|
+
var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
|
|
717
717
|
var import_async5 = require("@dxos/async");
|
|
718
718
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
719
719
|
var import_context3 = require("@dxos/context");
|
|
@@ -727,7 +727,7 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
727
727
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
728
728
|
|
|
729
729
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
730
|
-
var
|
|
730
|
+
var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
|
|
731
731
|
var import_async4 = require("@dxos/async");
|
|
732
732
|
var import_context2 = require("@dxos/context");
|
|
733
733
|
var import_errors = require("@dxos/errors");
|
|
@@ -764,7 +764,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
764
764
|
// Perhaps in the future we will have more complex logic here.
|
|
765
765
|
InvitationHostService: {
|
|
766
766
|
options: async (options) => {
|
|
767
|
-
(0,
|
|
767
|
+
(0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
|
|
768
768
|
this._remoteOptions = options;
|
|
769
769
|
this._remoteOptionsTrigger.wake();
|
|
770
770
|
},
|
|
@@ -840,7 +840,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
840
840
|
callSite: (f, a) => f(...a)
|
|
841
841
|
});
|
|
842
842
|
let status = import_invitations.AuthenticationResponse.Status.OK;
|
|
843
|
-
(0,
|
|
843
|
+
(0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
|
|
844
844
|
switch (this.invitation.authMethod) {
|
|
845
845
|
case import_services2.Invitation.AuthMethod.NONE: {
|
|
846
846
|
(0, import_log4.log)("authentication not required", {}, {
|
|
@@ -904,7 +904,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
904
904
|
callSite: (f, a) => f(...a)
|
|
905
905
|
});
|
|
906
906
|
try {
|
|
907
|
-
(0,
|
|
907
|
+
(0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
|
|
908
908
|
if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
|
|
909
909
|
throw new Error("Not authenticated");
|
|
910
910
|
}
|
|
@@ -969,7 +969,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
969
969
|
return {
|
|
970
970
|
InvitationHostService: {
|
|
971
971
|
options: async (options) => {
|
|
972
|
-
(0,
|
|
972
|
+
(0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
|
|
973
973
|
this._remoteOptions = options;
|
|
974
974
|
this._remoteOptionsTrigger.wake();
|
|
975
975
|
},
|
|
@@ -1048,7 +1048,7 @@ var InvitationsHandler = class {
|
|
|
1048
1048
|
var _a;
|
|
1049
1049
|
const { invitationId = import_keys4.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys4.PublicKey.random() } = options != null ? options : {};
|
|
1050
1050
|
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials8.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
|
|
1051
|
-
(0,
|
|
1051
|
+
(0, import_tiny_invariant6.default)(protocol);
|
|
1052
1052
|
const invitation = {
|
|
1053
1053
|
invitationId,
|
|
1054
1054
|
type,
|
|
@@ -1095,7 +1095,7 @@ var InvitationsHandler = class {
|
|
|
1095
1095
|
var _a2, _b, _c;
|
|
1096
1096
|
try {
|
|
1097
1097
|
const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
|
|
1098
|
-
(0,
|
|
1098
|
+
(0, import_tiny_invariant6.default)(deviceKey);
|
|
1099
1099
|
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1100
1100
|
extension.completedTrigger.wake(deviceKey);
|
|
1101
1101
|
return admissionResponse;
|
|
@@ -1254,13 +1254,13 @@ var InvitationsHandler = class {
|
|
|
1254
1254
|
}
|
|
1255
1255
|
acceptInvitation(protocol, invitation) {
|
|
1256
1256
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
1257
|
-
(0,
|
|
1257
|
+
(0, import_tiny_invariant6.default)(protocol);
|
|
1258
1258
|
const authenticated = new import_async5.Trigger();
|
|
1259
1259
|
let admitted = false;
|
|
1260
1260
|
let currentState;
|
|
1261
1261
|
const stream = new import_async5.PushStream();
|
|
1262
1262
|
const setState = (newData) => {
|
|
1263
|
-
(0,
|
|
1263
|
+
(0, import_tiny_invariant6.default)(newData.state !== void 0);
|
|
1264
1264
|
currentState = newData.state;
|
|
1265
1265
|
stream.next({
|
|
1266
1266
|
...invitation,
|
|
@@ -1517,7 +1517,7 @@ var InvitationsHandler = class {
|
|
|
1517
1517
|
return extension;
|
|
1518
1518
|
};
|
|
1519
1519
|
(0, import_async5.scheduleTask)(ctx, async () => {
|
|
1520
|
-
(0,
|
|
1520
|
+
(0, import_tiny_invariant6.default)(invitation.swarmKey);
|
|
1521
1521
|
const topic = invitation.swarmKey;
|
|
1522
1522
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1523
1523
|
topic,
|
|
@@ -1550,7 +1550,7 @@ var InvitationsHandler = class {
|
|
|
1550
1550
|
};
|
|
1551
1551
|
|
|
1552
1552
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1553
|
-
var
|
|
1553
|
+
var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
|
|
1554
1554
|
var import_async6 = require("@dxos/async");
|
|
1555
1555
|
var import_codec_protobuf2 = require("@dxos/codec-protobuf");
|
|
1556
1556
|
var import_log6 = require("@dxos/log");
|
|
@@ -1621,7 +1621,7 @@ var InvitationsServiceImpl = class {
|
|
|
1621
1621
|
scope: this,
|
|
1622
1622
|
callSite: (f, a) => f(...a)
|
|
1623
1623
|
});
|
|
1624
|
-
(0,
|
|
1624
|
+
(0, import_tiny_invariant7.default)(invitationId);
|
|
1625
1625
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1626
1626
|
if (!observable) {
|
|
1627
1627
|
import_log6.log.warn("invalid invitation", {
|
|
@@ -1643,7 +1643,7 @@ var InvitationsServiceImpl = class {
|
|
|
1643
1643
|
scope: this,
|
|
1644
1644
|
callSite: (f, a) => f(...a)
|
|
1645
1645
|
});
|
|
1646
|
-
(0,
|
|
1646
|
+
(0, import_tiny_invariant7.default)(invitationId);
|
|
1647
1647
|
const created = this._createInvitations.get(invitationId);
|
|
1648
1648
|
const accepted = this._acceptInvitations.get(invitationId);
|
|
1649
1649
|
if (created) {
|
|
@@ -1718,7 +1718,7 @@ var InvitationsServiceImpl = class {
|
|
|
1718
1718
|
};
|
|
1719
1719
|
|
|
1720
1720
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
1721
|
-
var
|
|
1721
|
+
var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
|
|
1722
1722
|
var import_credentials9 = require("@dxos/credentials");
|
|
1723
1723
|
var import_feed_store2 = require("@dxos/feed-store");
|
|
1724
1724
|
var import_log7 = require("@dxos/log");
|
|
@@ -1744,10 +1744,10 @@ var SpaceInvitationProtocol = class {
|
|
|
1744
1744
|
}
|
|
1745
1745
|
async admit(request, guestProfile) {
|
|
1746
1746
|
var _a;
|
|
1747
|
-
(0,
|
|
1747
|
+
(0, import_tiny_invariant8.default)(this._spaceKey);
|
|
1748
1748
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
1749
|
-
(0,
|
|
1750
|
-
(0,
|
|
1749
|
+
(0, import_tiny_invariant8.default)(space);
|
|
1750
|
+
(0, import_tiny_invariant8.default)(request.space);
|
|
1751
1751
|
const { identityKey, deviceKey } = request.space;
|
|
1752
1752
|
(0, import_log7.log)("writing guest credentials", {
|
|
1753
1753
|
host: this._signingContext.deviceKey,
|
|
@@ -1759,9 +1759,9 @@ var SpaceInvitationProtocol = class {
|
|
|
1759
1759
|
callSite: (f, a) => f(...a)
|
|
1760
1760
|
});
|
|
1761
1761
|
const credentials = await (0, import_credentials9.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
1762
|
-
(0,
|
|
1762
|
+
(0, import_tiny_invariant8.default)(credentials[0].credential);
|
|
1763
1763
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
1764
|
-
(0,
|
|
1764
|
+
(0, import_tiny_invariant8.default)((0, import_credentials9.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
1765
1765
|
await (0, import_feed_store2.writeMessages)(space.inner.controlPipeline.writer, credentials);
|
|
1766
1766
|
return {
|
|
1767
1767
|
space: {
|
|
@@ -1789,11 +1789,11 @@ var SpaceInvitationProtocol = class {
|
|
|
1789
1789
|
};
|
|
1790
1790
|
}
|
|
1791
1791
|
async accept(response) {
|
|
1792
|
-
(0,
|
|
1792
|
+
(0, import_tiny_invariant8.default)(response.space);
|
|
1793
1793
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
1794
1794
|
const assertion = (0, import_credentials9.getCredentialAssertion)(credential);
|
|
1795
|
-
(0,
|
|
1796
|
-
(0,
|
|
1795
|
+
(0, import_tiny_invariant8.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
|
|
1796
|
+
(0, import_tiny_invariant8.default)(credential.subject.id.equals(this._signingContext.identityKey));
|
|
1797
1797
|
await this._spaceManager.acceptSpace({
|
|
1798
1798
|
spaceKey: assertion.spaceKey,
|
|
1799
1799
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -1808,7 +1808,7 @@ var SpaceInvitationProtocol = class {
|
|
|
1808
1808
|
};
|
|
1809
1809
|
|
|
1810
1810
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
1811
|
-
var
|
|
1811
|
+
var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
|
|
1812
1812
|
var import_async9 = require("@dxos/async");
|
|
1813
1813
|
var import_context6 = require("@dxos/context");
|
|
1814
1814
|
var import_credentials13 = require("@dxos/credentials");
|
|
@@ -1834,7 +1834,7 @@ var import_timeframe = require("@dxos/timeframe");
|
|
|
1834
1834
|
var import_util3 = require("@dxos/util");
|
|
1835
1835
|
|
|
1836
1836
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
1837
|
-
var
|
|
1837
|
+
var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
|
|
1838
1838
|
var import_async7 = require("@dxos/async");
|
|
1839
1839
|
var import_context4 = require("@dxos/context");
|
|
1840
1840
|
var import_keys5 = require("@dxos/keys");
|
|
@@ -1871,7 +1871,7 @@ var NotarizationPlugin = class {
|
|
|
1871
1871
|
scope: this,
|
|
1872
1872
|
callSite: (f, a) => f(...a)
|
|
1873
1873
|
});
|
|
1874
|
-
(0,
|
|
1874
|
+
(0, import_tiny_invariant9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
1875
1875
|
const errors = new import_async7.Trigger();
|
|
1876
1876
|
const ctx = this._ctx.derive({
|
|
1877
1877
|
onError: (err) => {
|
|
@@ -1989,7 +1989,7 @@ var NotarizationPlugin = class {
|
|
|
1989
1989
|
this._processCredentialsTriggers.delete(credential.id);
|
|
1990
1990
|
}
|
|
1991
1991
|
setWriter(writer) {
|
|
1992
|
-
(0,
|
|
1992
|
+
(0, import_tiny_invariant9.default)(!this._writer, "Writer already set.");
|
|
1993
1993
|
this._writer = writer;
|
|
1994
1994
|
}
|
|
1995
1995
|
async _waitUntilProcessed(id) {
|
|
@@ -2007,7 +2007,7 @@ var NotarizationPlugin = class {
|
|
|
2007
2007
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2008
2008
|
}
|
|
2009
2009
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2010
|
-
(0,
|
|
2010
|
+
(0, import_tiny_invariant9.default)(credential.id, "Credential must have an id");
|
|
2011
2011
|
if (this._processedCredentials.has(credential.id)) {
|
|
2012
2012
|
continue;
|
|
2013
2013
|
}
|
|
@@ -2496,7 +2496,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2496
2496
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
2497
2497
|
*/
|
|
2498
2498
|
async createSpace() {
|
|
2499
|
-
(0,
|
|
2499
|
+
(0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
|
|
2500
2500
|
const spaceKey = await this._keyring.createKey();
|
|
2501
2501
|
const controlFeedKey = await this._keyring.createKey();
|
|
2502
2502
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -2518,7 +2518,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2518
2518
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2519
2519
|
await this._metadataStore.addSpace(metadata);
|
|
2520
2520
|
const memberCredential = credentials[1];
|
|
2521
|
-
(0,
|
|
2521
|
+
(0, import_tiny_invariant10.default)((0, import_credentials13.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2522
2522
|
await this._signingContext.recordCredential(memberCredential);
|
|
2523
2523
|
await space.initializeDataPipeline();
|
|
2524
2524
|
this.updated.emit();
|
|
@@ -2534,8 +2534,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2534
2534
|
scope: this,
|
|
2535
2535
|
callSite: (f, a) => f(...a)
|
|
2536
2536
|
});
|
|
2537
|
-
(0,
|
|
2538
|
-
(0,
|
|
2537
|
+
(0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
|
|
2538
|
+
(0, import_tiny_invariant10.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
2539
2539
|
const metadata = {
|
|
2540
2540
|
key: opts.spaceKey,
|
|
2541
2541
|
genesisFeedKey: opts.genesisFeedKey,
|
|
@@ -2564,7 +2564,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2564
2564
|
metadata
|
|
2565
2565
|
}, {
|
|
2566
2566
|
file: "data-space-manager.ts",
|
|
2567
|
-
line:
|
|
2567
|
+
line: 180,
|
|
2568
2568
|
scope: this,
|
|
2569
2569
|
callSite: (f, a) => f(...a)
|
|
2570
2570
|
});
|
|
@@ -2600,7 +2600,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2600
2600
|
onAuthFailure: () => {
|
|
2601
2601
|
import_log10.log.warn("auth failure", {}, {
|
|
2602
2602
|
file: "data-space-manager.ts",
|
|
2603
|
-
line:
|
|
2603
|
+
line: 211,
|
|
2604
2604
|
scope: this,
|
|
2605
2605
|
callSite: (f, a) => f(...a)
|
|
2606
2606
|
});
|
|
@@ -2623,7 +2623,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2623
2623
|
space: space.key
|
|
2624
2624
|
}, {
|
|
2625
2625
|
file: "data-space-manager.ts",
|
|
2626
|
-
line:
|
|
2626
|
+
line: 228,
|
|
2627
2627
|
scope: this,
|
|
2628
2628
|
callSite: (f, a) => f(...a)
|
|
2629
2629
|
});
|
|
@@ -2635,7 +2635,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2635
2635
|
open: this._isOpen
|
|
2636
2636
|
}, {
|
|
2637
2637
|
file: "data-space-manager.ts",
|
|
2638
|
-
line:
|
|
2638
|
+
line: 235,
|
|
2639
2639
|
scope: this,
|
|
2640
2640
|
callSite: (f, a) => f(...a)
|
|
2641
2641
|
});
|
|
@@ -2945,7 +2945,7 @@ var ServiceContext = class {
|
|
|
2945
2945
|
}
|
|
2946
2946
|
getInvitationHandler(invitation) {
|
|
2947
2947
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
2948
|
-
(0,
|
|
2948
|
+
(0, import_tiny_invariant11.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
|
|
2949
2949
|
return factory(invitation);
|
|
2950
2950
|
}
|
|
2951
2951
|
async _acceptIdentity(params) {
|
|
@@ -2985,7 +2985,7 @@ var ServiceContext = class {
|
|
|
2985
2985
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
2986
2986
|
await this.dataSpaceManager.open();
|
|
2987
2987
|
this._handlerFactories.set(import_services9.Invitation.Kind.SPACE, (invitation) => {
|
|
2988
|
-
(0,
|
|
2988
|
+
(0, import_tiny_invariant11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
|
|
2989
2989
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
2990
2990
|
});
|
|
2991
2991
|
this.initialized.wake();
|
|
@@ -3048,16 +3048,19 @@ var ServiceContext = class {
|
|
|
3048
3048
|
};
|
|
3049
3049
|
|
|
3050
3050
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3051
|
-
var
|
|
3051
|
+
var import_tiny_invariant13 = __toESM(require("tiny-invariant"));
|
|
3052
3052
|
var import_async17 = require("@dxos/async");
|
|
3053
3053
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
3054
|
+
var import_document_model = require("@dxos/document-model");
|
|
3054
3055
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
3055
3056
|
var import_keys12 = require("@dxos/keys");
|
|
3056
3057
|
var import_log15 = require("@dxos/log");
|
|
3057
3058
|
var import_messaging = require("@dxos/messaging");
|
|
3059
|
+
var import_model_factory = require("@dxos/model-factory");
|
|
3058
3060
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
3059
3061
|
var import_protocols9 = require("@dxos/protocols");
|
|
3060
3062
|
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3063
|
+
var import_text_model = require("@dxos/text-model");
|
|
3061
3064
|
|
|
3062
3065
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3063
3066
|
var import_async12 = require("@dxos/async");
|
|
@@ -3420,7 +3423,7 @@ var DevtoolsServiceImpl = class {
|
|
|
3420
3423
|
};
|
|
3421
3424
|
|
|
3422
3425
|
// packages/sdk/client-services/src/packlets/locks/node.ts
|
|
3423
|
-
var
|
|
3426
|
+
var import_tiny_invariant12 = __toESM(require("tiny-invariant"));
|
|
3424
3427
|
var import_lock_file = require("@dxos/lock-file");
|
|
3425
3428
|
var import_log13 = require("@dxos/log");
|
|
3426
3429
|
var __decorate3 = function(decorators, target, key, desc) {
|
|
@@ -3462,7 +3465,7 @@ var Lock = class {
|
|
|
3462
3465
|
async release() {
|
|
3463
3466
|
var _a;
|
|
3464
3467
|
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
3465
|
-
(0,
|
|
3468
|
+
(0, import_tiny_invariant12.default)(this._fileHandle, "Lock is not acquired");
|
|
3466
3469
|
await import_lock_file.LockFile.release(this._fileHandle);
|
|
3467
3470
|
}
|
|
3468
3471
|
};
|
|
@@ -3700,10 +3703,13 @@ var __decorate4 = function(decorators, target, key, desc) {
|
|
|
3700
3703
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3701
3704
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3702
3705
|
};
|
|
3706
|
+
var createDefaultModelFactory = () => {
|
|
3707
|
+
return new import_model_factory.ModelFactory().registerModel(import_document_model.DocumentModel).registerModel(import_text_model.TextModel);
|
|
3708
|
+
};
|
|
3703
3709
|
var ClientServicesHost = class {
|
|
3704
3710
|
constructor({
|
|
3705
3711
|
config,
|
|
3706
|
-
modelFactory =
|
|
3712
|
+
modelFactory = createDefaultModelFactory(),
|
|
3707
3713
|
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
3708
3714
|
transportFactory,
|
|
3709
3715
|
signalManager,
|
|
@@ -3775,9 +3781,9 @@ var ClientServicesHost = class {
|
|
|
3775
3781
|
*/
|
|
3776
3782
|
initialize({ config, ...options }) {
|
|
3777
3783
|
var _a, _b, _c;
|
|
3778
|
-
(0,
|
|
3784
|
+
(0, import_tiny_invariant13.default)(!this._open, "service host is open");
|
|
3779
3785
|
if (config) {
|
|
3780
|
-
(0,
|
|
3786
|
+
(0, import_tiny_invariant13.default)(!this._config, "config already set");
|
|
3781
3787
|
this._config = config;
|
|
3782
3788
|
if (!this._storage) {
|
|
3783
3789
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
@@ -3787,7 +3793,7 @@ var ClientServicesHost = class {
|
|
|
3787
3793
|
iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
|
|
3788
3794
|
}), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
|
|
3789
3795
|
this._signalManager = signalManager;
|
|
3790
|
-
(0,
|
|
3796
|
+
(0, import_tiny_invariant13.default)(!this._networkManager, "network manager already set");
|
|
3791
3797
|
this._networkManager = new import_network_manager2.NetworkManager({
|
|
3792
3798
|
log: connectionLog,
|
|
3793
3799
|
transportFactory,
|
|
@@ -3804,20 +3810,20 @@ var ClientServicesHost = class {
|
|
|
3804
3810
|
id: traceId
|
|
3805
3811
|
}), {
|
|
3806
3812
|
file: "service-host.ts",
|
|
3807
|
-
line:
|
|
3813
|
+
line: 195,
|
|
3808
3814
|
scope: this,
|
|
3809
3815
|
callSite: (f, a) => f(...a)
|
|
3810
3816
|
});
|
|
3811
|
-
(0,
|
|
3812
|
-
(0,
|
|
3813
|
-
(0,
|
|
3814
|
-
(0,
|
|
3817
|
+
(0, import_tiny_invariant13.default)(this._config, "config not set");
|
|
3818
|
+
(0, import_tiny_invariant13.default)(this._storage, "storage not set");
|
|
3819
|
+
(0, import_tiny_invariant13.default)(this._signalManager, "signal manager not set");
|
|
3820
|
+
(0, import_tiny_invariant13.default)(this._networkManager, "network manager not set");
|
|
3815
3821
|
this._opening = true;
|
|
3816
3822
|
(0, import_log15.log)("opening...", {
|
|
3817
3823
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
3818
3824
|
}, {
|
|
3819
3825
|
file: "service-host.ts",
|
|
3820
|
-
line:
|
|
3826
|
+
line: 203,
|
|
3821
3827
|
scope: this,
|
|
3822
3828
|
callSite: (f, a) => f(...a)
|
|
3823
3829
|
});
|
|
@@ -3852,7 +3858,7 @@ var ClientServicesHost = class {
|
|
|
3852
3858
|
deviceKey
|
|
3853
3859
|
}, {
|
|
3854
3860
|
file: "service-host.ts",
|
|
3855
|
-
line:
|
|
3861
|
+
line: 258,
|
|
3856
3862
|
scope: this,
|
|
3857
3863
|
callSite: (f, a) => f(...a)
|
|
3858
3864
|
});
|
|
@@ -3860,7 +3866,7 @@ var ClientServicesHost = class {
|
|
|
3860
3866
|
id: traceId
|
|
3861
3867
|
}), {
|
|
3862
3868
|
file: "service-host.ts",
|
|
3863
|
-
line:
|
|
3869
|
+
line: 259,
|
|
3864
3870
|
scope: this,
|
|
3865
3871
|
callSite: (f, a) => f(...a)
|
|
3866
3872
|
});
|
|
@@ -3875,7 +3881,7 @@ var ClientServicesHost = class {
|
|
|
3875
3881
|
deviceKey
|
|
3876
3882
|
}, {
|
|
3877
3883
|
file: "service-host.ts",
|
|
3878
|
-
line:
|
|
3884
|
+
line: 269,
|
|
3879
3885
|
scope: this,
|
|
3880
3886
|
callSite: (f, a) => f(...a)
|
|
3881
3887
|
});
|
|
@@ -3890,7 +3896,7 @@ var ClientServicesHost = class {
|
|
|
3890
3896
|
deviceKey
|
|
3891
3897
|
}, {
|
|
3892
3898
|
file: "service-host.ts",
|
|
3893
|
-
line:
|
|
3899
|
+
line: 275,
|
|
3894
3900
|
scope: this,
|
|
3895
3901
|
callSite: (f, a) => f(...a)
|
|
3896
3902
|
});
|
|
@@ -3902,13 +3908,13 @@ var ClientServicesHost = class {
|
|
|
3902
3908
|
id: traceId
|
|
3903
3909
|
}), {
|
|
3904
3910
|
file: "service-host.ts",
|
|
3905
|
-
line:
|
|
3911
|
+
line: 280,
|
|
3906
3912
|
scope: this,
|
|
3907
3913
|
callSite: (f, a) => f(...a)
|
|
3908
3914
|
});
|
|
3909
3915
|
(0, import_log15.log)("resetting...", {}, {
|
|
3910
3916
|
file: "service-host.ts",
|
|
3911
|
-
line:
|
|
3917
|
+
line: 282,
|
|
3912
3918
|
scope: this,
|
|
3913
3919
|
callSite: (f, a) => f(...a)
|
|
3914
3920
|
});
|
|
@@ -3916,7 +3922,7 @@ var ClientServicesHost = class {
|
|
|
3916
3922
|
await this._storage.reset();
|
|
3917
3923
|
(0, import_log15.log)("reset", {}, {
|
|
3918
3924
|
file: "service-host.ts",
|
|
3919
|
-
line:
|
|
3925
|
+
line: 285,
|
|
3920
3926
|
scope: this,
|
|
3921
3927
|
callSite: (f, a) => f(...a)
|
|
3922
3928
|
});
|
|
@@ -3924,7 +3930,7 @@ var ClientServicesHost = class {
|
|
|
3924
3930
|
id: traceId
|
|
3925
3931
|
}), {
|
|
3926
3932
|
file: "service-host.ts",
|
|
3927
|
-
line:
|
|
3933
|
+
line: 286,
|
|
3928
3934
|
scope: this,
|
|
3929
3935
|
callSite: (f, a) => f(...a)
|
|
3930
3936
|
});
|
|
@@ -3969,7 +3975,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
3969
3975
|
if ((_b2 = (_a2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _a2.onConnecting) == null ? void 0 : _b2.call(_a2, guestObservable)) {
|
|
3970
3976
|
break;
|
|
3971
3977
|
}
|
|
3972
|
-
(0,
|
|
3978
|
+
(0, import_tiny_invariant14.default)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey));
|
|
3973
3979
|
break;
|
|
3974
3980
|
}
|
|
3975
3981
|
case import_services13.Invitation.State.CONNECTED: {
|
|
@@ -4110,7 +4116,6 @@ var acceptInvitation = (guest, invitation) => {
|
|
|
4110
4116
|
};
|
|
4111
4117
|
|
|
4112
4118
|
// packages/sdk/client-services/src/packlets/testing/test-builder.ts
|
|
4113
|
-
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
4114
4119
|
var import_context8 = require("@dxos/context");
|
|
4115
4120
|
var import_credentials15 = require("@dxos/credentials");
|
|
4116
4121
|
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
@@ -4136,7 +4141,7 @@ var createServiceContext = ({ signalContext = new import_messaging2.MemorySignal
|
|
|
4136
4141
|
signalManager,
|
|
4137
4142
|
transportFactory: import_network_manager3.MemoryTransportFactory
|
|
4138
4143
|
});
|
|
4139
|
-
const modelFactory =
|
|
4144
|
+
const modelFactory = createDefaultModelFactory();
|
|
4140
4145
|
return new ServiceContext(storage, networkManager, signalManager, modelFactory);
|
|
4141
4146
|
};
|
|
4142
4147
|
var createPeers = async (numPeers) => {
|
|
@@ -4226,7 +4231,7 @@ var TestPeer = class {
|
|
|
4226
4231
|
feedStore: this.feedStore,
|
|
4227
4232
|
networkManager: this.networkManager,
|
|
4228
4233
|
metadataStore: this.metadataStore,
|
|
4229
|
-
modelFactory:
|
|
4234
|
+
modelFactory: createDefaultModelFactory(),
|
|
4230
4235
|
snapshotStore: this.snapshotStore,
|
|
4231
4236
|
blobStore: this.blobStore
|
|
4232
4237
|
});
|