@dxos/client-services 0.7.5-main.9d2a38b → 0.7.5-main.e9bb01b
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-RFZHCLFI.mjs → chunk-O46EJ5BJ.mjs} +69 -55
- package/dist/lib/browser/chunk-O46EJ5BJ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-WCTGAZLA.cjs → chunk-WFDMSV4I.cjs} +67 -53
- package/dist/lib/node/chunk-WFDMSV4I.cjs.map +7 -0
- package/dist/lib/node/index.cjs +47 -47
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +8 -8
- package/dist/lib/node-esm/{chunk-RSOLUJE6.mjs → chunk-UWR5XM7L.mjs} +69 -55
- package/dist/lib/node-esm/chunk-UWR5XM7L.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/utils.d.ts +1 -0
- package/dist/types/src/packlets/invitations/utils.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +38 -38
- package/src/packlets/invitations/invitations-handler.ts +15 -6
- package/src/packlets/invitations/invitations-manager.ts +1 -1
- package/src/packlets/invitations/space-invitation-protocol.ts +2 -3
- package/src/packlets/invitations/utils.ts +7 -0
- package/src/packlets/spaces/data-space-manager.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-RFZHCLFI.mjs.map +0 -7
- package/dist/lib/node/chunk-WCTGAZLA.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-RSOLUJE6.mjs.map +0 -7
|
@@ -32,7 +32,7 @@ __export(testing_exports, {
|
|
|
32
32
|
sanitizeInvitation: () => sanitizeInvitation
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(testing_exports);
|
|
35
|
-
var
|
|
35
|
+
var import_chunk_WFDMSV4I = require("../chunk-WFDMSV4I.cjs");
|
|
36
36
|
var import_credentials = require("@dxos/credentials");
|
|
37
37
|
var import_keys = require("@dxos/keys");
|
|
38
38
|
var import_async = require("@dxos/async");
|
|
@@ -235,7 +235,7 @@ var createInvitation = async (host, options) => {
|
|
|
235
235
|
authMethod: import_services.Invitation.AuthMethod.NONE,
|
|
236
236
|
...options ?? {}
|
|
237
237
|
};
|
|
238
|
-
if (host instanceof
|
|
238
|
+
if (host instanceof import_chunk_WFDMSV4I.ServiceContext) {
|
|
239
239
|
return host.invitationsManager.createInvitation({
|
|
240
240
|
kind: import_services.Invitation.Kind.SPACE,
|
|
241
241
|
...options
|
|
@@ -245,7 +245,7 @@ var createInvitation = async (host, options) => {
|
|
|
245
245
|
};
|
|
246
246
|
var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
|
|
247
247
|
invitation = sanitizeInvitation(invitation);
|
|
248
|
-
if (guest instanceof
|
|
248
|
+
if (guest instanceof import_chunk_WFDMSV4I.ServiceContext) {
|
|
249
249
|
return guest.invitationsManager.acceptInvitation({
|
|
250
250
|
invitation,
|
|
251
251
|
deviceProfile: guestDeviceProfile
|
|
@@ -255,7 +255,7 @@ var acceptInvitation = (guest, invitation, guestDeviceProfile) => {
|
|
|
255
255
|
};
|
|
256
256
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/testing/test-builder.ts";
|
|
257
257
|
var createServiceHost = (config, signalManagerContext) => {
|
|
258
|
-
return new
|
|
258
|
+
return new import_chunk_WFDMSV4I.ClientServicesHost({
|
|
259
259
|
config,
|
|
260
260
|
signalManager: new import_messaging.MemorySignalManager(signalManagerContext),
|
|
261
261
|
transportFactory: import_network_manager.MemoryTransportFactory
|
|
@@ -274,7 +274,7 @@ var createServiceContext = async ({ signalManagerFactory = async () => {
|
|
|
274
274
|
});
|
|
275
275
|
const level = (0, import_testing.createTestLevel)();
|
|
276
276
|
await level.open();
|
|
277
|
-
return new
|
|
277
|
+
return new import_chunk_WFDMSV4I.ServiceContext(storage, level, networkManager, signalManager, void 0, void 0, {
|
|
278
278
|
invitationConnectionDefaultParams: {
|
|
279
279
|
teleport: {
|
|
280
280
|
controlHeartbeatInterval: 200
|
|
@@ -385,7 +385,7 @@ var TestPeer = class {
|
|
|
385
385
|
return this._props.meshEchoReplicator ??= new import_echo_pipeline.MeshEchoReplicator();
|
|
386
386
|
}
|
|
387
387
|
get dataSpaceManager() {
|
|
388
|
-
return this._props.dataSpaceManager ??= new
|
|
388
|
+
return this._props.dataSpaceManager ??= new import_chunk_WFDMSV4I.DataSpaceManager({
|
|
389
389
|
spaceManager: this.spaceManager,
|
|
390
390
|
metadataStore: this.metadataStore,
|
|
391
391
|
keyring: this.keyring,
|
|
@@ -400,9 +400,9 @@ var TestPeer = class {
|
|
|
400
400
|
});
|
|
401
401
|
}
|
|
402
402
|
get invitationsManager() {
|
|
403
|
-
return this._props.invitationsManager ??= new
|
|
403
|
+
return this._props.invitationsManager ??= new import_chunk_WFDMSV4I.InvitationsManager(new import_chunk_WFDMSV4I.InvitationsHandler(this.networkManager), (invitation) => {
|
|
404
404
|
if (invitation.kind === import_services2.Invitation.Kind.SPACE) {
|
|
405
|
-
return new
|
|
405
|
+
return new import_chunk_WFDMSV4I.SpaceInvitationProtocol(this.dataSpaceManager, this.identity, this.keyring, invitation.spaceKey);
|
|
406
406
|
} else {
|
|
407
407
|
throw new Error("not implemented");
|
|
408
408
|
}
|
|
@@ -397,7 +397,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
|
397
397
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
398
398
|
|
|
399
399
|
// packages/sdk/client-services/src/version.ts
|
|
400
|
-
var DXOS_VERSION = "0.7.5-main.
|
|
400
|
+
var DXOS_VERSION = "0.7.5-main.e9bb01b";
|
|
401
401
|
|
|
402
402
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
403
403
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -2570,7 +2570,7 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2570
2570
|
guestKeypair: invitation.guestKey ? {
|
|
2571
2571
|
publicKey: invitation.guestKey
|
|
2572
2572
|
} : void 0,
|
|
2573
|
-
lifetime: invitation.expiresOn ? invitation.expiresOn.getTime() - Date.now() : void 0,
|
|
2573
|
+
lifetime: invitation.expiresOn ? (invitation.expiresOn.getTime() - Date.now()) / 1e3 : void 0,
|
|
2574
2574
|
multiUse: invitation.multiUse,
|
|
2575
2575
|
delegationCredentialId: credentialId,
|
|
2576
2576
|
persistent: false
|
|
@@ -4627,14 +4627,14 @@ var DeviceInvitationProtocol = class {
|
|
|
4627
4627
|
|
|
4628
4628
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
4629
4629
|
import { scheduleTask as scheduleTask7, TimeoutError as TimeoutError2 } from "@dxos/async";
|
|
4630
|
-
import { INVITATION_TIMEOUT } from "@dxos/client-protocol";
|
|
4630
|
+
import { INVITATION_TIMEOUT, getExpirationTime } from "@dxos/client-protocol";
|
|
4631
4631
|
import { ContextDisposedError as ContextDisposedError3 } from "@dxos/context";
|
|
4632
4632
|
import { createKeyPair, sign as sign2 } from "@dxos/crypto";
|
|
4633
4633
|
import { invariant as invariant15 } from "@dxos/invariant";
|
|
4634
4634
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4635
4635
|
import { log as log17 } from "@dxos/log";
|
|
4636
4636
|
import { createTeleportProtocolFactory } from "@dxos/network-manager";
|
|
4637
|
-
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace7 } from "@dxos/protocols";
|
|
4637
|
+
import { InvalidInvitationError, InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace7 } from "@dxos/protocols";
|
|
4638
4638
|
import { Invitation as Invitation7 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4639
4639
|
import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
4640
4640
|
import { InvitationOptions as InvitationOptions4 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
@@ -4657,6 +4657,12 @@ import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/ser
|
|
|
4657
4657
|
var stateToString = (state) => {
|
|
4658
4658
|
return Object.entries(Invitation3.State).find(([key, val]) => val === state)?.[0] ?? "unknown";
|
|
4659
4659
|
};
|
|
4660
|
+
var computeExpirationTime = (invitation) => {
|
|
4661
|
+
if (!invitation.lifetime) {
|
|
4662
|
+
return;
|
|
4663
|
+
}
|
|
4664
|
+
return new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime * 1e3);
|
|
4665
|
+
};
|
|
4660
4666
|
var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
|
|
4661
4667
|
let guard;
|
|
4662
4668
|
return cancelWithContext3(ctx, (async () => {
|
|
@@ -5672,18 +5678,19 @@ var InvitationsHandler = class {
|
|
|
5672
5678
|
});
|
|
5673
5679
|
return extension;
|
|
5674
5680
|
};
|
|
5675
|
-
|
|
5676
|
-
|
|
5681
|
+
const expiresOn = getExpirationTime(invitation);
|
|
5682
|
+
if (expiresOn) {
|
|
5683
|
+
if (expiresOn.getTime() < Date.now()) {
|
|
5677
5684
|
log17.warn("invitation has already expired", void 0, {
|
|
5678
5685
|
F: __dxlog_file21,
|
|
5679
|
-
L:
|
|
5686
|
+
L: 194,
|
|
5680
5687
|
S: this,
|
|
5681
5688
|
C: (f, a) => f(...a)
|
|
5682
5689
|
});
|
|
5683
5690
|
guardedState.set(null, Invitation7.State.EXPIRED);
|
|
5684
5691
|
void ctx.dispose().catch((err) => log17.catch(err, void 0, {
|
|
5685
5692
|
F: __dxlog_file21,
|
|
5686
|
-
L:
|
|
5693
|
+
L: 196,
|
|
5687
5694
|
S: this,
|
|
5688
5695
|
C: (f, a) => f(...a)
|
|
5689
5696
|
}));
|
|
@@ -5694,7 +5701,7 @@ var InvitationsHandler = class {
|
|
|
5694
5701
|
guardedState.set(null, Invitation7.State.EXPIRED);
|
|
5695
5702
|
metrics.increment("dxos.invitation.expired");
|
|
5696
5703
|
await ctx.dispose();
|
|
5697
|
-
},
|
|
5704
|
+
}, expiresOn.getTime() - Date.now());
|
|
5698
5705
|
}
|
|
5699
5706
|
let swarmConnection;
|
|
5700
5707
|
scheduleTask7(ctx, async () => {
|
|
@@ -5710,7 +5717,7 @@ var InvitationsHandler = class {
|
|
|
5710
5717
|
type: invitation.type
|
|
5711
5718
|
}, {
|
|
5712
5719
|
F: __dxlog_file21,
|
|
5713
|
-
L:
|
|
5720
|
+
L: 227,
|
|
5714
5721
|
S: this,
|
|
5715
5722
|
C: (f, a) => f(...a)
|
|
5716
5723
|
});
|
|
@@ -5718,7 +5725,7 @@ var InvitationsHandler = class {
|
|
|
5718
5725
|
if (deviceProfile) {
|
|
5719
5726
|
invariant15(invitation.kind === Invitation7.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
5720
5727
|
F: __dxlog_file21,
|
|
5721
|
-
L:
|
|
5728
|
+
L: 236,
|
|
5722
5729
|
S: this,
|
|
5723
5730
|
A: [
|
|
5724
5731
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -5736,7 +5743,7 @@ var InvitationsHandler = class {
|
|
|
5736
5743
|
triedPeers: triedPeersIds.size
|
|
5737
5744
|
}, {
|
|
5738
5745
|
F: __dxlog_file21,
|
|
5739
|
-
L:
|
|
5746
|
+
L: 244,
|
|
5740
5747
|
S: this,
|
|
5741
5748
|
C: (f, a) => f(...a)
|
|
5742
5749
|
});
|
|
@@ -5763,7 +5770,7 @@ var InvitationsHandler = class {
|
|
|
5763
5770
|
currentState: guardedState.current.state
|
|
5764
5771
|
}, {
|
|
5765
5772
|
F: __dxlog_file21,
|
|
5766
|
-
L:
|
|
5773
|
+
L: 272,
|
|
5767
5774
|
S: this,
|
|
5768
5775
|
C: (f, a) => f(...a)
|
|
5769
5776
|
});
|
|
@@ -5781,7 +5788,7 @@ var InvitationsHandler = class {
|
|
|
5781
5788
|
id: traceId
|
|
5782
5789
|
}), {
|
|
5783
5790
|
F: __dxlog_file21,
|
|
5784
|
-
L:
|
|
5791
|
+
L: 284,
|
|
5785
5792
|
S: this,
|
|
5786
5793
|
C: (f, a) => f(...a)
|
|
5787
5794
|
});
|
|
@@ -5793,7 +5800,7 @@ var InvitationsHandler = class {
|
|
|
5793
5800
|
...protocol.toJSON()
|
|
5794
5801
|
}, {
|
|
5795
5802
|
F: __dxlog_file21,
|
|
5796
|
-
L:
|
|
5803
|
+
L: 295,
|
|
5797
5804
|
S: this,
|
|
5798
5805
|
C: (f, a) => f(...a)
|
|
5799
5806
|
});
|
|
@@ -5803,7 +5810,7 @@ var InvitationsHandler = class {
|
|
|
5803
5810
|
...protocol.toJSON()
|
|
5804
5811
|
}, {
|
|
5805
5812
|
F: __dxlog_file21,
|
|
5806
|
-
L:
|
|
5813
|
+
L: 299,
|
|
5807
5814
|
S: this,
|
|
5808
5815
|
C: (f, a) => f(...a)
|
|
5809
5816
|
});
|
|
@@ -5817,7 +5824,7 @@ var InvitationsHandler = class {
|
|
|
5817
5824
|
authMethod: introductionResponse.authMethod
|
|
5818
5825
|
}, {
|
|
5819
5826
|
F: __dxlog_file21,
|
|
5820
|
-
L:
|
|
5827
|
+
L: 307,
|
|
5821
5828
|
S: this,
|
|
5822
5829
|
C: (f, a) => f(...a)
|
|
5823
5830
|
});
|
|
@@ -5839,7 +5846,7 @@ var InvitationsHandler = class {
|
|
|
5839
5846
|
...protocol.toJSON()
|
|
5840
5847
|
}, {
|
|
5841
5848
|
F: __dxlog_file21,
|
|
5842
|
-
L:
|
|
5849
|
+
L: 337,
|
|
5843
5850
|
S: this,
|
|
5844
5851
|
C: (f, a) => f(...a)
|
|
5845
5852
|
});
|
|
@@ -5852,7 +5859,7 @@ var InvitationsHandler = class {
|
|
|
5852
5859
|
...protocol.toJSON()
|
|
5853
5860
|
}, {
|
|
5854
5861
|
F: __dxlog_file21,
|
|
5855
|
-
L:
|
|
5862
|
+
L: 351,
|
|
5856
5863
|
S: this,
|
|
5857
5864
|
C: (f, a) => f(...a)
|
|
5858
5865
|
});
|
|
@@ -5865,7 +5872,7 @@ var InvitationsHandler = class {
|
|
|
5865
5872
|
id: traceId
|
|
5866
5873
|
}), {
|
|
5867
5874
|
F: __dxlog_file21,
|
|
5868
|
-
L:
|
|
5875
|
+
L: 360,
|
|
5869
5876
|
S: this,
|
|
5870
5877
|
C: (f, a) => f(...a)
|
|
5871
5878
|
});
|
|
@@ -5875,7 +5882,7 @@ var InvitationsHandler = class {
|
|
|
5875
5882
|
...protocol.toJSON()
|
|
5876
5883
|
}, {
|
|
5877
5884
|
F: __dxlog_file21,
|
|
5878
|
-
L:
|
|
5885
|
+
L: 363,
|
|
5879
5886
|
S: this,
|
|
5880
5887
|
C: (f, a) => f(...a)
|
|
5881
5888
|
});
|
|
@@ -5883,7 +5890,7 @@ var InvitationsHandler = class {
|
|
|
5883
5890
|
} else {
|
|
5884
5891
|
log17.verbose("auth failed", err, {
|
|
5885
5892
|
F: __dxlog_file21,
|
|
5886
|
-
L:
|
|
5893
|
+
L: 366,
|
|
5887
5894
|
S: this,
|
|
5888
5895
|
C: (f, a) => f(...a)
|
|
5889
5896
|
});
|
|
@@ -5895,7 +5902,7 @@ var InvitationsHandler = class {
|
|
|
5895
5902
|
error: err
|
|
5896
5903
|
}), {
|
|
5897
5904
|
F: __dxlog_file21,
|
|
5898
|
-
L:
|
|
5905
|
+
L: 370,
|
|
5899
5906
|
S: this,
|
|
5900
5907
|
C: (f, a) => f(...a)
|
|
5901
5908
|
});
|
|
@@ -5911,7 +5918,7 @@ var InvitationsHandler = class {
|
|
|
5911
5918
|
...protocol.toJSON()
|
|
5912
5919
|
}, {
|
|
5913
5920
|
F: __dxlog_file21,
|
|
5914
|
-
L:
|
|
5921
|
+
L: 379,
|
|
5915
5922
|
S: this,
|
|
5916
5923
|
C: (f, a) => f(...a)
|
|
5917
5924
|
});
|
|
@@ -5919,7 +5926,7 @@ var InvitationsHandler = class {
|
|
|
5919
5926
|
} else {
|
|
5920
5927
|
log17.verbose("auth failed", err, {
|
|
5921
5928
|
F: __dxlog_file21,
|
|
5922
|
-
L:
|
|
5929
|
+
L: 382,
|
|
5923
5930
|
S: this,
|
|
5924
5931
|
C: (f, a) => f(...a)
|
|
5925
5932
|
});
|
|
@@ -5936,7 +5943,7 @@ var InvitationsHandler = class {
|
|
|
5936
5943
|
...protocol.toJSON()
|
|
5937
5944
|
}, {
|
|
5938
5945
|
F: __dxlog_file21,
|
|
5939
|
-
L:
|
|
5946
|
+
L: 394,
|
|
5940
5947
|
S: this,
|
|
5941
5948
|
C: (f, a) => f(...a)
|
|
5942
5949
|
});
|
|
@@ -5949,14 +5956,14 @@ var InvitationsHandler = class {
|
|
|
5949
5956
|
});
|
|
5950
5957
|
edgeInvitationHandler.handle(ctx, guardedState, protocol, deviceProfile);
|
|
5951
5958
|
scheduleTask7(ctx, async () => {
|
|
5952
|
-
const error =
|
|
5959
|
+
const error = checkInvitation(protocol, invitation);
|
|
5953
5960
|
if (error) {
|
|
5954
5961
|
stream.error(error);
|
|
5955
5962
|
await ctx.dispose();
|
|
5956
5963
|
} else {
|
|
5957
5964
|
invariant15(invitation.swarmKey, void 0, {
|
|
5958
5965
|
F: __dxlog_file21,
|
|
5959
|
-
L:
|
|
5966
|
+
L: 406,
|
|
5960
5967
|
S: this,
|
|
5961
5968
|
A: [
|
|
5962
5969
|
"invitation.swarmKey",
|
|
@@ -6000,7 +6007,7 @@ var InvitationsHandler = class {
|
|
|
6000
6007
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
6001
6008
|
log17("guest waiting for authentication code...", void 0, {
|
|
6002
6009
|
F: __dxlog_file21,
|
|
6003
|
-
L:
|
|
6010
|
+
L: 458,
|
|
6004
6011
|
S: this,
|
|
6005
6012
|
C: (f, a) => f(...a)
|
|
6006
6013
|
});
|
|
@@ -6008,7 +6015,7 @@ var InvitationsHandler = class {
|
|
|
6008
6015
|
const authCode = await authenticated.wait(options);
|
|
6009
6016
|
log17("sending authentication request", void 0, {
|
|
6010
6017
|
F: __dxlog_file21,
|
|
6011
|
-
L:
|
|
6018
|
+
L: 462,
|
|
6012
6019
|
S: this,
|
|
6013
6020
|
C: (f, a) => f(...a)
|
|
6014
6021
|
});
|
|
@@ -6027,7 +6034,7 @@ var InvitationsHandler = class {
|
|
|
6027
6034
|
attempt
|
|
6028
6035
|
}, {
|
|
6029
6036
|
F: __dxlog_file21,
|
|
6030
|
-
L:
|
|
6037
|
+
L: 473,
|
|
6031
6038
|
S: this,
|
|
6032
6039
|
C: (f, a) => f(...a)
|
|
6033
6040
|
});
|
|
@@ -6045,7 +6052,7 @@ var InvitationsHandler = class {
|
|
|
6045
6052
|
}
|
|
6046
6053
|
log17("sending authentication request", void 0, {
|
|
6047
6054
|
F: __dxlog_file21,
|
|
6048
|
-
L:
|
|
6055
|
+
L: 492,
|
|
6049
6056
|
S: this,
|
|
6050
6057
|
C: (f, a) => f(...a)
|
|
6051
6058
|
});
|
|
@@ -6058,6 +6065,13 @@ var InvitationsHandler = class {
|
|
|
6058
6065
|
}
|
|
6059
6066
|
}
|
|
6060
6067
|
};
|
|
6068
|
+
var checkInvitation = (protocol, invitation) => {
|
|
6069
|
+
const expiresOn = getExpirationTime(invitation);
|
|
6070
|
+
if (expiresOn && expiresOn.getTime() < Date.now()) {
|
|
6071
|
+
return new InvalidInvitationError("Invitation already expired.");
|
|
6072
|
+
}
|
|
6073
|
+
return protocol.checkInvitation(invitation);
|
|
6074
|
+
};
|
|
6061
6075
|
var createAdmissionKeypair = () => {
|
|
6062
6076
|
const keypair = createKeyPair();
|
|
6063
6077
|
return {
|
|
@@ -6172,7 +6186,7 @@ import { createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInv
|
|
|
6172
6186
|
import { writeMessages as writeMessages4 } from "@dxos/feed-store";
|
|
6173
6187
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
6174
6188
|
import { log as log18 } from "@dxos/log";
|
|
6175
|
-
import { AlreadyJoinedError as AlreadyJoinedError3, AuthorizationError as AuthorizationError2, InvalidInvitationError, SpaceNotFoundError as SpaceNotFoundError2 } from "@dxos/protocols";
|
|
6189
|
+
import { AlreadyJoinedError as AlreadyJoinedError3, AuthorizationError as AuthorizationError2, InvalidInvitationError as InvalidInvitationError2, SpaceNotFoundError as SpaceNotFoundError2 } from "@dxos/protocols";
|
|
6176
6190
|
import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
|
|
6177
6191
|
import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
6178
6192
|
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
@@ -6192,7 +6206,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6192
6206
|
}
|
|
6193
6207
|
checkCanInviteNewMembers() {
|
|
6194
6208
|
if (this._spaceKey == null) {
|
|
6195
|
-
return new
|
|
6209
|
+
return new InvalidInvitationError2("No spaceKey was provided for a space invitation.");
|
|
6196
6210
|
}
|
|
6197
6211
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6198
6212
|
if (space == null) {
|
|
@@ -6206,7 +6220,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6206
6220
|
getInvitationContext() {
|
|
6207
6221
|
invariant16(this._spaceKey, void 0, {
|
|
6208
6222
|
F: __dxlog_file22,
|
|
6209
|
-
L:
|
|
6223
|
+
L: 65,
|
|
6210
6224
|
S: this,
|
|
6211
6225
|
A: [
|
|
6212
6226
|
"this._spaceKey",
|
|
@@ -6216,7 +6230,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6216
6230
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6217
6231
|
invariant16(space, void 0, {
|
|
6218
6232
|
F: __dxlog_file22,
|
|
6219
|
-
L:
|
|
6233
|
+
L: 67,
|
|
6220
6234
|
S: this,
|
|
6221
6235
|
A: [
|
|
6222
6236
|
"space",
|
|
@@ -6232,7 +6246,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6232
6246
|
async admit(invitation, request, guestProfile) {
|
|
6233
6247
|
invariant16(this._spaceKey && request.space, void 0, {
|
|
6234
6248
|
F: __dxlog_file22,
|
|
6235
|
-
L:
|
|
6249
|
+
L: 80,
|
|
6236
6250
|
S: this,
|
|
6237
6251
|
A: [
|
|
6238
6252
|
"this._spaceKey && request.space",
|
|
@@ -6244,7 +6258,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6244
6258
|
guest: request.space.deviceKey
|
|
6245
6259
|
}, {
|
|
6246
6260
|
F: __dxlog_file22,
|
|
6247
|
-
L:
|
|
6261
|
+
L: 81,
|
|
6248
6262
|
S: this,
|
|
6249
6263
|
C: (f, a) => f(...a)
|
|
6250
6264
|
});
|
|
@@ -6266,7 +6280,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6266
6280
|
async delegate(invitation) {
|
|
6267
6281
|
invariant16(this._spaceKey, void 0, {
|
|
6268
6282
|
F: __dxlog_file22,
|
|
6269
|
-
L:
|
|
6283
|
+
L: 101,
|
|
6270
6284
|
S: this,
|
|
6271
6285
|
A: [
|
|
6272
6286
|
"this._spaceKey",
|
|
@@ -6276,7 +6290,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6276
6290
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6277
6291
|
invariant16(space, void 0, {
|
|
6278
6292
|
F: __dxlog_file22,
|
|
6279
|
-
L:
|
|
6293
|
+
L: 103,
|
|
6280
6294
|
S: this,
|
|
6281
6295
|
A: [
|
|
6282
6296
|
"space",
|
|
@@ -6286,7 +6300,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6286
6300
|
if (invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
6287
6301
|
invariant16(invitation.guestKeypair?.publicKey, void 0, {
|
|
6288
6302
|
F: __dxlog_file22,
|
|
6289
|
-
L:
|
|
6303
|
+
L: 105,
|
|
6290
6304
|
S: this,
|
|
6291
6305
|
A: [
|
|
6292
6306
|
"invitation.guestKeypair?.publicKey",
|
|
@@ -6299,7 +6313,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6299
6313
|
id: invitation.invitationId
|
|
6300
6314
|
}, {
|
|
6301
6315
|
F: __dxlog_file22,
|
|
6302
|
-
L:
|
|
6316
|
+
L: 108,
|
|
6303
6317
|
S: this,
|
|
6304
6318
|
C: (f, a) => f(...a)
|
|
6305
6319
|
});
|
|
@@ -6308,13 +6322,13 @@ var SpaceInvitationProtocol = class {
|
|
|
6308
6322
|
authMethod: invitation.authMethod,
|
|
6309
6323
|
swarmKey: invitation.swarmKey,
|
|
6310
6324
|
role: invitation.role ?? SpaceMember6.Role.ADMIN,
|
|
6311
|
-
expiresOn:
|
|
6325
|
+
expiresOn: computeExpirationTime(invitation),
|
|
6312
6326
|
multiUse: invitation.multiUse ?? false,
|
|
6313
6327
|
guestKey: invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
|
|
6314
6328
|
});
|
|
6315
6329
|
invariant16(credential.credential, void 0, {
|
|
6316
6330
|
F: __dxlog_file22,
|
|
6317
|
-
L:
|
|
6331
|
+
L: 126,
|
|
6318
6332
|
S: this,
|
|
6319
6333
|
A: [
|
|
6320
6334
|
"credential.credential",
|
|
@@ -6329,7 +6343,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6329
6343
|
async cancelDelegation(invitation) {
|
|
6330
6344
|
invariant16(this._spaceKey, void 0, {
|
|
6331
6345
|
F: __dxlog_file22,
|
|
6332
|
-
L:
|
|
6346
|
+
L: 132,
|
|
6333
6347
|
S: this,
|
|
6334
6348
|
A: [
|
|
6335
6349
|
"this._spaceKey",
|
|
@@ -6338,7 +6352,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6338
6352
|
});
|
|
6339
6353
|
invariant16(invitation.type === Invitation8.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
|
|
6340
6354
|
F: __dxlog_file22,
|
|
6341
|
-
L:
|
|
6355
|
+
L: 133,
|
|
6342
6356
|
S: this,
|
|
6343
6357
|
A: [
|
|
6344
6358
|
"invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
|
|
@@ -6348,7 +6362,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6348
6362
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6349
6363
|
invariant16(space, void 0, {
|
|
6350
6364
|
F: __dxlog_file22,
|
|
6351
|
-
L:
|
|
6365
|
+
L: 135,
|
|
6352
6366
|
S: this,
|
|
6353
6367
|
A: [
|
|
6354
6368
|
"space",
|
|
@@ -6360,14 +6374,14 @@ var SpaceInvitationProtocol = class {
|
|
|
6360
6374
|
id: invitation.invitationId
|
|
6361
6375
|
}, {
|
|
6362
6376
|
F: __dxlog_file22,
|
|
6363
|
-
L:
|
|
6377
|
+
L: 137,
|
|
6364
6378
|
S: this,
|
|
6365
6379
|
C: (f, a) => f(...a)
|
|
6366
6380
|
});
|
|
6367
6381
|
const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
|
|
6368
6382
|
invariant16(credential.credential, void 0, {
|
|
6369
6383
|
F: __dxlog_file22,
|
|
6370
|
-
L:
|
|
6384
|
+
L: 144,
|
|
6371
6385
|
S: this,
|
|
6372
6386
|
A: [
|
|
6373
6387
|
"credential.credential",
|
|
@@ -6380,7 +6394,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6380
6394
|
}
|
|
6381
6395
|
checkInvitation(invitation) {
|
|
6382
6396
|
if (invitation.spaceKey == null) {
|
|
6383
|
-
return new
|
|
6397
|
+
return new InvalidInvitationError2("No spaceKey was provided for a space invitation.");
|
|
6384
6398
|
}
|
|
6385
6399
|
if (this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
6386
6400
|
return new AlreadyJoinedError3("Already joined space.");
|
|
@@ -6406,7 +6420,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6406
6420
|
async accept(response) {
|
|
6407
6421
|
invariant16(response.space, void 0, {
|
|
6408
6422
|
F: __dxlog_file22,
|
|
6409
|
-
L:
|
|
6423
|
+
L: 179,
|
|
6410
6424
|
S: this,
|
|
6411
6425
|
A: [
|
|
6412
6426
|
"response.space",
|
|
@@ -6417,7 +6431,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6417
6431
|
const assertion = getCredentialAssertion5(credential);
|
|
6418
6432
|
invariant16(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
6419
6433
|
F: __dxlog_file22,
|
|
6420
|
-
L:
|
|
6434
|
+
L: 182,
|
|
6421
6435
|
S: this,
|
|
6422
6436
|
A: [
|
|
6423
6437
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -6426,7 +6440,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6426
6440
|
});
|
|
6427
6441
|
invariant16(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
6428
6442
|
F: __dxlog_file22,
|
|
6429
|
-
L:
|
|
6443
|
+
L: 183,
|
|
6430
6444
|
S: this,
|
|
6431
6445
|
A: [
|
|
6432
6446
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -6662,7 +6676,7 @@ var InvitationsManager = class {
|
|
|
6662
6676
|
}
|
|
6663
6677
|
}
|
|
6664
6678
|
_createInvitation(protocol, _options) {
|
|
6665
|
-
const { invitationId = PublicKey12.random().toHex(), type = Invitation9.Type.INTERACTIVE, authMethod = Invitation9.AuthMethod.SHARED_SECRET, state = Invitation9.State.INIT, timeout = INVITATION_TIMEOUT2, swarmKey = PublicKey12.random(), persistent = _options?.authMethod !== Invitation9.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = SpaceMember7.Role.ADMIN, lifetime = 86400, multiUse = false, ...options } = _options ?? {};
|
|
6679
|
+
const { invitationId = PublicKey12.random().toHex(), type = Invitation9.Type.INTERACTIVE, authMethod = Invitation9.AuthMethod.SHARED_SECRET, state = Invitation9.State.INIT, timeout = INVITATION_TIMEOUT2, swarmKey = PublicKey12.random(), persistent = _options?.authMethod !== Invitation9.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = SpaceMember7.Role.ADMIN, lifetime = 86400 * 7, multiUse = false, ...options } = _options ?? {};
|
|
6666
6680
|
const authCode = options?.authCode ?? (authMethod === Invitation9.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
6667
6681
|
return {
|
|
6668
6682
|
invitationId,
|
|
@@ -8953,4 +8967,4 @@ export {
|
|
|
8953
8967
|
importProfileData,
|
|
8954
8968
|
ClientServicesHost
|
|
8955
8969
|
};
|
|
8956
|
-
//# sourceMappingURL=chunk-
|
|
8970
|
+
//# sourceMappingURL=chunk-UWR5XM7L.mjs.map
|