@dxos/credentials 0.7.5-main.ff8607b → 0.7.5-staging.2ff1350
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 +90 -89
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +98 -98
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +90 -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/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/processor/device-state-machine.d.ts.map +1 -1
- package/dist/types/src/state-machine/space-state-machine.d.ts +0 -2
- package/dist/types/src/state-machine/space-state-machine.d.ts.map +1 -1
- package/package.json +13 -12
- package/project.json +1 -0
- package/src/credentials/signing.ts +2 -2
- package/src/did.ts +27 -0
- package/src/index.ts +1 -0
- package/src/processor/device-state-machine.ts +4 -3
- package/src/state-machine/space-state-machine.ts +8 -21
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
|
@@ -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;
|
|
@@ -1510,18 +1533,20 @@ var SpaceStateMachine = class {
|
|
|
1510
1533
|
/**
|
|
1511
1534
|
* @param credential Message to process.
|
|
1512
1535
|
* @param fromFeed Key of the feed where this credential is recorded.
|
|
1513
|
-
* @synchronized
|
|
1514
1536
|
*/
|
|
1515
1537
|
async process(credential, { sourceFeed, skipVerification }) {
|
|
1516
|
-
if (credential.id
|
|
1517
|
-
|
|
1538
|
+
if (credential.id) {
|
|
1539
|
+
if (this._processedCredentials.has(credential.id)) {
|
|
1540
|
+
return true;
|
|
1541
|
+
}
|
|
1542
|
+
this._processedCredentials.add(credential.id);
|
|
1518
1543
|
}
|
|
1519
1544
|
if (!skipVerification) {
|
|
1520
1545
|
const result = await verifyCredential(credential);
|
|
1521
1546
|
if (result.kind !== "pass") {
|
|
1522
1547
|
log3.warn(`Invalid credential: ${result.errors.join(", ")}`, void 0, {
|
|
1523
1548
|
F: __dxlog_file6,
|
|
1524
|
-
L:
|
|
1549
|
+
L: 156,
|
|
1525
1550
|
S: this,
|
|
1526
1551
|
C: (f, a) => f(...a)
|
|
1527
1552
|
});
|
|
@@ -1534,7 +1559,7 @@ var SpaceStateMachine = class {
|
|
|
1534
1559
|
if (this._genesisCredential) {
|
|
1535
1560
|
log3.warn("Space already has a genesis credential.", void 0, {
|
|
1536
1561
|
F: __dxlog_file6,
|
|
1537
|
-
L:
|
|
1562
|
+
L: 165,
|
|
1538
1563
|
S: this,
|
|
1539
1564
|
C: (f, a) => f(...a)
|
|
1540
1565
|
});
|
|
@@ -1543,7 +1568,7 @@ var SpaceStateMachine = class {
|
|
|
1543
1568
|
if (!credential.issuer.equals(this._spaceKey)) {
|
|
1544
1569
|
log3.warn("Space genesis credential must be issued by space.", void 0, {
|
|
1545
1570
|
F: __dxlog_file6,
|
|
1546
|
-
L:
|
|
1571
|
+
L: 169,
|
|
1547
1572
|
S: this,
|
|
1548
1573
|
C: (f, a) => f(...a)
|
|
1549
1574
|
});
|
|
@@ -1552,7 +1577,7 @@ var SpaceStateMachine = class {
|
|
|
1552
1577
|
if (!credential.subject.id.equals(this._spaceKey)) {
|
|
1553
1578
|
log3.warn("Space genesis credential must be issued to space.", void 0, {
|
|
1554
1579
|
F: __dxlog_file6,
|
|
1555
|
-
L:
|
|
1580
|
+
L: 173,
|
|
1556
1581
|
S: this,
|
|
1557
1582
|
C: (f, a) => f(...a)
|
|
1558
1583
|
});
|
|
@@ -1568,7 +1593,7 @@ var SpaceStateMachine = class {
|
|
|
1568
1593
|
if (!this._genesisCredential) {
|
|
1569
1594
|
log3.warn("Space must have a genesis credential before adding members.", void 0, {
|
|
1570
1595
|
F: __dxlog_file6,
|
|
1571
|
-
L:
|
|
1596
|
+
L: 186,
|
|
1572
1597
|
S: this,
|
|
1573
1598
|
C: (f, a) => f(...a)
|
|
1574
1599
|
});
|
|
@@ -1577,7 +1602,7 @@ var SpaceStateMachine = class {
|
|
|
1577
1602
|
if (!this._canInviteNewMembers(credential.issuer)) {
|
|
1578
1603
|
log3.warn(`Space member is not authorized to invite new members: ${credential.issuer}`, void 0, {
|
|
1579
1604
|
F: __dxlog_file6,
|
|
1580
|
-
L:
|
|
1605
|
+
L: 190,
|
|
1581
1606
|
S: this,
|
|
1582
1607
|
C: (f, a) => f(...a)
|
|
1583
1608
|
});
|
|
@@ -1591,7 +1616,7 @@ var SpaceStateMachine = class {
|
|
|
1591
1616
|
if (!this._genesisCredential) {
|
|
1592
1617
|
log3.warn("Space must have a genesis credential before adding members.", void 0, {
|
|
1593
1618
|
F: __dxlog_file6,
|
|
1594
|
-
L:
|
|
1619
|
+
L: 201,
|
|
1595
1620
|
S: this,
|
|
1596
1621
|
C: (f, a) => f(...a)
|
|
1597
1622
|
});
|
|
@@ -1604,19 +1629,7 @@ var SpaceStateMachine = class {
|
|
|
1604
1629
|
if (!this._genesisCredential) {
|
|
1605
1630
|
log3.warn("Space must have a genesis credential before admitting feeds.", void 0, {
|
|
1606
1631
|
F: __dxlog_file6,
|
|
1607
|
-
L:
|
|
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,
|
|
1632
|
+
L: 211,
|
|
1620
1633
|
S: this,
|
|
1621
1634
|
C: (f, a) => f(...a)
|
|
1622
1635
|
});
|
|
@@ -1630,7 +1643,7 @@ var SpaceStateMachine = class {
|
|
|
1630
1643
|
if (!this._canInviteNewMembers(credential.issuer)) {
|
|
1631
1644
|
log3.warn(`Invalid invitation, space member is not authorized to invite new members: ${credential.issuer}`, void 0, {
|
|
1632
1645
|
F: __dxlog_file6,
|
|
1633
|
-
L:
|
|
1646
|
+
L: 222,
|
|
1634
1647
|
S: this,
|
|
1635
1648
|
C: (f, a) => f(...a)
|
|
1636
1649
|
});
|
|
@@ -1655,9 +1668,6 @@ var SpaceStateMachine = class {
|
|
|
1655
1668
|
}
|
|
1656
1669
|
}
|
|
1657
1670
|
await this.onCredentialProcessed.callIfSet(credential);
|
|
1658
|
-
if (credential.id) {
|
|
1659
|
-
this._processedCredentials.add(credential.id);
|
|
1660
|
-
}
|
|
1661
1671
|
return true;
|
|
1662
1672
|
}
|
|
1663
1673
|
getMemberRole(memberKey) {
|
|
@@ -1669,11 +1679,10 @@ var SpaceStateMachine = class {
|
|
|
1669
1679
|
_canInviteNewMembers(key) {
|
|
1670
1680
|
return key.equals(this._spaceKey) || this._members.getRole(key) === SpaceMember3.Role.ADMIN || this._members.getRole(key) === SpaceMember3.Role.OWNER;
|
|
1671
1681
|
}
|
|
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
|
-
}
|
|
1676
1682
|
};
|
|
1683
|
+
_ts_decorate([
|
|
1684
|
+
synchronized
|
|
1685
|
+
], SpaceStateMachine.prototype, "process", null);
|
|
1677
1686
|
var CredentialConsumer = class {
|
|
1678
1687
|
constructor(processor, _onOpen, _onClose) {
|
|
1679
1688
|
this.processor = processor;
|
|
@@ -1681,7 +1690,7 @@ var CredentialConsumer = class {
|
|
|
1681
1690
|
this._onClose = _onClose;
|
|
1682
1691
|
this._ctx = new Context(void 0, {
|
|
1683
1692
|
F: __dxlog_file6,
|
|
1684
|
-
L:
|
|
1693
|
+
L: 267
|
|
1685
1694
|
});
|
|
1686
1695
|
this._isReadyForLiveCredentials = false;
|
|
1687
1696
|
}
|
|
@@ -1708,14 +1717,14 @@ var CredentialConsumer = class {
|
|
|
1708
1717
|
// packages/core/halo/credentials/src/processor/device-state-machine.ts
|
|
1709
1718
|
import { Trigger } from "@dxos/async";
|
|
1710
1719
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1711
|
-
import { PublicKey as
|
|
1720
|
+
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
1712
1721
|
import { log as log4 } from "@dxos/log";
|
|
1713
|
-
import { ComplexMap as
|
|
1722
|
+
import { ComplexMap as ComplexMap7 } from "@dxos/util";
|
|
1714
1723
|
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/processor/device-state-machine.ts";
|
|
1715
1724
|
var DeviceStateMachine = class {
|
|
1716
1725
|
constructor(_params) {
|
|
1717
1726
|
this._params = _params;
|
|
1718
|
-
this.authorizedDeviceKeys = new
|
|
1727
|
+
this.authorizedDeviceKeys = new ComplexMap7(PublicKey9.hash);
|
|
1719
1728
|
this.deviceChainReady = new Trigger();
|
|
1720
1729
|
}
|
|
1721
1730
|
async processCredential(credential) {
|
|
@@ -1738,23 +1747,14 @@ var DeviceStateMachine = class {
|
|
|
1738
1747
|
const assertion = getCredentialAssertion(credential);
|
|
1739
1748
|
switch (assertion["@type"]) {
|
|
1740
1749
|
case "dxos.halo.credentials.AuthorizedDevice": {
|
|
1741
|
-
|
|
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
|
-
this.authorizedDeviceKeys.set(assertion.deviceKey, {});
|
|
1750
|
+
this.authorizedDeviceKeys.set(assertion.deviceKey, this.authorizedDeviceKeys.get(assertion.deviceKey) ?? {});
|
|
1751
1751
|
log4("added device", {
|
|
1752
1752
|
localDeviceKey: this._params.deviceKey,
|
|
1753
1753
|
deviceKey: assertion.deviceKey,
|
|
1754
1754
|
size: this.authorizedDeviceKeys.size
|
|
1755
1755
|
}, {
|
|
1756
1756
|
F: __dxlog_file7,
|
|
1757
|
-
L:
|
|
1757
|
+
L: 55,
|
|
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: 65,
|
|
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: 68,
|
|
1781
1781
|
S: this,
|
|
1782
1782
|
C: (f, a) => f(...a)
|
|
1783
1783
|
});
|
|
@@ -1848,6 +1848,7 @@ export {
|
|
|
1848
1848
|
createCredentialSignerWithKey,
|
|
1849
1849
|
createDelegatedSpaceInvitationCredential,
|
|
1850
1850
|
createDeviceAuthorization,
|
|
1851
|
+
createDidFromIdentityKey,
|
|
1851
1852
|
credentialTypeFilter,
|
|
1852
1853
|
defaultSecretProvider,
|
|
1853
1854
|
defaultSecretValidator,
|