@dxos/credentials 0.7.5-labs.e27f9b9 → 0.7.5-main.2567c87
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/index.mjs +88 -89
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +97 -97
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +88 -89
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/credentials/signing.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/processor/device-state-machine.d.ts.map +1 -1
- package/dist/types/src/state-machine/space-state-machine.d.ts +2 -0
- package/dist/types/src/state-machine/space-state-machine.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/credentials/signing.ts +2 -2
- package/src/index.ts +0 -1
- package/src/processor/device-state-machine.ts +2 -3
- package/src/state-machine/space-state-machine.ts +21 -8
- package/dist/types/src/did.d.ts +0 -7
- package/dist/types/src/did.d.ts.map +0 -1
- package/src/did.ts +0 -27
|
@@ -1,22 +1,5 @@
|
|
|
1
1
|
import "@dxos/node-std/globals";
|
|
2
2
|
|
|
3
|
-
// packages/core/halo/credentials/src/did.ts
|
|
4
|
-
import { subtleCrypto } from "@dxos/crypto";
|
|
5
|
-
import { PublicKey, IdentityDid } from "@dxos/keys";
|
|
6
|
-
import { ComplexMap } from "@dxos/util";
|
|
7
|
-
var IDENTITY_DIDS_CACHE = new ComplexMap(PublicKey.hash);
|
|
8
|
-
var createDidFromIdentityKey = async (identityKey) => {
|
|
9
|
-
const cachedValue = IDENTITY_DIDS_CACHE.get(identityKey);
|
|
10
|
-
if (cachedValue !== void 0) {
|
|
11
|
-
return cachedValue;
|
|
12
|
-
}
|
|
13
|
-
const digest = await subtleCrypto.digest("SHA-256", identityKey.asUint8Array());
|
|
14
|
-
const bytes = new Uint8Array(digest).slice(0, IdentityDid.byteLength);
|
|
15
|
-
const identityDid = IdentityDid.encode(bytes);
|
|
16
|
-
IDENTITY_DIDS_CACHE.set(identityKey, identityDid);
|
|
17
|
-
return identityDid;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
3
|
// packages/core/halo/credentials/src/invitations.ts
|
|
21
4
|
var defaultSecretProvider = async () => Buffer.from("0000");
|
|
22
5
|
var defaultSecretValidator = async (invitation, secret) => true;
|
|
@@ -52,7 +35,7 @@ var generatePasscode = (length = 4) => {
|
|
|
52
35
|
|
|
53
36
|
// packages/core/halo/credentials/src/credentials/signing.ts
|
|
54
37
|
import stableStringify from "json-stable-stringify";
|
|
55
|
-
import { PublicKey
|
|
38
|
+
import { PublicKey } from "@dxos/keys";
|
|
56
39
|
import { Timeframe } from "@dxos/timeframe";
|
|
57
40
|
import { arrayToBuffer } from "@dxos/util";
|
|
58
41
|
var getCredentialProofPayload = (credential) => {
|
|
@@ -87,7 +70,7 @@ var canonicalStringify = (obj) => stableStringify(obj, {
|
|
|
87
70
|
}
|
|
88
71
|
const original = this[key];
|
|
89
72
|
if (value) {
|
|
90
|
-
if (
|
|
73
|
+
if (PublicKey.isPublicKey(value)) {
|
|
91
74
|
return value.toHex();
|
|
92
75
|
}
|
|
93
76
|
if (Buffer.isBuffer(value)) {
|
|
@@ -152,9 +135,9 @@ var checkCredentialType = (credential, type) => credential.subject.assertion["@t
|
|
|
152
135
|
var credentialTypeFilter = (type) => (credential) => checkCredentialType(credential, type);
|
|
153
136
|
|
|
154
137
|
// packages/core/halo/credentials/src/credentials/credential-factory.ts
|
|
155
|
-
import { subtleCrypto
|
|
138
|
+
import { subtleCrypto } from "@dxos/crypto";
|
|
156
139
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
157
|
-
import { PublicKey as
|
|
140
|
+
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
158
141
|
|
|
159
142
|
// packages/core/halo/credentials/src/credentials/verifier.ts
|
|
160
143
|
import { verifySignature } from "@dxos/crypto";
|
|
@@ -279,7 +262,7 @@ var createCredential = async ({ signer, issuer, subject, assertion, signingKey,
|
|
|
279
262
|
if (chain) {
|
|
280
263
|
credential.proof.chain = chain;
|
|
281
264
|
}
|
|
282
|
-
credential.id =
|
|
265
|
+
credential.id = PublicKey2.from(await subtleCrypto.digest("SHA-256", signedPayload));
|
|
283
266
|
return credential;
|
|
284
267
|
};
|
|
285
268
|
var createCredentialMessage = (credential) => {
|
|
@@ -624,22 +607,22 @@ var verifyPresentationSignature = async (presentation, proof) => {
|
|
|
624
607
|
};
|
|
625
608
|
|
|
626
609
|
// packages/core/halo/credentials/src/state-machine/space-state-machine.ts
|
|
627
|
-
import { runInContextAsync
|
|
610
|
+
import { runInContextAsync } from "@dxos/async";
|
|
628
611
|
import { Context } from "@dxos/context";
|
|
629
|
-
import { PublicKey as
|
|
612
|
+
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
630
613
|
import { log as log3 } from "@dxos/log";
|
|
631
614
|
import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
632
|
-
import { Callback as Callback4, ComplexMap as
|
|
615
|
+
import { Callback as Callback4, ComplexMap as ComplexMap5, ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
633
616
|
|
|
634
617
|
// packages/core/halo/credentials/src/state-machine/feed-state-machine.ts
|
|
635
618
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
636
|
-
import { PublicKey as
|
|
637
|
-
import { Callback, ComplexMap
|
|
619
|
+
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
620
|
+
import { Callback, ComplexMap } from "@dxos/util";
|
|
638
621
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/state-machine/feed-state-machine.ts";
|
|
639
622
|
var FeedStateMachine = class {
|
|
640
623
|
constructor(_spaceKey) {
|
|
641
624
|
this._spaceKey = _spaceKey;
|
|
642
|
-
this._feeds = new
|
|
625
|
+
this._feeds = new ComplexMap(PublicKey3.hash);
|
|
643
626
|
this.onFeedAdmitted = new Callback();
|
|
644
627
|
}
|
|
645
628
|
get feeds() {
|
|
@@ -683,13 +666,13 @@ var FeedStateMachine = class {
|
|
|
683
666
|
};
|
|
684
667
|
|
|
685
668
|
// packages/core/halo/credentials/src/state-machine/invitation-state-machine.ts
|
|
686
|
-
import { PublicKey as
|
|
687
|
-
import { Callback as Callback2, ComplexMap as
|
|
669
|
+
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
670
|
+
import { Callback as Callback2, ComplexMap as ComplexMap2, ComplexSet } from "@dxos/util";
|
|
688
671
|
var InvitationStateMachine = class {
|
|
689
672
|
constructor() {
|
|
690
|
-
this._invitations = new
|
|
691
|
-
this._redeemedInvitationCredentialIds = new ComplexSet(
|
|
692
|
-
this._cancelledInvitationCredentialIds = new ComplexSet(
|
|
673
|
+
this._invitations = new ComplexMap2(PublicKey4.hash);
|
|
674
|
+
this._redeemedInvitationCredentialIds = new ComplexSet(PublicKey4.hash);
|
|
675
|
+
this._cancelledInvitationCredentialIds = new ComplexSet(PublicKey4.hash);
|
|
693
676
|
this.onDelegatedInvitation = new Callback2();
|
|
694
677
|
this.onDelegatedInvitationRemoved = new Callback2();
|
|
695
678
|
}
|
|
@@ -754,16 +737,16 @@ var InvitationStateMachine = class {
|
|
|
754
737
|
|
|
755
738
|
// packages/core/halo/credentials/src/state-machine/member-state-machine.ts
|
|
756
739
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
757
|
-
import { PublicKey as
|
|
740
|
+
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
758
741
|
import { log as log2 } from "@dxos/log";
|
|
759
742
|
import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
760
|
-
import { ComplexMap as
|
|
743
|
+
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
761
744
|
|
|
762
745
|
// packages/core/halo/credentials/src/graph/credential-graph.ts
|
|
763
746
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
764
|
-
import { PublicKey as
|
|
747
|
+
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
765
748
|
import { log } from "@dxos/log";
|
|
766
|
-
import { Callback as Callback3, ComplexMap as
|
|
749
|
+
import { Callback as Callback3, ComplexMap as ComplexMap3, ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
767
750
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/graph/credential-graph.ts";
|
|
768
751
|
var CredentialGraph = class {
|
|
769
752
|
constructor(_stateHandler) {
|
|
@@ -779,9 +762,9 @@ var CredentialGraph = class {
|
|
|
779
762
|
parents: [],
|
|
780
763
|
children: []
|
|
781
764
|
};
|
|
782
|
-
this._vertexByCredentialId = new
|
|
783
|
-
this._subjectToVertex = new
|
|
784
|
-
this._subjectToState = new
|
|
765
|
+
this._vertexByCredentialId = new ComplexMap3(PublicKey5.hash);
|
|
766
|
+
this._subjectToVertex = new ComplexMap3(PublicKey5.hash);
|
|
767
|
+
this._subjectToState = new ComplexMap3(PublicKey5.hash);
|
|
785
768
|
this.onSubjectStateChanged = new Callback3();
|
|
786
769
|
}
|
|
787
770
|
getSubjectState(subjectId) {
|
|
@@ -948,7 +931,7 @@ var CredentialGraph = class {
|
|
|
948
931
|
}
|
|
949
932
|
_replayFailedPaths(paths, pendingPaths, mergeResult, convergedPaths) {
|
|
950
933
|
paths.push(...mergeResult.replay.map((path) => {
|
|
951
|
-
const stateOverrides = path.stateOverrides ?? new
|
|
934
|
+
const stateOverrides = path.stateOverrides ?? new ComplexMap3(PublicKey5.hash);
|
|
952
935
|
mergeResult.stateOverrides.forEach((value, key) => stateOverrides.set(key, value));
|
|
953
936
|
return {
|
|
954
937
|
...mergeResult.from,
|
|
@@ -1040,12 +1023,12 @@ var CredentialGraph = class {
|
|
|
1040
1023
|
]
|
|
1041
1024
|
},
|
|
1042
1025
|
head: choice,
|
|
1043
|
-
credentials: new ComplexSet2(
|
|
1044
|
-
state: new
|
|
1026
|
+
credentials: new ComplexSet2(PublicKey5.hash, path.credentials),
|
|
1027
|
+
state: new ComplexMap3(PublicKey5.hash, [
|
|
1045
1028
|
...path.state.entries()
|
|
1046
1029
|
]),
|
|
1047
|
-
forkIssuers: new ComplexSet2(
|
|
1048
|
-
forkChangedSubjects: new ComplexSet2(
|
|
1030
|
+
forkIssuers: new ComplexSet2(PublicKey5.hash),
|
|
1031
|
+
forkChangedSubjects: new ComplexSet2(PublicKey5.hash),
|
|
1049
1032
|
stateOverrides: path.stateOverrides
|
|
1050
1033
|
};
|
|
1051
1034
|
paths.push(fork);
|
|
@@ -1057,8 +1040,8 @@ var CredentialGraph = class {
|
|
|
1057
1040
|
*/
|
|
1058
1041
|
_setCurrentState(path) {
|
|
1059
1042
|
const changedSubjects = [];
|
|
1060
|
-
const newStateMap = new
|
|
1061
|
-
const newVertexMap = new
|
|
1043
|
+
const newStateMap = new ComplexMap3(PublicKey5.hash);
|
|
1044
|
+
const newVertexMap = new ComplexMap3(PublicKey5.hash);
|
|
1062
1045
|
for (const [subjectKey, subjectVertex] of path.state.entries()) {
|
|
1063
1046
|
const newState = this._stateHandler.createState(subjectVertex.credential, subjectVertex.assertion);
|
|
1064
1047
|
const prevState = this._subjectToState.get(subjectKey);
|
|
@@ -1166,13 +1149,13 @@ var CredentialGraph = class {
|
|
|
1166
1149
|
[forkPoint.head.id]: []
|
|
1167
1150
|
},
|
|
1168
1151
|
stateOverrides: forkPoint.stateOverrides,
|
|
1169
|
-
credentials: new ComplexSet2(
|
|
1170
|
-
forkIssuers: new ComplexSet2(
|
|
1171
|
-
forkChangedSubjects: new ComplexSet2(
|
|
1152
|
+
credentials: new ComplexSet2(PublicKey5.hash, forkPoint.credentials),
|
|
1153
|
+
forkIssuers: new ComplexSet2(PublicKey5.hash, forkPoint.forkIssuers),
|
|
1154
|
+
forkChangedSubjects: new ComplexSet2(PublicKey5.hash, forkPoint.forkChangedSubjects),
|
|
1172
1155
|
state: forkPoint.state.mapValues((v) => v),
|
|
1173
1156
|
head: paths[0].head
|
|
1174
1157
|
};
|
|
1175
|
-
const subjectToBranch = new
|
|
1158
|
+
const subjectToBranch = new ComplexMap3(PublicKey5.hash);
|
|
1176
1159
|
for (const path of paths) {
|
|
1177
1160
|
log("processing a path", () => ({
|
|
1178
1161
|
choices: toChosenPath(path),
|
|
@@ -1300,10 +1283,10 @@ var CredentialGraph = class {
|
|
|
1300
1283
|
return {
|
|
1301
1284
|
head: this._root,
|
|
1302
1285
|
chosenPath: {},
|
|
1303
|
-
forkIssuers: new ComplexSet2(
|
|
1304
|
-
forkChangedSubjects: new ComplexSet2(
|
|
1305
|
-
state: new
|
|
1306
|
-
credentials: new ComplexSet2(
|
|
1286
|
+
forkIssuers: new ComplexSet2(PublicKey5.hash),
|
|
1287
|
+
forkChangedSubjects: new ComplexSet2(PublicKey5.hash),
|
|
1288
|
+
state: new ComplexMap3(PublicKey5.hash),
|
|
1289
|
+
credentials: new ComplexSet2(PublicKey5.hash)
|
|
1307
1290
|
};
|
|
1308
1291
|
}
|
|
1309
1292
|
};
|
|
@@ -1319,7 +1302,7 @@ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/
|
|
|
1319
1302
|
var MemberStateMachine = class {
|
|
1320
1303
|
constructor(_spaceKey) {
|
|
1321
1304
|
this._spaceKey = _spaceKey;
|
|
1322
|
-
this._memberProfiles = new
|
|
1305
|
+
this._memberProfiles = new ComplexMap4(PublicKey6.hash);
|
|
1323
1306
|
this._hashgraph = new CredentialGraph(this);
|
|
1324
1307
|
this.onMemberRoleChanged = this._hashgraph.onSubjectStateChanged;
|
|
1325
1308
|
}
|
|
@@ -1461,12 +1444,6 @@ var MemberStateMachine = class {
|
|
|
1461
1444
|
};
|
|
1462
1445
|
|
|
1463
1446
|
// packages/core/halo/credentials/src/state-machine/space-state-machine.ts
|
|
1464
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
1465
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1466
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1467
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1468
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1469
|
-
}
|
|
1470
1447
|
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/state-machine/space-state-machine.ts";
|
|
1471
1448
|
var SpaceStateMachine = class {
|
|
1472
1449
|
constructor(_spaceKey) {
|
|
@@ -1475,8 +1452,8 @@ var SpaceStateMachine = class {
|
|
|
1475
1452
|
this._feeds = new FeedStateMachine(this._spaceKey);
|
|
1476
1453
|
this._invitations = new InvitationStateMachine();
|
|
1477
1454
|
this._credentials = [];
|
|
1478
|
-
this._credentialsById = new
|
|
1479
|
-
this._processedCredentials = new ComplexSet3(
|
|
1455
|
+
this._credentialsById = new ComplexMap5(PublicKey7.hash);
|
|
1456
|
+
this._processedCredentials = new ComplexSet3(PublicKey7.hash);
|
|
1480
1457
|
this._credentialProcessors = [];
|
|
1481
1458
|
this.onCredentialProcessed = new Callback4();
|
|
1482
1459
|
this.onMemberRoleChanged = this._members.onMemberRoleChanged;
|
|
@@ -1533,20 +1510,18 @@ var SpaceStateMachine = class {
|
|
|
1533
1510
|
/**
|
|
1534
1511
|
* @param credential Message to process.
|
|
1535
1512
|
* @param fromFeed Key of the feed where this credential is recorded.
|
|
1513
|
+
* @synchronized
|
|
1536
1514
|
*/
|
|
1537
1515
|
async process(credential, { sourceFeed, skipVerification }) {
|
|
1538
|
-
if (credential.id) {
|
|
1539
|
-
|
|
1540
|
-
return true;
|
|
1541
|
-
}
|
|
1542
|
-
this._processedCredentials.add(credential.id);
|
|
1516
|
+
if (credential.id && this._processedCredentials.has(credential.id)) {
|
|
1517
|
+
return true;
|
|
1543
1518
|
}
|
|
1544
1519
|
if (!skipVerification) {
|
|
1545
1520
|
const result = await verifyCredential(credential);
|
|
1546
1521
|
if (result.kind !== "pass") {
|
|
1547
1522
|
log3.warn(`Invalid credential: ${result.errors.join(", ")}`, void 0, {
|
|
1548
1523
|
F: __dxlog_file6,
|
|
1549
|
-
L:
|
|
1524
|
+
L: 153,
|
|
1550
1525
|
S: this,
|
|
1551
1526
|
C: (f, a) => f(...a)
|
|
1552
1527
|
});
|
|
@@ -1559,7 +1534,7 @@ var SpaceStateMachine = class {
|
|
|
1559
1534
|
if (this._genesisCredential) {
|
|
1560
1535
|
log3.warn("Space already has a genesis credential.", void 0, {
|
|
1561
1536
|
F: __dxlog_file6,
|
|
1562
|
-
L:
|
|
1537
|
+
L: 162,
|
|
1563
1538
|
S: this,
|
|
1564
1539
|
C: (f, a) => f(...a)
|
|
1565
1540
|
});
|
|
@@ -1568,7 +1543,7 @@ var SpaceStateMachine = class {
|
|
|
1568
1543
|
if (!credential.issuer.equals(this._spaceKey)) {
|
|
1569
1544
|
log3.warn("Space genesis credential must be issued by space.", void 0, {
|
|
1570
1545
|
F: __dxlog_file6,
|
|
1571
|
-
L:
|
|
1546
|
+
L: 166,
|
|
1572
1547
|
S: this,
|
|
1573
1548
|
C: (f, a) => f(...a)
|
|
1574
1549
|
});
|
|
@@ -1577,7 +1552,7 @@ var SpaceStateMachine = class {
|
|
|
1577
1552
|
if (!credential.subject.id.equals(this._spaceKey)) {
|
|
1578
1553
|
log3.warn("Space genesis credential must be issued to space.", void 0, {
|
|
1579
1554
|
F: __dxlog_file6,
|
|
1580
|
-
L:
|
|
1555
|
+
L: 170,
|
|
1581
1556
|
S: this,
|
|
1582
1557
|
C: (f, a) => f(...a)
|
|
1583
1558
|
});
|
|
@@ -1593,7 +1568,7 @@ var SpaceStateMachine = class {
|
|
|
1593
1568
|
if (!this._genesisCredential) {
|
|
1594
1569
|
log3.warn("Space must have a genesis credential before adding members.", void 0, {
|
|
1595
1570
|
F: __dxlog_file6,
|
|
1596
|
-
L:
|
|
1571
|
+
L: 183,
|
|
1597
1572
|
S: this,
|
|
1598
1573
|
C: (f, a) => f(...a)
|
|
1599
1574
|
});
|
|
@@ -1602,7 +1577,7 @@ var SpaceStateMachine = class {
|
|
|
1602
1577
|
if (!this._canInviteNewMembers(credential.issuer)) {
|
|
1603
1578
|
log3.warn(`Space member is not authorized to invite new members: ${credential.issuer}`, void 0, {
|
|
1604
1579
|
F: __dxlog_file6,
|
|
1605
|
-
L:
|
|
1580
|
+
L: 187,
|
|
1606
1581
|
S: this,
|
|
1607
1582
|
C: (f, a) => f(...a)
|
|
1608
1583
|
});
|
|
@@ -1616,7 +1591,7 @@ var SpaceStateMachine = class {
|
|
|
1616
1591
|
if (!this._genesisCredential) {
|
|
1617
1592
|
log3.warn("Space must have a genesis credential before adding members.", void 0, {
|
|
1618
1593
|
F: __dxlog_file6,
|
|
1619
|
-
L:
|
|
1594
|
+
L: 198,
|
|
1620
1595
|
S: this,
|
|
1621
1596
|
C: (f, a) => f(...a)
|
|
1622
1597
|
});
|
|
@@ -1629,7 +1604,19 @@ var SpaceStateMachine = class {
|
|
|
1629
1604
|
if (!this._genesisCredential) {
|
|
1630
1605
|
log3.warn("Space must have a genesis credential before admitting feeds.", void 0, {
|
|
1631
1606
|
F: __dxlog_file6,
|
|
1632
|
-
L:
|
|
1607
|
+
L: 208,
|
|
1608
|
+
S: this,
|
|
1609
|
+
C: (f, a) => f(...a)
|
|
1610
|
+
});
|
|
1611
|
+
return false;
|
|
1612
|
+
}
|
|
1613
|
+
if (!this._canAdmitFeeds(credential.issuer)) {
|
|
1614
|
+
log3.warn(`Space member is not authorized to admit feeds: ${credential.issuer}`, {
|
|
1615
|
+
sourceFeed: sourceFeed.toHex(),
|
|
1616
|
+
feed: credential.subject.id.toHex()
|
|
1617
|
+
}, {
|
|
1618
|
+
F: __dxlog_file6,
|
|
1619
|
+
L: 212,
|
|
1633
1620
|
S: this,
|
|
1634
1621
|
C: (f, a) => f(...a)
|
|
1635
1622
|
});
|
|
@@ -1643,7 +1630,7 @@ var SpaceStateMachine = class {
|
|
|
1643
1630
|
if (!this._canInviteNewMembers(credential.issuer)) {
|
|
1644
1631
|
log3.warn(`Invalid invitation, space member is not authorized to invite new members: ${credential.issuer}`, void 0, {
|
|
1645
1632
|
F: __dxlog_file6,
|
|
1646
|
-
L:
|
|
1633
|
+
L: 226,
|
|
1647
1634
|
S: this,
|
|
1648
1635
|
C: (f, a) => f(...a)
|
|
1649
1636
|
});
|
|
@@ -1668,6 +1655,9 @@ var SpaceStateMachine = class {
|
|
|
1668
1655
|
}
|
|
1669
1656
|
}
|
|
1670
1657
|
await this.onCredentialProcessed.callIfSet(credential);
|
|
1658
|
+
if (credential.id) {
|
|
1659
|
+
this._processedCredentials.add(credential.id);
|
|
1660
|
+
}
|
|
1671
1661
|
return true;
|
|
1672
1662
|
}
|
|
1673
1663
|
getMemberRole(memberKey) {
|
|
@@ -1679,10 +1669,11 @@ var SpaceStateMachine = class {
|
|
|
1679
1669
|
_canInviteNewMembers(key) {
|
|
1680
1670
|
return key.equals(this._spaceKey) || this._members.getRole(key) === SpaceMember3.Role.ADMIN || this._members.getRole(key) === SpaceMember3.Role.OWNER;
|
|
1681
1671
|
}
|
|
1672
|
+
_canAdmitFeeds(key) {
|
|
1673
|
+
const role = this._members.getRole(key);
|
|
1674
|
+
return role === SpaceMember3.Role.EDITOR || role === SpaceMember3.Role.ADMIN || role === SpaceMember3.Role.OWNER;
|
|
1675
|
+
}
|
|
1682
1676
|
};
|
|
1683
|
-
_ts_decorate([
|
|
1684
|
-
synchronized
|
|
1685
|
-
], SpaceStateMachine.prototype, "process", null);
|
|
1686
1677
|
var CredentialConsumer = class {
|
|
1687
1678
|
constructor(processor, _onOpen, _onClose) {
|
|
1688
1679
|
this.processor = processor;
|
|
@@ -1690,7 +1681,7 @@ var CredentialConsumer = class {
|
|
|
1690
1681
|
this._onClose = _onClose;
|
|
1691
1682
|
this._ctx = new Context(void 0, {
|
|
1692
1683
|
F: __dxlog_file6,
|
|
1693
|
-
L:
|
|
1684
|
+
L: 280
|
|
1694
1685
|
});
|
|
1695
1686
|
this._isReadyForLiveCredentials = false;
|
|
1696
1687
|
}
|
|
@@ -1717,14 +1708,14 @@ var CredentialConsumer = class {
|
|
|
1717
1708
|
// packages/core/halo/credentials/src/processor/device-state-machine.ts
|
|
1718
1709
|
import { Trigger } from "@dxos/async";
|
|
1719
1710
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1720
|
-
import { PublicKey as
|
|
1711
|
+
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
1721
1712
|
import { log as log4 } from "@dxos/log";
|
|
1722
|
-
import { ComplexMap as
|
|
1713
|
+
import { ComplexMap as ComplexMap6 } from "@dxos/util";
|
|
1723
1714
|
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/processor/device-state-machine.ts";
|
|
1724
1715
|
var DeviceStateMachine = class {
|
|
1725
1716
|
constructor(_params) {
|
|
1726
1717
|
this._params = _params;
|
|
1727
|
-
this.authorizedDeviceKeys = new
|
|
1718
|
+
this.authorizedDeviceKeys = new ComplexMap6(PublicKey8.hash);
|
|
1728
1719
|
this.deviceChainReady = new Trigger();
|
|
1729
1720
|
}
|
|
1730
1721
|
async processCredential(credential) {
|
|
@@ -1747,6 +1738,15 @@ var DeviceStateMachine = class {
|
|
|
1747
1738
|
const assertion = getCredentialAssertion(credential);
|
|
1748
1739
|
switch (assertion["@type"]) {
|
|
1749
1740
|
case "dxos.halo.credentials.AuthorizedDevice": {
|
|
1741
|
+
invariant6(!this.authorizedDeviceKeys.has(assertion.deviceKey), "Device already added.", {
|
|
1742
|
+
F: __dxlog_file7,
|
|
1743
|
+
L: 51,
|
|
1744
|
+
S: this,
|
|
1745
|
+
A: [
|
|
1746
|
+
"!this.authorizedDeviceKeys.has(assertion.deviceKey)",
|
|
1747
|
+
"'Device already added.'"
|
|
1748
|
+
]
|
|
1749
|
+
});
|
|
1750
1750
|
this.authorizedDeviceKeys.set(assertion.deviceKey, {});
|
|
1751
1751
|
log4("added device", {
|
|
1752
1752
|
localDeviceKey: this._params.deviceKey,
|
|
@@ -1754,7 +1754,7 @@ var DeviceStateMachine = class {
|
|
|
1754
1754
|
size: this.authorizedDeviceKeys.size
|
|
1755
1755
|
}, {
|
|
1756
1756
|
F: __dxlog_file7,
|
|
1757
|
-
L:
|
|
1757
|
+
L: 54,
|
|
1758
1758
|
S: this,
|
|
1759
1759
|
C: (f, a) => f(...a)
|
|
1760
1760
|
});
|
|
@@ -1764,7 +1764,7 @@ var DeviceStateMachine = class {
|
|
|
1764
1764
|
case "dxos.halo.credentials.DeviceProfile": {
|
|
1765
1765
|
invariant6(this.authorizedDeviceKeys.has(credential.subject.id), "Device not found.", {
|
|
1766
1766
|
F: __dxlog_file7,
|
|
1767
|
-
L:
|
|
1767
|
+
L: 64,
|
|
1768
1768
|
S: this,
|
|
1769
1769
|
A: [
|
|
1770
1770
|
"this.authorizedDeviceKeys.has(credential.subject.id)",
|
|
@@ -1777,7 +1777,7 @@ var DeviceStateMachine = class {
|
|
|
1777
1777
|
profile: assertion.profile
|
|
1778
1778
|
}, {
|
|
1779
1779
|
F: __dxlog_file7,
|
|
1780
|
-
L:
|
|
1780
|
+
L: 67,
|
|
1781
1781
|
S: this,
|
|
1782
1782
|
C: (f, a) => f(...a)
|
|
1783
1783
|
});
|
|
@@ -1848,7 +1848,6 @@ export {
|
|
|
1848
1848
|
createCredentialSignerWithKey,
|
|
1849
1849
|
createDelegatedSpaceInvitationCredential,
|
|
1850
1850
|
createDeviceAuthorization,
|
|
1851
|
-
createDidFromIdentityKey,
|
|
1852
1851
|
credentialTypeFilter,
|
|
1853
1852
|
defaultSecretProvider,
|
|
1854
1853
|
defaultSecretValidator,
|