@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "@dxos/node-std/globals"
|
|
1
|
+
import "@dxos/node-std/globals";
|
|
2
2
|
|
|
3
3
|
// packages/sdk/client-services/src/packlets/devtools/feeds.ts
|
|
4
4
|
import { EventSubscriptions } from "@dxos/async";
|
|
@@ -461,7 +461,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
461
461
|
};
|
|
462
462
|
|
|
463
463
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
464
|
-
import
|
|
464
|
+
import invariant from "tiny-invariant";
|
|
465
465
|
import { Event } from "@dxos/async";
|
|
466
466
|
import { AUTH_TIMEOUT, LOAD_CONTROL_FEEDS_TIMEOUT } from "@dxos/client-protocol";
|
|
467
467
|
import { DeviceStateMachine, createCredentialSignerWithKey, createCredentialSignerWithChain, ProfileStateMachine } from "@dxos/credentials";
|
|
@@ -543,7 +543,7 @@ var Identity = class {
|
|
|
543
543
|
* Requires identity to be ready.
|
|
544
544
|
*/
|
|
545
545
|
getIdentityCredentialSigner() {
|
|
546
|
-
|
|
546
|
+
invariant(this._deviceStateMachine.processor.deviceCredentialChain, "Device credential chain is not ready.");
|
|
547
547
|
return createCredentialSignerWithChain(this._signer, this._deviceStateMachine.processor.deviceCredentialChain, this.deviceKey);
|
|
548
548
|
}
|
|
549
549
|
/**
|
|
@@ -604,7 +604,7 @@ var Identity = class {
|
|
|
604
604
|
};
|
|
605
605
|
|
|
606
606
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
607
|
-
import
|
|
607
|
+
import invariant2 from "tiny-invariant";
|
|
608
608
|
import { Event as Event2 } from "@dxos/async";
|
|
609
609
|
import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
|
|
610
610
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
@@ -676,7 +676,7 @@ var IdentityManager = class {
|
|
|
676
676
|
}
|
|
677
677
|
async createIdentity({ displayName } = {}) {
|
|
678
678
|
var _a;
|
|
679
|
-
|
|
679
|
+
invariant2(!this._identity, "Identity already exists.");
|
|
680
680
|
log3("creating identity...", {}, {
|
|
681
681
|
file: "identity-manager.ts",
|
|
682
682
|
line: 94,
|
|
@@ -698,8 +698,8 @@ var IdentityManager = class {
|
|
|
698
698
|
await identity.open();
|
|
699
699
|
{
|
|
700
700
|
const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
701
|
-
|
|
702
|
-
|
|
701
|
+
invariant2(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
|
|
702
|
+
invariant2(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
|
|
703
703
|
const credentials = [
|
|
704
704
|
// Space genesis.
|
|
705
705
|
...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
|
|
@@ -757,7 +757,7 @@ var IdentityManager = class {
|
|
|
757
757
|
scope: this,
|
|
758
758
|
callSite: (f, a) => f(...a)
|
|
759
759
|
});
|
|
760
|
-
|
|
760
|
+
invariant2(!this._identity, "Identity already exists.");
|
|
761
761
|
const identityRecord = {
|
|
762
762
|
identityKey: params.identityKey,
|
|
763
763
|
deviceKey: params.deviceKey,
|
|
@@ -796,7 +796,7 @@ var IdentityManager = class {
|
|
|
796
796
|
return identity;
|
|
797
797
|
}
|
|
798
798
|
async _constructIdentity(identityRecord) {
|
|
799
|
-
|
|
799
|
+
invariant2(!this._identity);
|
|
800
800
|
log3("constructing identity", {
|
|
801
801
|
identityRecord
|
|
802
802
|
}, {
|
|
@@ -805,11 +805,11 @@ var IdentityManager = class {
|
|
|
805
805
|
scope: this,
|
|
806
806
|
callSite: (f, a) => f(...a)
|
|
807
807
|
});
|
|
808
|
-
|
|
808
|
+
invariant2(identityRecord.haloSpace.controlFeedKey);
|
|
809
809
|
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
|
|
810
810
|
writable: true
|
|
811
811
|
});
|
|
812
|
-
|
|
812
|
+
invariant2(identityRecord.haloSpace.dataFeedKey);
|
|
813
813
|
const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
|
|
814
814
|
writable: true,
|
|
815
815
|
sparse: true
|
|
@@ -867,7 +867,7 @@ var IdentityManager = class {
|
|
|
867
867
|
};
|
|
868
868
|
|
|
869
869
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
870
|
-
import
|
|
870
|
+
import invariant3 from "tiny-invariant";
|
|
871
871
|
import { Stream as Stream7 } from "@dxos/codec-protobuf";
|
|
872
872
|
import { signPresentation } from "@dxos/credentials";
|
|
873
873
|
import { todo } from "@dxos/debug";
|
|
@@ -903,7 +903,7 @@ var IdentityServiceImpl = class {
|
|
|
903
903
|
};
|
|
904
904
|
}
|
|
905
905
|
async signPresentation({ presentation, nonce }) {
|
|
906
|
-
|
|
906
|
+
invariant3(this._serviceContext.identityManager.identity, "Identity not initialized.");
|
|
907
907
|
return await signPresentation({
|
|
908
908
|
presentation,
|
|
909
909
|
signer: this._serviceContext.keyring,
|
|
@@ -915,7 +915,7 @@ var IdentityServiceImpl = class {
|
|
|
915
915
|
};
|
|
916
916
|
|
|
917
917
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
918
|
-
import
|
|
918
|
+
import invariant4 from "tiny-invariant";
|
|
919
919
|
import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
|
|
920
920
|
var DeviceInvitationProtocol = class {
|
|
921
921
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
@@ -932,7 +932,7 @@ var DeviceInvitationProtocol = class {
|
|
|
932
932
|
};
|
|
933
933
|
}
|
|
934
934
|
async admit(request) {
|
|
935
|
-
|
|
935
|
+
invariant4(request.device);
|
|
936
936
|
const identity = this._getIdentity();
|
|
937
937
|
await identity.admitDevice(request.device);
|
|
938
938
|
return {
|
|
@@ -960,9 +960,9 @@ var DeviceInvitationProtocol = class {
|
|
|
960
960
|
};
|
|
961
961
|
}
|
|
962
962
|
async accept(response, request) {
|
|
963
|
-
|
|
963
|
+
invariant4(response.device);
|
|
964
964
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
965
|
-
|
|
965
|
+
invariant4(request.device);
|
|
966
966
|
const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
|
|
967
967
|
await this._acceptIdentity({
|
|
968
968
|
identityKey,
|
|
@@ -980,7 +980,7 @@ var DeviceInvitationProtocol = class {
|
|
|
980
980
|
};
|
|
981
981
|
|
|
982
982
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
983
|
-
import
|
|
983
|
+
import invariant6 from "tiny-invariant";
|
|
984
984
|
import { PushStream, scheduleTask as scheduleTask2, TimeoutError, Trigger as Trigger3 } from "@dxos/async";
|
|
985
985
|
import { AuthenticatingInvitationObservable, AUTHENTICATION_CODE_LENGTH, CancellableInvitationObservable, INVITATION_TIMEOUT } from "@dxos/client-protocol";
|
|
986
986
|
import { Context as Context4 } from "@dxos/context";
|
|
@@ -994,7 +994,7 @@ import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/ser
|
|
|
994
994
|
import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
995
995
|
|
|
996
996
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
997
|
-
import
|
|
997
|
+
import invariant5 from "tiny-invariant";
|
|
998
998
|
import { Trigger as Trigger2 } from "@dxos/async";
|
|
999
999
|
import { cancelWithContext, Context as Context3 } from "@dxos/context";
|
|
1000
1000
|
import { InvalidInvitationExtensionRoleError } from "@dxos/errors";
|
|
@@ -1031,7 +1031,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1031
1031
|
// Perhaps in the future we will have more complex logic here.
|
|
1032
1032
|
InvitationHostService: {
|
|
1033
1033
|
options: async (options) => {
|
|
1034
|
-
|
|
1034
|
+
invariant5(!this._remoteOptions, "Remote options already set.");
|
|
1035
1035
|
this._remoteOptions = options;
|
|
1036
1036
|
this._remoteOptionsTrigger.wake();
|
|
1037
1037
|
},
|
|
@@ -1107,7 +1107,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1107
1107
|
callSite: (f, a) => f(...a)
|
|
1108
1108
|
});
|
|
1109
1109
|
let status = AuthenticationResponse.Status.OK;
|
|
1110
|
-
|
|
1110
|
+
invariant5(this.invitation, "Invitation is not set.");
|
|
1111
1111
|
switch (this.invitation.authMethod) {
|
|
1112
1112
|
case Invitation2.AuthMethod.NONE: {
|
|
1113
1113
|
log4("authentication not required", {}, {
|
|
@@ -1171,7 +1171,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1171
1171
|
callSite: (f, a) => f(...a)
|
|
1172
1172
|
});
|
|
1173
1173
|
try {
|
|
1174
|
-
|
|
1174
|
+
invariant5(this.invitation, "Invitation is not set.");
|
|
1175
1175
|
if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
|
|
1176
1176
|
throw new Error("Not authenticated");
|
|
1177
1177
|
}
|
|
@@ -1236,7 +1236,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1236
1236
|
return {
|
|
1237
1237
|
InvitationHostService: {
|
|
1238
1238
|
options: async (options) => {
|
|
1239
|
-
|
|
1239
|
+
invariant5(!this._remoteOptions, "Remote options already set.");
|
|
1240
1240
|
this._remoteOptions = options;
|
|
1241
1241
|
this._remoteOptionsTrigger.wake();
|
|
1242
1242
|
},
|
|
@@ -1315,7 +1315,7 @@ var InvitationsHandler = class {
|
|
|
1315
1315
|
var _a;
|
|
1316
1316
|
const { invitationId = PublicKey5.random().toHex(), type = Invitation3.Type.INTERACTIVE, authMethod = Invitation3.AuthMethod.SHARED_SECRET, state = Invitation3.State.INIT, timeout = INVITATION_TIMEOUT, swarmKey = PublicKey5.random() } = options != null ? options : {};
|
|
1317
1317
|
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0;
|
|
1318
|
-
|
|
1318
|
+
invariant6(protocol);
|
|
1319
1319
|
const invitation = {
|
|
1320
1320
|
invitationId,
|
|
1321
1321
|
type,
|
|
@@ -1362,7 +1362,7 @@ var InvitationsHandler = class {
|
|
|
1362
1362
|
var _a2, _b, _c;
|
|
1363
1363
|
try {
|
|
1364
1364
|
const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
|
|
1365
|
-
|
|
1365
|
+
invariant6(deviceKey);
|
|
1366
1366
|
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1367
1367
|
extension.completedTrigger.wake(deviceKey);
|
|
1368
1368
|
return admissionResponse;
|
|
@@ -1521,13 +1521,13 @@ var InvitationsHandler = class {
|
|
|
1521
1521
|
}
|
|
1522
1522
|
acceptInvitation(protocol, invitation) {
|
|
1523
1523
|
const { timeout = INVITATION_TIMEOUT } = invitation;
|
|
1524
|
-
|
|
1524
|
+
invariant6(protocol);
|
|
1525
1525
|
const authenticated = new Trigger3();
|
|
1526
1526
|
let admitted = false;
|
|
1527
1527
|
let currentState;
|
|
1528
1528
|
const stream = new PushStream();
|
|
1529
1529
|
const setState = (newData) => {
|
|
1530
|
-
|
|
1530
|
+
invariant6(newData.state !== void 0);
|
|
1531
1531
|
currentState = newData.state;
|
|
1532
1532
|
stream.next({
|
|
1533
1533
|
...invitation,
|
|
@@ -1784,7 +1784,7 @@ var InvitationsHandler = class {
|
|
|
1784
1784
|
return extension;
|
|
1785
1785
|
};
|
|
1786
1786
|
scheduleTask2(ctx, async () => {
|
|
1787
|
-
|
|
1787
|
+
invariant6(invitation.swarmKey);
|
|
1788
1788
|
const topic = invitation.swarmKey;
|
|
1789
1789
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1790
1790
|
topic,
|
|
@@ -1817,7 +1817,7 @@ var InvitationsHandler = class {
|
|
|
1817
1817
|
};
|
|
1818
1818
|
|
|
1819
1819
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1820
|
-
import
|
|
1820
|
+
import invariant7 from "tiny-invariant";
|
|
1821
1821
|
import { Event as Event3 } from "@dxos/async";
|
|
1822
1822
|
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
1823
1823
|
import { log as log6 } from "@dxos/log";
|
|
@@ -1888,7 +1888,7 @@ var InvitationsServiceImpl = class {
|
|
|
1888
1888
|
scope: this,
|
|
1889
1889
|
callSite: (f, a) => f(...a)
|
|
1890
1890
|
});
|
|
1891
|
-
|
|
1891
|
+
invariant7(invitationId);
|
|
1892
1892
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1893
1893
|
if (!observable) {
|
|
1894
1894
|
log6.warn("invalid invitation", {
|
|
@@ -1910,7 +1910,7 @@ var InvitationsServiceImpl = class {
|
|
|
1910
1910
|
scope: this,
|
|
1911
1911
|
callSite: (f, a) => f(...a)
|
|
1912
1912
|
});
|
|
1913
|
-
|
|
1913
|
+
invariant7(invitationId);
|
|
1914
1914
|
const created = this._createInvitations.get(invitationId);
|
|
1915
1915
|
const accepted = this._acceptInvitations.get(invitationId);
|
|
1916
1916
|
if (created) {
|
|
@@ -1985,7 +1985,7 @@ var InvitationsServiceImpl = class {
|
|
|
1985
1985
|
};
|
|
1986
1986
|
|
|
1987
1987
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
1988
|
-
import
|
|
1988
|
+
import invariant8 from "tiny-invariant";
|
|
1989
1989
|
import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
|
|
1990
1990
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
1991
1991
|
import { log as log7 } from "@dxos/log";
|
|
@@ -2011,10 +2011,10 @@ var SpaceInvitationProtocol = class {
|
|
|
2011
2011
|
}
|
|
2012
2012
|
async admit(request, guestProfile) {
|
|
2013
2013
|
var _a;
|
|
2014
|
-
|
|
2014
|
+
invariant8(this._spaceKey);
|
|
2015
2015
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2016
|
-
|
|
2017
|
-
|
|
2016
|
+
invariant8(space);
|
|
2017
|
+
invariant8(request.space);
|
|
2018
2018
|
const { identityKey, deviceKey } = request.space;
|
|
2019
2019
|
log7("writing guest credentials", {
|
|
2020
2020
|
host: this._signingContext.deviceKey,
|
|
@@ -2026,9 +2026,9 @@ var SpaceInvitationProtocol = class {
|
|
|
2026
2026
|
callSite: (f, a) => f(...a)
|
|
2027
2027
|
});
|
|
2028
2028
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2029
|
-
|
|
2029
|
+
invariant8(credentials[0].credential);
|
|
2030
2030
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2031
|
-
|
|
2031
|
+
invariant8(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2032
2032
|
await writeMessages2(space.inner.controlPipeline.writer, credentials);
|
|
2033
2033
|
return {
|
|
2034
2034
|
space: {
|
|
@@ -2056,11 +2056,11 @@ var SpaceInvitationProtocol = class {
|
|
|
2056
2056
|
};
|
|
2057
2057
|
}
|
|
2058
2058
|
async accept(response) {
|
|
2059
|
-
|
|
2059
|
+
invariant8(response.space);
|
|
2060
2060
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2061
2061
|
const assertion = getCredentialAssertion(credential);
|
|
2062
|
-
|
|
2063
|
-
|
|
2062
|
+
invariant8(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
|
|
2063
|
+
invariant8(credential.subject.id.equals(this._signingContext.identityKey));
|
|
2064
2064
|
await this._spaceManager.acceptSpace({
|
|
2065
2065
|
spaceKey: assertion.spaceKey,
|
|
2066
2066
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -2089,7 +2089,7 @@ import { Timeframe } from "@dxos/timeframe";
|
|
|
2089
2089
|
import { ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
2090
2090
|
|
|
2091
2091
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2092
|
-
import
|
|
2092
|
+
import invariant9 from "tiny-invariant";
|
|
2093
2093
|
import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2094
2094
|
import { Context as Context5, rejectOnDispose } from "@dxos/context";
|
|
2095
2095
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
@@ -2126,7 +2126,7 @@ var NotarizationPlugin = class {
|
|
|
2126
2126
|
scope: this,
|
|
2127
2127
|
callSite: (f, a) => f(...a)
|
|
2128
2128
|
});
|
|
2129
|
-
|
|
2129
|
+
invariant9(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
2130
2130
|
const errors = new Trigger4();
|
|
2131
2131
|
const ctx = this._ctx.derive({
|
|
2132
2132
|
onError: (err) => {
|
|
@@ -2244,7 +2244,7 @@ var NotarizationPlugin = class {
|
|
|
2244
2244
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2245
2245
|
}
|
|
2246
2246
|
setWriter(writer) {
|
|
2247
|
-
|
|
2247
|
+
invariant9(!this._writer, "Writer already set.");
|
|
2248
2248
|
this._writer = writer;
|
|
2249
2249
|
}
|
|
2250
2250
|
async _waitUntilProcessed(id) {
|
|
@@ -2262,7 +2262,7 @@ var NotarizationPlugin = class {
|
|
|
2262
2262
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2263
2263
|
}
|
|
2264
2264
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2265
|
-
|
|
2265
|
+
invariant9(credential.id, "Credential must have an id");
|
|
2266
2266
|
if (this._processedCredentials.has(credential.id)) {
|
|
2267
2267
|
continue;
|
|
2268
2268
|
}
|
|
@@ -2577,7 +2577,7 @@ DataSpace = __decorate([
|
|
|
2577
2577
|
], DataSpace);
|
|
2578
2578
|
|
|
2579
2579
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2580
|
-
import
|
|
2580
|
+
import invariant10 from "tiny-invariant";
|
|
2581
2581
|
import { Event as Event6, synchronized, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
2582
2582
|
import { cancelWithContext as cancelWithContext3, Context as Context7 } from "@dxos/context";
|
|
2583
2583
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
@@ -2763,7 +2763,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2763
2763
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
2764
2764
|
*/
|
|
2765
2765
|
async createSpace() {
|
|
2766
|
-
|
|
2766
|
+
invariant10(this._isOpen, "Not open.");
|
|
2767
2767
|
const spaceKey = await this._keyring.createKey();
|
|
2768
2768
|
const controlFeedKey = await this._keyring.createKey();
|
|
2769
2769
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -2785,7 +2785,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2785
2785
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2786
2786
|
await this._metadataStore.addSpace(metadata);
|
|
2787
2787
|
const memberCredential = credentials[1];
|
|
2788
|
-
|
|
2788
|
+
invariant10(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2789
2789
|
await this._signingContext.recordCredential(memberCredential);
|
|
2790
2790
|
await space.initializeDataPipeline();
|
|
2791
2791
|
this.updated.emit();
|
|
@@ -2801,8 +2801,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2801
2801
|
scope: this,
|
|
2802
2802
|
callSite: (f, a) => f(...a)
|
|
2803
2803
|
});
|
|
2804
|
-
|
|
2805
|
-
|
|
2804
|
+
invariant10(this._isOpen, "Not open.");
|
|
2805
|
+
invariant10(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
2806
2806
|
const metadata = {
|
|
2807
2807
|
key: opts.spaceKey,
|
|
2808
2808
|
genesisFeedKey: opts.genesisFeedKey,
|
|
@@ -2831,7 +2831,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2831
2831
|
metadata
|
|
2832
2832
|
}, {
|
|
2833
2833
|
file: "data-space-manager.ts",
|
|
2834
|
-
line:
|
|
2834
|
+
line: 180,
|
|
2835
2835
|
scope: this,
|
|
2836
2836
|
callSite: (f, a) => f(...a)
|
|
2837
2837
|
});
|
|
@@ -2867,7 +2867,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2867
2867
|
onAuthFailure: () => {
|
|
2868
2868
|
log10.warn("auth failure", {}, {
|
|
2869
2869
|
file: "data-space-manager.ts",
|
|
2870
|
-
line:
|
|
2870
|
+
line: 211,
|
|
2871
2871
|
scope: this,
|
|
2872
2872
|
callSite: (f, a) => f(...a)
|
|
2873
2873
|
});
|
|
@@ -2890,7 +2890,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2890
2890
|
space: space.key
|
|
2891
2891
|
}, {
|
|
2892
2892
|
file: "data-space-manager.ts",
|
|
2893
|
-
line:
|
|
2893
|
+
line: 228,
|
|
2894
2894
|
scope: this,
|
|
2895
2895
|
callSite: (f, a) => f(...a)
|
|
2896
2896
|
});
|
|
@@ -2902,7 +2902,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2902
2902
|
open: this._isOpen
|
|
2903
2903
|
}, {
|
|
2904
2904
|
file: "data-space-manager.ts",
|
|
2905
|
-
line:
|
|
2905
|
+
line: 235,
|
|
2906
2906
|
scope: this,
|
|
2907
2907
|
callSite: (f, a) => f(...a)
|
|
2908
2908
|
});
|
|
@@ -3105,7 +3105,7 @@ var SpacesServiceImpl = class {
|
|
|
3105
3105
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
3106
3106
|
|
|
3107
3107
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3108
|
-
import
|
|
3108
|
+
import invariant11 from "tiny-invariant";
|
|
3109
3109
|
import { Trigger as Trigger5 } from "@dxos/async";
|
|
3110
3110
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
3111
3111
|
import { failUndefined as failUndefined3 } from "@dxos/debug";
|
|
@@ -3224,7 +3224,7 @@ var ServiceContext = class {
|
|
|
3224
3224
|
}
|
|
3225
3225
|
getInvitationHandler(invitation) {
|
|
3226
3226
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3227
|
-
|
|
3227
|
+
invariant11(factory, `Unknown invitation kind: ${invitation.kind}`);
|
|
3228
3228
|
return factory(invitation);
|
|
3229
3229
|
}
|
|
3230
3230
|
async _acceptIdentity(params) {
|
|
@@ -3264,7 +3264,7 @@ var ServiceContext = class {
|
|
|
3264
3264
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3265
3265
|
await this.dataSpaceManager.open();
|
|
3266
3266
|
this._handlerFactories.set(Invitation5.Kind.SPACE, (invitation) => {
|
|
3267
|
-
|
|
3267
|
+
invariant11(this.dataSpaceManager, "dataSpaceManager not initialized yet");
|
|
3268
3268
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3269
3269
|
});
|
|
3270
3270
|
this.initialized.wake();
|
|
@@ -3525,16 +3525,19 @@ var ServiceRegistry = class {
|
|
|
3525
3525
|
};
|
|
3526
3526
|
|
|
3527
3527
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3528
|
-
import
|
|
3528
|
+
import invariant12 from "tiny-invariant";
|
|
3529
3529
|
import { Event as Event8, synchronized as synchronized2 } from "@dxos/async";
|
|
3530
|
-
import { clientServiceBundle
|
|
3530
|
+
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
3531
|
+
import { DocumentModel } from "@dxos/document-model";
|
|
3531
3532
|
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
3532
3533
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3533
3534
|
import { log as log15 } from "@dxos/log";
|
|
3534
3535
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
3536
|
+
import { ModelFactory } from "@dxos/model-factory";
|
|
3535
3537
|
import { createWebRTCTransportFactory, NetworkManager } from "@dxos/network-manager";
|
|
3536
3538
|
import { trace as trace6 } from "@dxos/protocols";
|
|
3537
3539
|
import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
3540
|
+
import { TextModel } from "@dxos/text-model";
|
|
3538
3541
|
|
|
3539
3542
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3540
3543
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
@@ -3740,6 +3743,9 @@ var __decorate4 = function(decorators, target, key, desc) {
|
|
|
3740
3743
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3741
3744
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3742
3745
|
};
|
|
3746
|
+
var createDefaultModelFactory = () => {
|
|
3747
|
+
return new ModelFactory().registerModel(DocumentModel).registerModel(TextModel);
|
|
3748
|
+
};
|
|
3743
3749
|
var ClientServicesHost = class {
|
|
3744
3750
|
constructor({
|
|
3745
3751
|
config,
|
|
@@ -3815,9 +3821,9 @@ var ClientServicesHost = class {
|
|
|
3815
3821
|
*/
|
|
3816
3822
|
initialize({ config, ...options }) {
|
|
3817
3823
|
var _a, _b, _c;
|
|
3818
|
-
|
|
3824
|
+
invariant12(!this._open, "service host is open");
|
|
3819
3825
|
if (config) {
|
|
3820
|
-
|
|
3826
|
+
invariant12(!this._config, "config already set");
|
|
3821
3827
|
this._config = config;
|
|
3822
3828
|
if (!this._storage) {
|
|
3823
3829
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
@@ -3827,7 +3833,7 @@ var ClientServicesHost = class {
|
|
|
3827
3833
|
iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
|
|
3828
3834
|
}), signalManager = new WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
|
|
3829
3835
|
this._signalManager = signalManager;
|
|
3830
|
-
|
|
3836
|
+
invariant12(!this._networkManager, "network manager already set");
|
|
3831
3837
|
this._networkManager = new NetworkManager({
|
|
3832
3838
|
log: connectionLog,
|
|
3833
3839
|
transportFactory,
|
|
@@ -3844,20 +3850,20 @@ var ClientServicesHost = class {
|
|
|
3844
3850
|
id: traceId
|
|
3845
3851
|
}), {
|
|
3846
3852
|
file: "service-host.ts",
|
|
3847
|
-
line:
|
|
3853
|
+
line: 195,
|
|
3848
3854
|
scope: this,
|
|
3849
3855
|
callSite: (f, a) => f(...a)
|
|
3850
3856
|
});
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3857
|
+
invariant12(this._config, "config not set");
|
|
3858
|
+
invariant12(this._storage, "storage not set");
|
|
3859
|
+
invariant12(this._signalManager, "signal manager not set");
|
|
3860
|
+
invariant12(this._networkManager, "network manager not set");
|
|
3855
3861
|
this._opening = true;
|
|
3856
3862
|
log15("opening...", {
|
|
3857
3863
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
3858
3864
|
}, {
|
|
3859
3865
|
file: "service-host.ts",
|
|
3860
|
-
line:
|
|
3866
|
+
line: 203,
|
|
3861
3867
|
scope: this,
|
|
3862
3868
|
callSite: (f, a) => f(...a)
|
|
3863
3869
|
});
|
|
@@ -3892,7 +3898,7 @@ var ClientServicesHost = class {
|
|
|
3892
3898
|
deviceKey
|
|
3893
3899
|
}, {
|
|
3894
3900
|
file: "service-host.ts",
|
|
3895
|
-
line:
|
|
3901
|
+
line: 258,
|
|
3896
3902
|
scope: this,
|
|
3897
3903
|
callSite: (f, a) => f(...a)
|
|
3898
3904
|
});
|
|
@@ -3900,7 +3906,7 @@ var ClientServicesHost = class {
|
|
|
3900
3906
|
id: traceId
|
|
3901
3907
|
}), {
|
|
3902
3908
|
file: "service-host.ts",
|
|
3903
|
-
line:
|
|
3909
|
+
line: 259,
|
|
3904
3910
|
scope: this,
|
|
3905
3911
|
callSite: (f, a) => f(...a)
|
|
3906
3912
|
});
|
|
@@ -3915,7 +3921,7 @@ var ClientServicesHost = class {
|
|
|
3915
3921
|
deviceKey
|
|
3916
3922
|
}, {
|
|
3917
3923
|
file: "service-host.ts",
|
|
3918
|
-
line:
|
|
3924
|
+
line: 269,
|
|
3919
3925
|
scope: this,
|
|
3920
3926
|
callSite: (f, a) => f(...a)
|
|
3921
3927
|
});
|
|
@@ -3930,7 +3936,7 @@ var ClientServicesHost = class {
|
|
|
3930
3936
|
deviceKey
|
|
3931
3937
|
}, {
|
|
3932
3938
|
file: "service-host.ts",
|
|
3933
|
-
line:
|
|
3939
|
+
line: 275,
|
|
3934
3940
|
scope: this,
|
|
3935
3941
|
callSite: (f, a) => f(...a)
|
|
3936
3942
|
});
|
|
@@ -3942,13 +3948,13 @@ var ClientServicesHost = class {
|
|
|
3942
3948
|
id: traceId
|
|
3943
3949
|
}), {
|
|
3944
3950
|
file: "service-host.ts",
|
|
3945
|
-
line:
|
|
3951
|
+
line: 280,
|
|
3946
3952
|
scope: this,
|
|
3947
3953
|
callSite: (f, a) => f(...a)
|
|
3948
3954
|
});
|
|
3949
3955
|
log15("resetting...", {}, {
|
|
3950
3956
|
file: "service-host.ts",
|
|
3951
|
-
line:
|
|
3957
|
+
line: 282,
|
|
3952
3958
|
scope: this,
|
|
3953
3959
|
callSite: (f, a) => f(...a)
|
|
3954
3960
|
});
|
|
@@ -3956,7 +3962,7 @@ var ClientServicesHost = class {
|
|
|
3956
3962
|
await this._storage.reset();
|
|
3957
3963
|
log15("reset", {}, {
|
|
3958
3964
|
file: "service-host.ts",
|
|
3959
|
-
line:
|
|
3965
|
+
line: 285,
|
|
3960
3966
|
scope: this,
|
|
3961
3967
|
callSite: (f, a) => f(...a)
|
|
3962
3968
|
});
|
|
@@ -3964,7 +3970,7 @@ var ClientServicesHost = class {
|
|
|
3964
3970
|
id: traceId
|
|
3965
3971
|
}), {
|
|
3966
3972
|
file: "service-host.ts",
|
|
3967
|
-
line:
|
|
3973
|
+
line: 286,
|
|
3968
3974
|
scope: this,
|
|
3969
3975
|
callSite: (f, a) => f(...a)
|
|
3970
3976
|
});
|
|
@@ -4005,6 +4011,7 @@ export {
|
|
|
4005
4011
|
isLocked,
|
|
4006
4012
|
createStorageObjects,
|
|
4007
4013
|
ServiceRegistry,
|
|
4014
|
+
createDefaultModelFactory,
|
|
4008
4015
|
ClientServicesHost
|
|
4009
4016
|
};
|
|
4010
|
-
//# sourceMappingURL=chunk-
|
|
4017
|
+
//# sourceMappingURL=chunk-O5T3BZYP.mjs.map
|