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