@dxos/client-services 0.7.5-main.9d26e3a → 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-27A4ATQX.mjs → chunk-O46EJ5BJ.mjs} +172 -123
- 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-7FKXMJDD.cjs → chunk-WFDMSV4I.cjs} +202 -153
- 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-HGN7FHFK.mjs → chunk-UWR5XM7L.mjs} +172 -123
- 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/agents/edge-agent-service.d.ts +1 -1
- package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
- package/dist/types/src/packlets/devices/devices-service.d.ts +1 -1
- package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/devtools.d.ts +1 -1
- package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/feeds.d.ts +1 -1
- package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/keys.d.ts +1 -1
- package/dist/types/src/packlets/devtools/keys.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/metadata.d.ts +1 -1
- package/dist/types/src/packlets/devtools/metadata.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/network.d.ts +1 -1
- package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
- package/dist/types/src/packlets/devtools/spaces.d.ts +1 -1
- package/dist/types/src/packlets/devtools/spaces.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/contacts-service.d.ts +1 -1
- package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/utils.d.ts +1 -0
- package/dist/types/src/packlets/invitations/utils.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/network/network-service.d.ts +9 -2
- package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +3 -0
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +38 -38
- package/src/packlets/agents/edge-agent-service.ts +1 -1
- package/src/packlets/devices/devices-service.ts +1 -1
- package/src/packlets/devtools/devtools.ts +1 -1
- package/src/packlets/devtools/feeds.ts +1 -1
- package/src/packlets/devtools/keys.ts +1 -1
- package/src/packlets/devtools/metadata.ts +1 -1
- package/src/packlets/devtools/network.ts +1 -1
- package/src/packlets/devtools/spaces.ts +1 -1
- package/src/packlets/identity/contacts-service.ts +1 -1
- package/src/packlets/identity/identity-service.ts +1 -1
- package/src/packlets/invitations/invitations-handler.ts +15 -6
- package/src/packlets/invitations/invitations-manager.ts +1 -1
- package/src/packlets/invitations/invitations-service.ts +1 -1
- package/src/packlets/invitations/space-invitation-protocol.ts +2 -3
- package/src/packlets/invitations/utils.ts +7 -0
- package/src/packlets/logging/logging-service.ts +1 -1
- package/src/packlets/network/network-service.ts +39 -1
- package/src/packlets/services/service-context.ts +1 -0
- package/src/packlets/spaces/data-space-manager.ts +1 -1
- package/src/packlets/spaces/notarization-plugin.ts +32 -17
- package/src/packlets/spaces/spaces-service.ts +1 -1
- package/src/packlets/system/system-service.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-27A4ATQX.mjs.map +0 -7
- package/dist/lib/node/chunk-7FKXMJDD.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-HGN7FHFK.mjs.map +0 -7
|
@@ -2,7 +2,7 @@ import { createRequire } from 'node:module';const require = createRequire(import
|
|
|
2
2
|
|
|
3
3
|
// packages/sdk/client-services/src/packlets/devtools/feeds.ts
|
|
4
4
|
import { EventSubscriptions } from "@dxos/async";
|
|
5
|
-
import { Stream } from "@dxos/codec-protobuf";
|
|
5
|
+
import { Stream } from "@dxos/codec-protobuf/stream";
|
|
6
6
|
import { FeedIterator } from "@dxos/feed-store";
|
|
7
7
|
import { PublicKey } from "@dxos/keys";
|
|
8
8
|
import { log } from "@dxos/log";
|
|
@@ -113,7 +113,7 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
|
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
// packages/sdk/client-services/src/packlets/devtools/network.ts
|
|
116
|
-
import { Stream as Stream2 } from "@dxos/codec-protobuf";
|
|
116
|
+
import { Stream as Stream2 } from "@dxos/codec-protobuf/stream";
|
|
117
117
|
import { Context } from "@dxos/context";
|
|
118
118
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
119
119
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devtools/network.ts";
|
|
@@ -210,7 +210,7 @@ var getNetworkPeers = ({ networkManager }, request) => {
|
|
|
210
210
|
};
|
|
211
211
|
|
|
212
212
|
// packages/sdk/client-services/src/packlets/devtools/spaces.ts
|
|
213
|
-
import { Stream as Stream3 } from "@dxos/codec-protobuf";
|
|
213
|
+
import { Stream as Stream3 } from "@dxos/codec-protobuf/stream";
|
|
214
214
|
var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
215
215
|
return new Stream3(({ next }) => {
|
|
216
216
|
let unsubscribe;
|
|
@@ -247,11 +247,11 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
247
247
|
|
|
248
248
|
// packages/sdk/client-services/src/packlets/devtools/devtools.ts
|
|
249
249
|
import { Event as AsyncEvent } from "@dxos/async";
|
|
250
|
-
import { Stream as Stream6 } from "@dxos/codec-protobuf";
|
|
250
|
+
import { Stream as Stream6 } from "@dxos/codec-protobuf/stream";
|
|
251
251
|
|
|
252
252
|
// packages/sdk/client-services/src/packlets/devtools/keys.ts
|
|
253
253
|
import { scheduleTask } from "@dxos/async";
|
|
254
|
-
import { Stream as Stream4 } from "@dxos/codec-protobuf";
|
|
254
|
+
import { Stream as Stream4 } from "@dxos/codec-protobuf/stream";
|
|
255
255
|
var subscribeToKeyringKeys = ({ keyring }) => new Stream4(({ next, ctx }) => {
|
|
256
256
|
const update = async () => {
|
|
257
257
|
next({
|
|
@@ -263,7 +263,7 @@ var subscribeToKeyringKeys = ({ keyring }) => new Stream4(({ next, ctx }) => {
|
|
|
263
263
|
});
|
|
264
264
|
|
|
265
265
|
// packages/sdk/client-services/src/packlets/devtools/metadata.ts
|
|
266
|
-
import { Stream as Stream5 } from "@dxos/codec-protobuf";
|
|
266
|
+
import { Stream as Stream5 } from "@dxos/codec-protobuf/stream";
|
|
267
267
|
var subscribeToMetadata = ({ context }) => new Stream5(({ next, ctx }) => {
|
|
268
268
|
context.metadataStore.update.on(ctx, (data) => next({
|
|
269
269
|
metadata: data
|
|
@@ -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";
|
|
@@ -1373,6 +1373,7 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1373
1373
|
this._processedCredentials = new ComplexSet(PublicKey4.hash);
|
|
1374
1374
|
this._processCredentialsTriggers = new ComplexMap3(PublicKey4.hash);
|
|
1375
1375
|
this._activeEdgePollingIntervalHandle = void 0;
|
|
1376
|
+
this._activeEdgePollingEnabled = false;
|
|
1376
1377
|
this._spaceId = params.spaceId;
|
|
1377
1378
|
this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
|
|
1378
1379
|
if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
|
|
@@ -1380,15 +1381,6 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1380
1381
|
}
|
|
1381
1382
|
}
|
|
1382
1383
|
setActiveEdgePollingEnabled(enabled) {
|
|
1383
|
-
invariant4(this.isOpen, void 0, {
|
|
1384
|
-
F: __dxlog_file7,
|
|
1385
|
-
L: 109,
|
|
1386
|
-
S: this,
|
|
1387
|
-
A: [
|
|
1388
|
-
"this.isOpen",
|
|
1389
|
-
""
|
|
1390
|
-
]
|
|
1391
|
-
});
|
|
1392
1384
|
const client = this._edgeClient;
|
|
1393
1385
|
invariant4(client, void 0, {
|
|
1394
1386
|
F: __dxlog_file7,
|
|
@@ -1399,30 +1391,30 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1399
1391
|
""
|
|
1400
1392
|
]
|
|
1401
1393
|
});
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
clearInterval(this._activeEdgePollingIntervalHandle);
|
|
1410
|
-
this._activeEdgePollingIntervalHandle = void 0;
|
|
1394
|
+
this._activeEdgePollingEnabled = enabled;
|
|
1395
|
+
if (this.isOpen) {
|
|
1396
|
+
if (enabled && !this._activeEdgePollingIntervalHandle) {
|
|
1397
|
+
this._startPeriodicEdgePolling(client);
|
|
1398
|
+
} else if (!enabled && this._activeEdgePollingIntervalHandle) {
|
|
1399
|
+
this._stopPeriodicEdgePolling();
|
|
1400
|
+
}
|
|
1411
1401
|
}
|
|
1412
1402
|
}
|
|
1413
1403
|
get hasWriter() {
|
|
1414
1404
|
return !!this._writer;
|
|
1415
1405
|
}
|
|
1416
1406
|
async _open() {
|
|
1417
|
-
if (this._edgeClient
|
|
1418
|
-
|
|
1407
|
+
if (this._edgeClient) {
|
|
1408
|
+
if (this._activeEdgePollingEnabled) {
|
|
1409
|
+
this._startPeriodicEdgePolling(this._edgeClient);
|
|
1410
|
+
}
|
|
1411
|
+
if (this._writer) {
|
|
1412
|
+
this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
|
|
1413
|
+
}
|
|
1419
1414
|
}
|
|
1420
1415
|
}
|
|
1421
1416
|
async _close() {
|
|
1422
|
-
|
|
1423
|
-
clearInterval(this._activeEdgePollingIntervalHandle);
|
|
1424
|
-
this._activeEdgePollingIntervalHandle = void 0;
|
|
1425
|
-
}
|
|
1417
|
+
this._stopPeriodicEdgePolling();
|
|
1426
1418
|
await this._ctx.dispose();
|
|
1427
1419
|
}
|
|
1428
1420
|
/**
|
|
@@ -1600,10 +1592,23 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1600
1592
|
]
|
|
1601
1593
|
});
|
|
1602
1594
|
this._writer = writer;
|
|
1603
|
-
if (this._edgeClient) {
|
|
1595
|
+
if (this._edgeClient && this.isOpen) {
|
|
1604
1596
|
this._notarizePendingEdgeCredentials(this._edgeClient, writer);
|
|
1605
1597
|
}
|
|
1606
1598
|
}
|
|
1599
|
+
_startPeriodicEdgePolling(client) {
|
|
1600
|
+
this._activeEdgePollingIntervalHandle = setInterval(() => {
|
|
1601
|
+
if (this._writer) {
|
|
1602
|
+
this._notarizePendingEdgeCredentials(client, this._writer);
|
|
1603
|
+
}
|
|
1604
|
+
}, this._activeEdgePollingInterval);
|
|
1605
|
+
}
|
|
1606
|
+
_stopPeriodicEdgePolling() {
|
|
1607
|
+
if (this._activeEdgePollingIntervalHandle) {
|
|
1608
|
+
clearInterval(this._activeEdgePollingIntervalHandle);
|
|
1609
|
+
this._activeEdgePollingIntervalHandle = void 0;
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1607
1612
|
/**
|
|
1608
1613
|
* The method is used only for adding agent feeds to spaces.
|
|
1609
1614
|
* When an agent is created we can admit them into all the existing spaces. In case the operation fails
|
|
@@ -1622,7 +1627,7 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1622
1627
|
if (!credentials.length) {
|
|
1623
1628
|
log4("edge did not return credentials for notarization", void 0, {
|
|
1624
1629
|
F: __dxlog_file7,
|
|
1625
|
-
L:
|
|
1630
|
+
L: 311,
|
|
1626
1631
|
S: this,
|
|
1627
1632
|
C: (f, a) => f(...a)
|
|
1628
1633
|
});
|
|
@@ -1632,7 +1637,7 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1632
1637
|
count: credentials.length
|
|
1633
1638
|
}, {
|
|
1634
1639
|
F: __dxlog_file7,
|
|
1635
|
-
L:
|
|
1640
|
+
L: 315,
|
|
1636
1641
|
S: this,
|
|
1637
1642
|
C: (f, a) => f(...a)
|
|
1638
1643
|
});
|
|
@@ -1645,7 +1650,7 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1645
1650
|
count: decodedCredentials.length
|
|
1646
1651
|
}, {
|
|
1647
1652
|
F: __dxlog_file7,
|
|
1648
|
-
L:
|
|
1653
|
+
L: 324,
|
|
1649
1654
|
S: this,
|
|
1650
1655
|
C: (f, a) => f(...a)
|
|
1651
1656
|
});
|
|
@@ -1673,7 +1678,7 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1673
1678
|
for (const credential of credentials) {
|
|
1674
1679
|
invariant4(credential.id, "Credential must have an id", {
|
|
1675
1680
|
F: __dxlog_file7,
|
|
1676
|
-
L:
|
|
1681
|
+
L: 350,
|
|
1677
1682
|
S: this,
|
|
1678
1683
|
A: [
|
|
1679
1684
|
"credential.id",
|
|
@@ -1697,7 +1702,7 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1697
1702
|
peer: extension.localPeerId
|
|
1698
1703
|
}, {
|
|
1699
1704
|
F: __dxlog_file7,
|
|
1700
|
-
L:
|
|
1705
|
+
L: 365,
|
|
1701
1706
|
S: this,
|
|
1702
1707
|
C: (f, a) => f(...a)
|
|
1703
1708
|
});
|
|
@@ -1709,7 +1714,7 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1709
1714
|
peer: extension.localPeerId
|
|
1710
1715
|
}, {
|
|
1711
1716
|
F: __dxlog_file7,
|
|
1712
|
-
L:
|
|
1717
|
+
L: 370,
|
|
1713
1718
|
S: this,
|
|
1714
1719
|
C: (f, a) => f(...a)
|
|
1715
1720
|
});
|
|
@@ -1726,7 +1731,7 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1726
1731
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
1727
1732
|
}, {
|
|
1728
1733
|
F: __dxlog_file7,
|
|
1729
|
-
L:
|
|
1734
|
+
L: 382,
|
|
1730
1735
|
S: this,
|
|
1731
1736
|
C: (f, a) => f(...a)
|
|
1732
1737
|
});
|
|
@@ -1742,7 +1747,7 @@ var handleEdgeError = (error) => {
|
|
|
1742
1747
|
if (!(error instanceof EdgeCallFailedError) || error.errorData) {
|
|
1743
1748
|
log4.catch(error, void 0, {
|
|
1744
1749
|
F: __dxlog_file7,
|
|
1745
|
-
L:
|
|
1750
|
+
L: 396,
|
|
1746
1751
|
S: void 0,
|
|
1747
1752
|
C: (f, a) => f(...a)
|
|
1748
1753
|
});
|
|
@@ -1751,7 +1756,7 @@ var handleEdgeError = (error) => {
|
|
|
1751
1756
|
reason: error.reason
|
|
1752
1757
|
}, {
|
|
1753
1758
|
F: __dxlog_file7,
|
|
1754
|
-
L:
|
|
1759
|
+
L: 398,
|
|
1755
1760
|
S: void 0,
|
|
1756
1761
|
C: (f, a) => f(...a)
|
|
1757
1762
|
});
|
|
@@ -2565,7 +2570,7 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2565
2570
|
guestKeypair: invitation.guestKey ? {
|
|
2566
2571
|
publicKey: invitation.guestKey
|
|
2567
2572
|
} : void 0,
|
|
2568
|
-
lifetime: invitation.expiresOn ? invitation.expiresOn.getTime() - Date.now() : void 0,
|
|
2573
|
+
lifetime: invitation.expiresOn ? (invitation.expiresOn.getTime() - Date.now()) / 1e3 : void 0,
|
|
2569
2574
|
multiUse: invitation.multiUse,
|
|
2570
2575
|
delegationCredentialId: credentialId,
|
|
2571
2576
|
persistent: false
|
|
@@ -2592,7 +2597,7 @@ DataSpaceManager = _ts_decorate3([
|
|
|
2592
2597
|
|
|
2593
2598
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
2594
2599
|
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask3 } from "@dxos/async";
|
|
2595
|
-
import { Stream as Stream7 } from "@dxos/codec-protobuf";
|
|
2600
|
+
import { Stream as Stream7 } from "@dxos/codec-protobuf/stream";
|
|
2596
2601
|
import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
2597
2602
|
import { raise } from "@dxos/debug";
|
|
2598
2603
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
@@ -3678,7 +3683,7 @@ IdentityManager = _ts_decorate5([
|
|
|
3678
3683
|
|
|
3679
3684
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
3680
3685
|
import { Trigger as Trigger3, sleep as sleep2 } from "@dxos/async";
|
|
3681
|
-
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
3686
|
+
import { Stream as Stream8 } from "@dxos/codec-protobuf/stream";
|
|
3682
3687
|
import { Resource as Resource5 } from "@dxos/context";
|
|
3683
3688
|
import { createCredential as createCredential2, signPresentation } from "@dxos/credentials";
|
|
3684
3689
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
@@ -4622,14 +4627,14 @@ var DeviceInvitationProtocol = class {
|
|
|
4622
4627
|
|
|
4623
4628
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
4624
4629
|
import { scheduleTask as scheduleTask7, TimeoutError as TimeoutError2 } from "@dxos/async";
|
|
4625
|
-
import { INVITATION_TIMEOUT } from "@dxos/client-protocol";
|
|
4630
|
+
import { INVITATION_TIMEOUT, getExpirationTime } from "@dxos/client-protocol";
|
|
4626
4631
|
import { ContextDisposedError as ContextDisposedError3 } from "@dxos/context";
|
|
4627
4632
|
import { createKeyPair, sign as sign2 } from "@dxos/crypto";
|
|
4628
4633
|
import { invariant as invariant15 } from "@dxos/invariant";
|
|
4629
4634
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4630
4635
|
import { log as log17 } from "@dxos/log";
|
|
4631
4636
|
import { createTeleportProtocolFactory } from "@dxos/network-manager";
|
|
4632
|
-
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace7 } from "@dxos/protocols";
|
|
4637
|
+
import { InvalidInvitationError, InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace7 } from "@dxos/protocols";
|
|
4633
4638
|
import { Invitation as Invitation7 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4634
4639
|
import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
4635
4640
|
import { InvitationOptions as InvitationOptions4 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
@@ -4652,6 +4657,12 @@ import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/ser
|
|
|
4652
4657
|
var stateToString = (state) => {
|
|
4653
4658
|
return Object.entries(Invitation3.State).find(([key, val]) => val === state)?.[0] ?? "unknown";
|
|
4654
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
|
+
};
|
|
4655
4666
|
var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
|
|
4656
4667
|
let guard;
|
|
4657
4668
|
return cancelWithContext3(ctx, (async () => {
|
|
@@ -5667,18 +5678,19 @@ var InvitationsHandler = class {
|
|
|
5667
5678
|
});
|
|
5668
5679
|
return extension;
|
|
5669
5680
|
};
|
|
5670
|
-
|
|
5671
|
-
|
|
5681
|
+
const expiresOn = getExpirationTime(invitation);
|
|
5682
|
+
if (expiresOn) {
|
|
5683
|
+
if (expiresOn.getTime() < Date.now()) {
|
|
5672
5684
|
log17.warn("invitation has already expired", void 0, {
|
|
5673
5685
|
F: __dxlog_file21,
|
|
5674
|
-
L:
|
|
5686
|
+
L: 194,
|
|
5675
5687
|
S: this,
|
|
5676
5688
|
C: (f, a) => f(...a)
|
|
5677
5689
|
});
|
|
5678
5690
|
guardedState.set(null, Invitation7.State.EXPIRED);
|
|
5679
5691
|
void ctx.dispose().catch((err) => log17.catch(err, void 0, {
|
|
5680
5692
|
F: __dxlog_file21,
|
|
5681
|
-
L:
|
|
5693
|
+
L: 196,
|
|
5682
5694
|
S: this,
|
|
5683
5695
|
C: (f, a) => f(...a)
|
|
5684
5696
|
}));
|
|
@@ -5689,7 +5701,7 @@ var InvitationsHandler = class {
|
|
|
5689
5701
|
guardedState.set(null, Invitation7.State.EXPIRED);
|
|
5690
5702
|
metrics.increment("dxos.invitation.expired");
|
|
5691
5703
|
await ctx.dispose();
|
|
5692
|
-
},
|
|
5704
|
+
}, expiresOn.getTime() - Date.now());
|
|
5693
5705
|
}
|
|
5694
5706
|
let swarmConnection;
|
|
5695
5707
|
scheduleTask7(ctx, async () => {
|
|
@@ -5705,7 +5717,7 @@ var InvitationsHandler = class {
|
|
|
5705
5717
|
type: invitation.type
|
|
5706
5718
|
}, {
|
|
5707
5719
|
F: __dxlog_file21,
|
|
5708
|
-
L:
|
|
5720
|
+
L: 227,
|
|
5709
5721
|
S: this,
|
|
5710
5722
|
C: (f, a) => f(...a)
|
|
5711
5723
|
});
|
|
@@ -5713,7 +5725,7 @@ var InvitationsHandler = class {
|
|
|
5713
5725
|
if (deviceProfile) {
|
|
5714
5726
|
invariant15(invitation.kind === Invitation7.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
5715
5727
|
F: __dxlog_file21,
|
|
5716
|
-
L:
|
|
5728
|
+
L: 236,
|
|
5717
5729
|
S: this,
|
|
5718
5730
|
A: [
|
|
5719
5731
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -5731,7 +5743,7 @@ var InvitationsHandler = class {
|
|
|
5731
5743
|
triedPeers: triedPeersIds.size
|
|
5732
5744
|
}, {
|
|
5733
5745
|
F: __dxlog_file21,
|
|
5734
|
-
L:
|
|
5746
|
+
L: 244,
|
|
5735
5747
|
S: this,
|
|
5736
5748
|
C: (f, a) => f(...a)
|
|
5737
5749
|
});
|
|
@@ -5758,7 +5770,7 @@ var InvitationsHandler = class {
|
|
|
5758
5770
|
currentState: guardedState.current.state
|
|
5759
5771
|
}, {
|
|
5760
5772
|
F: __dxlog_file21,
|
|
5761
|
-
L:
|
|
5773
|
+
L: 272,
|
|
5762
5774
|
S: this,
|
|
5763
5775
|
C: (f, a) => f(...a)
|
|
5764
5776
|
});
|
|
@@ -5776,7 +5788,7 @@ var InvitationsHandler = class {
|
|
|
5776
5788
|
id: traceId
|
|
5777
5789
|
}), {
|
|
5778
5790
|
F: __dxlog_file21,
|
|
5779
|
-
L:
|
|
5791
|
+
L: 284,
|
|
5780
5792
|
S: this,
|
|
5781
5793
|
C: (f, a) => f(...a)
|
|
5782
5794
|
});
|
|
@@ -5788,7 +5800,7 @@ var InvitationsHandler = class {
|
|
|
5788
5800
|
...protocol.toJSON()
|
|
5789
5801
|
}, {
|
|
5790
5802
|
F: __dxlog_file21,
|
|
5791
|
-
L:
|
|
5803
|
+
L: 295,
|
|
5792
5804
|
S: this,
|
|
5793
5805
|
C: (f, a) => f(...a)
|
|
5794
5806
|
});
|
|
@@ -5798,7 +5810,7 @@ var InvitationsHandler = class {
|
|
|
5798
5810
|
...protocol.toJSON()
|
|
5799
5811
|
}, {
|
|
5800
5812
|
F: __dxlog_file21,
|
|
5801
|
-
L:
|
|
5813
|
+
L: 299,
|
|
5802
5814
|
S: this,
|
|
5803
5815
|
C: (f, a) => f(...a)
|
|
5804
5816
|
});
|
|
@@ -5812,7 +5824,7 @@ var InvitationsHandler = class {
|
|
|
5812
5824
|
authMethod: introductionResponse.authMethod
|
|
5813
5825
|
}, {
|
|
5814
5826
|
F: __dxlog_file21,
|
|
5815
|
-
L:
|
|
5827
|
+
L: 307,
|
|
5816
5828
|
S: this,
|
|
5817
5829
|
C: (f, a) => f(...a)
|
|
5818
5830
|
});
|
|
@@ -5834,7 +5846,7 @@ var InvitationsHandler = class {
|
|
|
5834
5846
|
...protocol.toJSON()
|
|
5835
5847
|
}, {
|
|
5836
5848
|
F: __dxlog_file21,
|
|
5837
|
-
L:
|
|
5849
|
+
L: 337,
|
|
5838
5850
|
S: this,
|
|
5839
5851
|
C: (f, a) => f(...a)
|
|
5840
5852
|
});
|
|
@@ -5847,7 +5859,7 @@ var InvitationsHandler = class {
|
|
|
5847
5859
|
...protocol.toJSON()
|
|
5848
5860
|
}, {
|
|
5849
5861
|
F: __dxlog_file21,
|
|
5850
|
-
L:
|
|
5862
|
+
L: 351,
|
|
5851
5863
|
S: this,
|
|
5852
5864
|
C: (f, a) => f(...a)
|
|
5853
5865
|
});
|
|
@@ -5860,7 +5872,7 @@ var InvitationsHandler = class {
|
|
|
5860
5872
|
id: traceId
|
|
5861
5873
|
}), {
|
|
5862
5874
|
F: __dxlog_file21,
|
|
5863
|
-
L:
|
|
5875
|
+
L: 360,
|
|
5864
5876
|
S: this,
|
|
5865
5877
|
C: (f, a) => f(...a)
|
|
5866
5878
|
});
|
|
@@ -5870,7 +5882,7 @@ var InvitationsHandler = class {
|
|
|
5870
5882
|
...protocol.toJSON()
|
|
5871
5883
|
}, {
|
|
5872
5884
|
F: __dxlog_file21,
|
|
5873
|
-
L:
|
|
5885
|
+
L: 363,
|
|
5874
5886
|
S: this,
|
|
5875
5887
|
C: (f, a) => f(...a)
|
|
5876
5888
|
});
|
|
@@ -5878,7 +5890,7 @@ var InvitationsHandler = class {
|
|
|
5878
5890
|
} else {
|
|
5879
5891
|
log17.verbose("auth failed", err, {
|
|
5880
5892
|
F: __dxlog_file21,
|
|
5881
|
-
L:
|
|
5893
|
+
L: 366,
|
|
5882
5894
|
S: this,
|
|
5883
5895
|
C: (f, a) => f(...a)
|
|
5884
5896
|
});
|
|
@@ -5890,7 +5902,7 @@ var InvitationsHandler = class {
|
|
|
5890
5902
|
error: err
|
|
5891
5903
|
}), {
|
|
5892
5904
|
F: __dxlog_file21,
|
|
5893
|
-
L:
|
|
5905
|
+
L: 370,
|
|
5894
5906
|
S: this,
|
|
5895
5907
|
C: (f, a) => f(...a)
|
|
5896
5908
|
});
|
|
@@ -5906,7 +5918,7 @@ var InvitationsHandler = class {
|
|
|
5906
5918
|
...protocol.toJSON()
|
|
5907
5919
|
}, {
|
|
5908
5920
|
F: __dxlog_file21,
|
|
5909
|
-
L:
|
|
5921
|
+
L: 379,
|
|
5910
5922
|
S: this,
|
|
5911
5923
|
C: (f, a) => f(...a)
|
|
5912
5924
|
});
|
|
@@ -5914,7 +5926,7 @@ var InvitationsHandler = class {
|
|
|
5914
5926
|
} else {
|
|
5915
5927
|
log17.verbose("auth failed", err, {
|
|
5916
5928
|
F: __dxlog_file21,
|
|
5917
|
-
L:
|
|
5929
|
+
L: 382,
|
|
5918
5930
|
S: this,
|
|
5919
5931
|
C: (f, a) => f(...a)
|
|
5920
5932
|
});
|
|
@@ -5931,7 +5943,7 @@ var InvitationsHandler = class {
|
|
|
5931
5943
|
...protocol.toJSON()
|
|
5932
5944
|
}, {
|
|
5933
5945
|
F: __dxlog_file21,
|
|
5934
|
-
L:
|
|
5946
|
+
L: 394,
|
|
5935
5947
|
S: this,
|
|
5936
5948
|
C: (f, a) => f(...a)
|
|
5937
5949
|
});
|
|
@@ -5944,14 +5956,14 @@ var InvitationsHandler = class {
|
|
|
5944
5956
|
});
|
|
5945
5957
|
edgeInvitationHandler.handle(ctx, guardedState, protocol, deviceProfile);
|
|
5946
5958
|
scheduleTask7(ctx, async () => {
|
|
5947
|
-
const error =
|
|
5959
|
+
const error = checkInvitation(protocol, invitation);
|
|
5948
5960
|
if (error) {
|
|
5949
5961
|
stream.error(error);
|
|
5950
5962
|
await ctx.dispose();
|
|
5951
5963
|
} else {
|
|
5952
5964
|
invariant15(invitation.swarmKey, void 0, {
|
|
5953
5965
|
F: __dxlog_file21,
|
|
5954
|
-
L:
|
|
5966
|
+
L: 406,
|
|
5955
5967
|
S: this,
|
|
5956
5968
|
A: [
|
|
5957
5969
|
"invitation.swarmKey",
|
|
@@ -5995,7 +6007,7 @@ var InvitationsHandler = class {
|
|
|
5995
6007
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
5996
6008
|
log17("guest waiting for authentication code...", void 0, {
|
|
5997
6009
|
F: __dxlog_file21,
|
|
5998
|
-
L:
|
|
6010
|
+
L: 458,
|
|
5999
6011
|
S: this,
|
|
6000
6012
|
C: (f, a) => f(...a)
|
|
6001
6013
|
});
|
|
@@ -6003,7 +6015,7 @@ var InvitationsHandler = class {
|
|
|
6003
6015
|
const authCode = await authenticated.wait(options);
|
|
6004
6016
|
log17("sending authentication request", void 0, {
|
|
6005
6017
|
F: __dxlog_file21,
|
|
6006
|
-
L:
|
|
6018
|
+
L: 462,
|
|
6007
6019
|
S: this,
|
|
6008
6020
|
C: (f, a) => f(...a)
|
|
6009
6021
|
});
|
|
@@ -6022,7 +6034,7 @@ var InvitationsHandler = class {
|
|
|
6022
6034
|
attempt
|
|
6023
6035
|
}, {
|
|
6024
6036
|
F: __dxlog_file21,
|
|
6025
|
-
L:
|
|
6037
|
+
L: 473,
|
|
6026
6038
|
S: this,
|
|
6027
6039
|
C: (f, a) => f(...a)
|
|
6028
6040
|
});
|
|
@@ -6040,7 +6052,7 @@ var InvitationsHandler = class {
|
|
|
6040
6052
|
}
|
|
6041
6053
|
log17("sending authentication request", void 0, {
|
|
6042
6054
|
F: __dxlog_file21,
|
|
6043
|
-
L:
|
|
6055
|
+
L: 492,
|
|
6044
6056
|
S: this,
|
|
6045
6057
|
C: (f, a) => f(...a)
|
|
6046
6058
|
});
|
|
@@ -6053,6 +6065,13 @@ var InvitationsHandler = class {
|
|
|
6053
6065
|
}
|
|
6054
6066
|
}
|
|
6055
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
|
+
};
|
|
6056
6075
|
var createAdmissionKeypair = () => {
|
|
6057
6076
|
const keypair = createKeyPair();
|
|
6058
6077
|
return {
|
|
@@ -6062,7 +6081,7 @@ var createAdmissionKeypair = () => {
|
|
|
6062
6081
|
};
|
|
6063
6082
|
|
|
6064
6083
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
6065
|
-
import { Stream as Stream9 } from "@dxos/codec-protobuf";
|
|
6084
|
+
import { Stream as Stream9 } from "@dxos/codec-protobuf/stream";
|
|
6066
6085
|
import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
6067
6086
|
import { trace as trace8 } from "@dxos/tracing";
|
|
6068
6087
|
var InvitationsServiceImpl = class {
|
|
@@ -6167,7 +6186,7 @@ import { createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInv
|
|
|
6167
6186
|
import { writeMessages as writeMessages4 } from "@dxos/feed-store";
|
|
6168
6187
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
6169
6188
|
import { log as log18 } from "@dxos/log";
|
|
6170
|
-
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";
|
|
6171
6190
|
import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
|
|
6172
6191
|
import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
6173
6192
|
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
@@ -6187,7 +6206,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6187
6206
|
}
|
|
6188
6207
|
checkCanInviteNewMembers() {
|
|
6189
6208
|
if (this._spaceKey == null) {
|
|
6190
|
-
return new
|
|
6209
|
+
return new InvalidInvitationError2("No spaceKey was provided for a space invitation.");
|
|
6191
6210
|
}
|
|
6192
6211
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6193
6212
|
if (space == null) {
|
|
@@ -6201,7 +6220,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6201
6220
|
getInvitationContext() {
|
|
6202
6221
|
invariant16(this._spaceKey, void 0, {
|
|
6203
6222
|
F: __dxlog_file22,
|
|
6204
|
-
L:
|
|
6223
|
+
L: 65,
|
|
6205
6224
|
S: this,
|
|
6206
6225
|
A: [
|
|
6207
6226
|
"this._spaceKey",
|
|
@@ -6211,7 +6230,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6211
6230
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6212
6231
|
invariant16(space, void 0, {
|
|
6213
6232
|
F: __dxlog_file22,
|
|
6214
|
-
L:
|
|
6233
|
+
L: 67,
|
|
6215
6234
|
S: this,
|
|
6216
6235
|
A: [
|
|
6217
6236
|
"space",
|
|
@@ -6227,7 +6246,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6227
6246
|
async admit(invitation, request, guestProfile) {
|
|
6228
6247
|
invariant16(this._spaceKey && request.space, void 0, {
|
|
6229
6248
|
F: __dxlog_file22,
|
|
6230
|
-
L:
|
|
6249
|
+
L: 80,
|
|
6231
6250
|
S: this,
|
|
6232
6251
|
A: [
|
|
6233
6252
|
"this._spaceKey && request.space",
|
|
@@ -6239,7 +6258,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6239
6258
|
guest: request.space.deviceKey
|
|
6240
6259
|
}, {
|
|
6241
6260
|
F: __dxlog_file22,
|
|
6242
|
-
L:
|
|
6261
|
+
L: 81,
|
|
6243
6262
|
S: this,
|
|
6244
6263
|
C: (f, a) => f(...a)
|
|
6245
6264
|
});
|
|
@@ -6261,7 +6280,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6261
6280
|
async delegate(invitation) {
|
|
6262
6281
|
invariant16(this._spaceKey, void 0, {
|
|
6263
6282
|
F: __dxlog_file22,
|
|
6264
|
-
L:
|
|
6283
|
+
L: 101,
|
|
6265
6284
|
S: this,
|
|
6266
6285
|
A: [
|
|
6267
6286
|
"this._spaceKey",
|
|
@@ -6271,7 +6290,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6271
6290
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6272
6291
|
invariant16(space, void 0, {
|
|
6273
6292
|
F: __dxlog_file22,
|
|
6274
|
-
L:
|
|
6293
|
+
L: 103,
|
|
6275
6294
|
S: this,
|
|
6276
6295
|
A: [
|
|
6277
6296
|
"space",
|
|
@@ -6281,7 +6300,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6281
6300
|
if (invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
6282
6301
|
invariant16(invitation.guestKeypair?.publicKey, void 0, {
|
|
6283
6302
|
F: __dxlog_file22,
|
|
6284
|
-
L:
|
|
6303
|
+
L: 105,
|
|
6285
6304
|
S: this,
|
|
6286
6305
|
A: [
|
|
6287
6306
|
"invitation.guestKeypair?.publicKey",
|
|
@@ -6294,7 +6313,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6294
6313
|
id: invitation.invitationId
|
|
6295
6314
|
}, {
|
|
6296
6315
|
F: __dxlog_file22,
|
|
6297
|
-
L:
|
|
6316
|
+
L: 108,
|
|
6298
6317
|
S: this,
|
|
6299
6318
|
C: (f, a) => f(...a)
|
|
6300
6319
|
});
|
|
@@ -6303,13 +6322,13 @@ var SpaceInvitationProtocol = class {
|
|
|
6303
6322
|
authMethod: invitation.authMethod,
|
|
6304
6323
|
swarmKey: invitation.swarmKey,
|
|
6305
6324
|
role: invitation.role ?? SpaceMember6.Role.ADMIN,
|
|
6306
|
-
expiresOn:
|
|
6325
|
+
expiresOn: computeExpirationTime(invitation),
|
|
6307
6326
|
multiUse: invitation.multiUse ?? false,
|
|
6308
6327
|
guestKey: invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
|
|
6309
6328
|
});
|
|
6310
6329
|
invariant16(credential.credential, void 0, {
|
|
6311
6330
|
F: __dxlog_file22,
|
|
6312
|
-
L:
|
|
6331
|
+
L: 126,
|
|
6313
6332
|
S: this,
|
|
6314
6333
|
A: [
|
|
6315
6334
|
"credential.credential",
|
|
@@ -6324,7 +6343,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6324
6343
|
async cancelDelegation(invitation) {
|
|
6325
6344
|
invariant16(this._spaceKey, void 0, {
|
|
6326
6345
|
F: __dxlog_file22,
|
|
6327
|
-
L:
|
|
6346
|
+
L: 132,
|
|
6328
6347
|
S: this,
|
|
6329
6348
|
A: [
|
|
6330
6349
|
"this._spaceKey",
|
|
@@ -6333,7 +6352,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6333
6352
|
});
|
|
6334
6353
|
invariant16(invitation.type === Invitation8.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
|
|
6335
6354
|
F: __dxlog_file22,
|
|
6336
|
-
L:
|
|
6355
|
+
L: 133,
|
|
6337
6356
|
S: this,
|
|
6338
6357
|
A: [
|
|
6339
6358
|
"invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
|
|
@@ -6343,7 +6362,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6343
6362
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6344
6363
|
invariant16(space, void 0, {
|
|
6345
6364
|
F: __dxlog_file22,
|
|
6346
|
-
L:
|
|
6365
|
+
L: 135,
|
|
6347
6366
|
S: this,
|
|
6348
6367
|
A: [
|
|
6349
6368
|
"space",
|
|
@@ -6355,14 +6374,14 @@ var SpaceInvitationProtocol = class {
|
|
|
6355
6374
|
id: invitation.invitationId
|
|
6356
6375
|
}, {
|
|
6357
6376
|
F: __dxlog_file22,
|
|
6358
|
-
L:
|
|
6377
|
+
L: 137,
|
|
6359
6378
|
S: this,
|
|
6360
6379
|
C: (f, a) => f(...a)
|
|
6361
6380
|
});
|
|
6362
6381
|
const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
|
|
6363
6382
|
invariant16(credential.credential, void 0, {
|
|
6364
6383
|
F: __dxlog_file22,
|
|
6365
|
-
L:
|
|
6384
|
+
L: 144,
|
|
6366
6385
|
S: this,
|
|
6367
6386
|
A: [
|
|
6368
6387
|
"credential.credential",
|
|
@@ -6375,7 +6394,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6375
6394
|
}
|
|
6376
6395
|
checkInvitation(invitation) {
|
|
6377
6396
|
if (invitation.spaceKey == null) {
|
|
6378
|
-
return new
|
|
6397
|
+
return new InvalidInvitationError2("No spaceKey was provided for a space invitation.");
|
|
6379
6398
|
}
|
|
6380
6399
|
if (this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
6381
6400
|
return new AlreadyJoinedError3("Already joined space.");
|
|
@@ -6401,7 +6420,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6401
6420
|
async accept(response) {
|
|
6402
6421
|
invariant16(response.space, void 0, {
|
|
6403
6422
|
F: __dxlog_file22,
|
|
6404
|
-
L:
|
|
6423
|
+
L: 179,
|
|
6405
6424
|
S: this,
|
|
6406
6425
|
A: [
|
|
6407
6426
|
"response.space",
|
|
@@ -6412,7 +6431,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6412
6431
|
const assertion = getCredentialAssertion5(credential);
|
|
6413
6432
|
invariant16(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
6414
6433
|
F: __dxlog_file22,
|
|
6415
|
-
L:
|
|
6434
|
+
L: 182,
|
|
6416
6435
|
S: this,
|
|
6417
6436
|
A: [
|
|
6418
6437
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -6421,7 +6440,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6421
6440
|
});
|
|
6422
6441
|
invariant16(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
6423
6442
|
F: __dxlog_file22,
|
|
6424
|
-
L:
|
|
6443
|
+
L: 183,
|
|
6425
6444
|
S: this,
|
|
6426
6445
|
A: [
|
|
6427
6446
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -6657,7 +6676,7 @@ var InvitationsManager = class {
|
|
|
6657
6676
|
}
|
|
6658
6677
|
}
|
|
6659
6678
|
_createInvitation(protocol, _options) {
|
|
6660
|
-
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 ?? {};
|
|
6661
6680
|
const authCode = options?.authCode ?? (authMethod === Invitation9.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
6662
6681
|
return {
|
|
6663
6682
|
invitationId,
|
|
@@ -7179,7 +7198,7 @@ _ts_decorate9([
|
|
|
7179
7198
|
], EdgeAgentManager.prototype, "createAgent", null);
|
|
7180
7199
|
|
|
7181
7200
|
// packages/sdk/client-services/src/packlets/agents/edge-agent-service.ts
|
|
7182
|
-
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
7201
|
+
import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
|
|
7183
7202
|
import { EdgeAgentStatus as EdgeAgentStatus2 } from "@dxos/protocols";
|
|
7184
7203
|
import { QueryAgentStatusResponse, QueryEdgeStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
7185
7204
|
var EdgeAgentServiceImpl = class {
|
|
@@ -7487,7 +7506,8 @@ var ServiceContext = class extends Resource7 {
|
|
|
7487
7506
|
this.recoveryManager = new EdgeIdentityRecoveryManager(this.keyring, this._edgeHttpClient, () => this.identityManager.identity, this._acceptIdentity.bind(this));
|
|
7488
7507
|
this.echoHost = new EchoHost({
|
|
7489
7508
|
kv: this.level,
|
|
7490
|
-
peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex()
|
|
7509
|
+
peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
|
|
7510
|
+
getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key
|
|
7491
7511
|
});
|
|
7492
7512
|
this._meshReplicator = new MeshEchoReplicator();
|
|
7493
7513
|
this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
|
|
@@ -7506,7 +7526,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7506
7526
|
await this._checkStorageVersion();
|
|
7507
7527
|
log23("opening...", void 0, {
|
|
7508
7528
|
F: __dxlog_file27,
|
|
7509
|
-
L:
|
|
7529
|
+
L: 199,
|
|
7510
7530
|
S: this,
|
|
7511
7531
|
C: (f, a) => f(...a)
|
|
7512
7532
|
});
|
|
@@ -7514,7 +7534,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7514
7534
|
id: this._instanceId
|
|
7515
7535
|
}), {
|
|
7516
7536
|
F: __dxlog_file27,
|
|
7517
|
-
L:
|
|
7537
|
+
L: 200,
|
|
7518
7538
|
S: this,
|
|
7519
7539
|
C: (f, a) => f(...a)
|
|
7520
7540
|
});
|
|
@@ -7541,7 +7561,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7541
7561
|
count: loadedInvitations.invitations?.length
|
|
7542
7562
|
}, {
|
|
7543
7563
|
F: __dxlog_file27,
|
|
7544
|
-
L:
|
|
7564
|
+
L: 228,
|
|
7545
7565
|
S: this,
|
|
7546
7566
|
C: (f, a) => f(...a)
|
|
7547
7567
|
});
|
|
@@ -7549,13 +7569,13 @@ var ServiceContext = class extends Resource7 {
|
|
|
7549
7569
|
id: this._instanceId
|
|
7550
7570
|
}), {
|
|
7551
7571
|
F: __dxlog_file27,
|
|
7552
|
-
L:
|
|
7572
|
+
L: 230,
|
|
7553
7573
|
S: this,
|
|
7554
7574
|
C: (f, a) => f(...a)
|
|
7555
7575
|
});
|
|
7556
7576
|
log23("opened", void 0, {
|
|
7557
7577
|
F: __dxlog_file27,
|
|
7558
|
-
L:
|
|
7578
|
+
L: 231,
|
|
7559
7579
|
S: this,
|
|
7560
7580
|
C: (f, a) => f(...a)
|
|
7561
7581
|
});
|
|
@@ -7563,7 +7583,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7563
7583
|
async _close(ctx) {
|
|
7564
7584
|
log23("closing...", void 0, {
|
|
7565
7585
|
F: __dxlog_file27,
|
|
7566
|
-
L:
|
|
7586
|
+
L: 235,
|
|
7567
7587
|
S: this,
|
|
7568
7588
|
C: (f, a) => f(...a)
|
|
7569
7589
|
});
|
|
@@ -7582,7 +7602,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7582
7602
|
await this._edgeConnection?.close();
|
|
7583
7603
|
log23("closed", void 0, {
|
|
7584
7604
|
F: __dxlog_file27,
|
|
7585
|
-
L:
|
|
7605
|
+
L: 251,
|
|
7586
7606
|
S: this,
|
|
7587
7607
|
C: (f, a) => f(...a)
|
|
7588
7608
|
});
|
|
@@ -7593,7 +7613,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7593
7613
|
await identity.joinNetwork();
|
|
7594
7614
|
await this._initialize(new Context9(void 0, {
|
|
7595
7615
|
F: __dxlog_file27,
|
|
7596
|
-
L:
|
|
7616
|
+
L: 258
|
|
7597
7617
|
}));
|
|
7598
7618
|
return identity;
|
|
7599
7619
|
}
|
|
@@ -7604,7 +7624,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7604
7624
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
7605
7625
|
invariant21(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
7606
7626
|
F: __dxlog_file27,
|
|
7607
|
-
L:
|
|
7627
|
+
L: 267,
|
|
7608
7628
|
S: this,
|
|
7609
7629
|
A: [
|
|
7610
7630
|
"factory",
|
|
@@ -7630,7 +7650,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7630
7650
|
await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
|
|
7631
7651
|
await this._initialize(new Context9(void 0, {
|
|
7632
7652
|
F: __dxlog_file27,
|
|
7633
|
-
L:
|
|
7653
|
+
L: 286
|
|
7634
7654
|
}));
|
|
7635
7655
|
return identity;
|
|
7636
7656
|
}
|
|
@@ -7644,7 +7664,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7644
7664
|
async _initialize(ctx) {
|
|
7645
7665
|
log23("initializing spaces...", void 0, {
|
|
7646
7666
|
F: __dxlog_file27,
|
|
7647
|
-
L:
|
|
7667
|
+
L: 301,
|
|
7648
7668
|
S: this,
|
|
7649
7669
|
C: (f, a) => f(...a)
|
|
7650
7670
|
});
|
|
@@ -7683,7 +7703,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7683
7703
|
this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
|
|
7684
7704
|
invariant21(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
7685
7705
|
F: __dxlog_file27,
|
|
7686
|
-
L:
|
|
7706
|
+
L: 339,
|
|
7687
7707
|
S: this,
|
|
7688
7708
|
A: [
|
|
7689
7709
|
"this.dataSpaceManager",
|
|
@@ -7707,7 +7727,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7707
7727
|
details: assertion
|
|
7708
7728
|
}, {
|
|
7709
7729
|
F: __dxlog_file27,
|
|
7710
|
-
L:
|
|
7730
|
+
L: 355,
|
|
7711
7731
|
S: this,
|
|
7712
7732
|
C: (f, a) => f(...a)
|
|
7713
7733
|
});
|
|
@@ -7718,7 +7738,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7718
7738
|
details: assertion
|
|
7719
7739
|
}, {
|
|
7720
7740
|
F: __dxlog_file27,
|
|
7721
|
-
L:
|
|
7741
|
+
L: 359,
|
|
7722
7742
|
S: this,
|
|
7723
7743
|
C: (f, a) => f(...a)
|
|
7724
7744
|
});
|
|
@@ -7729,7 +7749,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7729
7749
|
details: assertion
|
|
7730
7750
|
}, {
|
|
7731
7751
|
F: __dxlog_file27,
|
|
7732
|
-
L:
|
|
7752
|
+
L: 364,
|
|
7733
7753
|
S: this,
|
|
7734
7754
|
C: (f, a) => f(...a)
|
|
7735
7755
|
});
|
|
@@ -7740,7 +7760,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7740
7760
|
} catch (err) {
|
|
7741
7761
|
log23.catch(err, void 0, {
|
|
7742
7762
|
F: __dxlog_file27,
|
|
7743
|
-
L:
|
|
7763
|
+
L: 370,
|
|
7744
7764
|
S: this,
|
|
7745
7765
|
C: (f, a) => f(...a)
|
|
7746
7766
|
});
|
|
@@ -7761,7 +7781,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7761
7781
|
swarms: this.networkManager.topics
|
|
7762
7782
|
}, {
|
|
7763
7783
|
F: __dxlog_file27,
|
|
7764
|
-
L:
|
|
7784
|
+
L: 384,
|
|
7765
7785
|
S: this,
|
|
7766
7786
|
C: (f, a) => f(...a)
|
|
7767
7787
|
});
|
|
@@ -7775,7 +7795,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7775
7795
|
});
|
|
7776
7796
|
invariant21(identity.deviceCredentialChain, void 0, {
|
|
7777
7797
|
F: __dxlog_file27,
|
|
7778
|
-
L:
|
|
7798
|
+
L: 403,
|
|
7779
7799
|
S: this,
|
|
7780
7800
|
A: [
|
|
7781
7801
|
"identity.deviceCredentialChain",
|
|
@@ -8085,7 +8105,7 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
|
8085
8105
|
|
|
8086
8106
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
8087
8107
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
8088
|
-
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
8108
|
+
import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
|
|
8089
8109
|
import { invariant as invariant23 } from "@dxos/invariant";
|
|
8090
8110
|
import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
8091
8111
|
var __dxlog_file29 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
@@ -8175,7 +8195,7 @@ var DevicesServiceImpl = class {
|
|
|
8175
8195
|
|
|
8176
8196
|
// packages/sdk/client-services/src/packlets/identity/contacts-service.ts
|
|
8177
8197
|
import { EventSubscriptions as EventSubscriptions4, scheduleTask as scheduleTask9, UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
|
|
8178
|
-
import { Stream as Stream13 } from "@dxos/codec-protobuf";
|
|
8198
|
+
import { Stream as Stream13 } from "@dxos/codec-protobuf/stream";
|
|
8179
8199
|
import { PublicKey as PublicKey17 } from "@dxos/keys";
|
|
8180
8200
|
import { ComplexMap as ComplexMap5, ComplexSet as ComplexSet6 } from "@dxos/util";
|
|
8181
8201
|
var ContactsServiceImpl = class {
|
|
@@ -8258,7 +8278,7 @@ var ContactsServiceImpl = class {
|
|
|
8258
8278
|
|
|
8259
8279
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
8260
8280
|
import { Event as Event10 } from "@dxos/async";
|
|
8261
|
-
import { Stream as Stream14 } from "@dxos/codec-protobuf";
|
|
8281
|
+
import { Stream as Stream14 } from "@dxos/codec-protobuf/stream";
|
|
8262
8282
|
import { PublicKey as PublicKey18 } from "@dxos/keys";
|
|
8263
8283
|
import { getContextFromEntry, log as log25 } from "@dxos/log";
|
|
8264
8284
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -8381,7 +8401,7 @@ var shouldLog = (entry2, request) => {
|
|
|
8381
8401
|
var LOG_PROCESSING = 0;
|
|
8382
8402
|
|
|
8383
8403
|
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
8384
|
-
import { Stream as Stream15 } from "@dxos/codec-protobuf";
|
|
8404
|
+
import { Stream as Stream15 } from "@dxos/codec-protobuf/stream";
|
|
8385
8405
|
var NetworkServiceImpl = class {
|
|
8386
8406
|
constructor(networkManager, signalManager) {
|
|
8387
8407
|
this.networkManager = networkManager;
|
|
@@ -8411,10 +8431,39 @@ var NetworkServiceImpl = class {
|
|
|
8411
8431
|
async updateConfig(request) {
|
|
8412
8432
|
await this.networkManager.setConnectionState(request.swarm);
|
|
8413
8433
|
}
|
|
8434
|
+
async joinSwarm(request) {
|
|
8435
|
+
return this.signalManager.join(request);
|
|
8436
|
+
}
|
|
8437
|
+
async leaveSwarm(request) {
|
|
8438
|
+
return this.signalManager.leave(request);
|
|
8439
|
+
}
|
|
8440
|
+
subscribeSwarmState(request) {
|
|
8441
|
+
return new Stream15(({ next }) => {
|
|
8442
|
+
const unsubscribe = this.signalManager.swarmState?.on((state) => {
|
|
8443
|
+
if (request.topic.equals(state.swarmKey)) {
|
|
8444
|
+
next(state);
|
|
8445
|
+
}
|
|
8446
|
+
});
|
|
8447
|
+
return unsubscribe;
|
|
8448
|
+
});
|
|
8449
|
+
}
|
|
8450
|
+
async sendMessage(message) {
|
|
8451
|
+
return this.signalManager.sendMessage(message);
|
|
8452
|
+
}
|
|
8453
|
+
subscribeMessages(peer) {
|
|
8454
|
+
return new Stream15(({ next }) => {
|
|
8455
|
+
const unsubscribe = this.signalManager.onMessage.on((message) => {
|
|
8456
|
+
if (message.recipient.peerKey === peer.peerKey) {
|
|
8457
|
+
next(message);
|
|
8458
|
+
}
|
|
8459
|
+
});
|
|
8460
|
+
return unsubscribe;
|
|
8461
|
+
});
|
|
8462
|
+
}
|
|
8414
8463
|
};
|
|
8415
8464
|
|
|
8416
8465
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
8417
|
-
import { Stream as Stream16 } from "@dxos/codec-protobuf";
|
|
8466
|
+
import { Stream as Stream16 } from "@dxos/codec-protobuf/stream";
|
|
8418
8467
|
import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
8419
8468
|
import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
|
|
8420
8469
|
var SystemServiceImpl = class {
|
|
@@ -8918,4 +8967,4 @@ export {
|
|
|
8918
8967
|
importProfileData,
|
|
8919
8968
|
ClientServicesHost
|
|
8920
8969
|
};
|
|
8921
|
-
//# sourceMappingURL=chunk-
|
|
8970
|
+
//# sourceMappingURL=chunk-UWR5XM7L.mjs.map
|