@dxos/credentials 0.6.13 → 0.6.14-main.2b6a0f3
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 +92 -70
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +98 -76
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +1865 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +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/presentations/json-encoding.test.d.ts +2 -0
- package/dist/types/src/presentations/json-encoding.test.d.ts.map +1 -0
- package/dist/types/src/seedphrase.d.ts +0 -4
- package/dist/types/src/seedphrase.d.ts.map +1 -1
- package/package.json +17 -37
- package/project.json +1 -1
- package/src/credentials/verifier.test.ts +1 -2
- package/src/index.ts +1 -1
- package/src/presentations/json-encoding.test.ts +65 -0
- package/src/presentations/verifier.test.ts +1 -2
- package/src/seedphrase.ts +0 -7
- package/src/state-machine/invitation-state-machine.test.ts +2 -2
- package/src/state-machine/member-state-machine.test.ts +3 -3
- package/src/state-machine/space-state-machine.test.ts +1 -2
- package/tsconfig.json +1 -48
- package/vitest.config.ts +9 -0
|
@@ -11,6 +11,26 @@ import {
|
|
|
11
11
|
var defaultSecretProvider = async () => Buffer.from("0000");
|
|
12
12
|
var defaultSecretValidator = async (invitation, secret) => true;
|
|
13
13
|
|
|
14
|
+
// packages/core/halo/credentials/src/seedphrase.ts
|
|
15
|
+
import { generateMnemonic, mnemonicToSeedSync } from "bip39";
|
|
16
|
+
import { createKeyPair } from "@dxos/crypto";
|
|
17
|
+
import { invariant } from "@dxos/invariant";
|
|
18
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/seedphrase.ts";
|
|
19
|
+
var generateSeedPhrase = () => generateMnemonic();
|
|
20
|
+
var keyPairFromSeedPhrase = (seedPhrase) => {
|
|
21
|
+
invariant(seedPhrase, void 0, {
|
|
22
|
+
F: __dxlog_file,
|
|
23
|
+
L: 20,
|
|
24
|
+
S: void 0,
|
|
25
|
+
A: [
|
|
26
|
+
"seedPhrase",
|
|
27
|
+
""
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
const seed = mnemonicToSeedSync(seedPhrase);
|
|
31
|
+
return createKeyPair(seed);
|
|
32
|
+
};
|
|
33
|
+
|
|
14
34
|
// packages/core/halo/credentials/src/passcode.ts
|
|
15
35
|
var generatePasscode = (length = 4) => {
|
|
16
36
|
let passcode = "";
|
|
@@ -123,7 +143,7 @@ var credentialTypeFilter = (type) => (credential) => checkCredentialType(credent
|
|
|
123
143
|
|
|
124
144
|
// packages/core/halo/credentials/src/credentials/credential-factory.ts
|
|
125
145
|
import { subtleCrypto } from "@dxos/crypto";
|
|
126
|
-
import { invariant } from "@dxos/invariant";
|
|
146
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
127
147
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
128
148
|
|
|
129
149
|
// packages/core/halo/credentials/src/credentials/verifier.ts
|
|
@@ -196,10 +216,10 @@ var verifyChain = async (chain, authority, subject) => {
|
|
|
196
216
|
};
|
|
197
217
|
|
|
198
218
|
// packages/core/halo/credentials/src/credentials/credential-factory.ts
|
|
199
|
-
var
|
|
219
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/credentials/credential-factory.ts";
|
|
200
220
|
var createCredential = async ({ signer, issuer, subject, assertion, signingKey, chain, nonce, parentCredentialIds }) => {
|
|
201
|
-
|
|
202
|
-
F:
|
|
221
|
+
invariant2(assertion["@type"], "Invalid assertion.", {
|
|
222
|
+
F: __dxlog_file2,
|
|
203
223
|
L: 48,
|
|
204
224
|
S: void 0,
|
|
205
225
|
A: [
|
|
@@ -207,8 +227,8 @@ var createCredential = async ({ signer, issuer, subject, assertion, signingKey,
|
|
|
207
227
|
"'Invalid assertion.'"
|
|
208
228
|
]
|
|
209
229
|
});
|
|
210
|
-
|
|
211
|
-
F:
|
|
230
|
+
invariant2(!!signingKey === !!chain, "Chain must be provided if and only if the signing key differs from the issuer.", {
|
|
231
|
+
F: __dxlog_file2,
|
|
212
232
|
L: 49,
|
|
213
233
|
S: void 0,
|
|
214
234
|
A: [
|
|
@@ -218,8 +238,8 @@ var createCredential = async ({ signer, issuer, subject, assertion, signingKey,
|
|
|
218
238
|
});
|
|
219
239
|
if (chain) {
|
|
220
240
|
const result = await verifyChain(chain, issuer, signingKey);
|
|
221
|
-
|
|
222
|
-
F:
|
|
241
|
+
invariant2(result.kind === "pass", "Invalid chain.", {
|
|
242
|
+
F: __dxlog_file2,
|
|
223
243
|
L: 52,
|
|
224
244
|
S: void 0,
|
|
225
245
|
A: [
|
|
@@ -602,10 +622,10 @@ import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/cre
|
|
|
602
622
|
import { Callback as Callback4, ComplexMap as ComplexMap5, ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
603
623
|
|
|
604
624
|
// packages/core/halo/credentials/src/state-machine/feed-state-machine.ts
|
|
605
|
-
import { invariant as
|
|
625
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
606
626
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
607
627
|
import { Callback, ComplexMap } from "@dxos/util";
|
|
608
|
-
var
|
|
628
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/state-machine/feed-state-machine.ts";
|
|
609
629
|
var FeedStateMachine = class {
|
|
610
630
|
constructor(_spaceKey) {
|
|
611
631
|
this._spaceKey = _spaceKey;
|
|
@@ -623,8 +643,8 @@ var FeedStateMachine = class {
|
|
|
623
643
|
*/
|
|
624
644
|
async process(credential, fromFeed) {
|
|
625
645
|
const assertion = getCredentialAssertion(credential);
|
|
626
|
-
|
|
627
|
-
F:
|
|
646
|
+
invariant3(assertion["@type"] === "dxos.halo.credentials.AdmittedFeed", void 0, {
|
|
647
|
+
F: __dxlog_file3,
|
|
628
648
|
L: 47,
|
|
629
649
|
S: this,
|
|
630
650
|
A: [
|
|
@@ -632,8 +652,8 @@ var FeedStateMachine = class {
|
|
|
632
652
|
""
|
|
633
653
|
]
|
|
634
654
|
});
|
|
635
|
-
|
|
636
|
-
F:
|
|
655
|
+
invariant3(assertion.spaceKey.equals(this._spaceKey), void 0, {
|
|
656
|
+
F: __dxlog_file3,
|
|
637
657
|
L: 48,
|
|
638
658
|
S: this,
|
|
639
659
|
A: [
|
|
@@ -723,18 +743,18 @@ var InvitationStateMachine = class {
|
|
|
723
743
|
};
|
|
724
744
|
|
|
725
745
|
// packages/core/halo/credentials/src/state-machine/member-state-machine.ts
|
|
726
|
-
import { invariant as
|
|
746
|
+
import { invariant as invariant5 } from "@dxos/invariant";
|
|
727
747
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
728
748
|
import { log as log2 } from "@dxos/log";
|
|
729
749
|
import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
730
750
|
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
731
751
|
|
|
732
752
|
// packages/core/halo/credentials/src/graph/credential-graph.ts
|
|
733
|
-
import { invariant as
|
|
753
|
+
import { invariant as invariant4 } from "@dxos/invariant";
|
|
734
754
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
735
755
|
import { log } from "@dxos/log";
|
|
736
756
|
import { Callback as Callback3, ComplexMap as ComplexMap3, ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
737
|
-
var
|
|
757
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/graph/credential-graph.ts";
|
|
738
758
|
var CredentialGraph = class {
|
|
739
759
|
constructor(_stateHandler) {
|
|
740
760
|
this._stateHandler = _stateHandler;
|
|
@@ -789,7 +809,7 @@ var CredentialGraph = class {
|
|
|
789
809
|
credential,
|
|
790
810
|
parentId
|
|
791
811
|
}, {
|
|
792
|
-
F:
|
|
812
|
+
F: __dxlog_file4,
|
|
793
813
|
L: 72,
|
|
794
814
|
S: this,
|
|
795
815
|
C: (f, a) => f(...a)
|
|
@@ -810,8 +830,8 @@ var CredentialGraph = class {
|
|
|
810
830
|
if (sentinelIdx >= 0) {
|
|
811
831
|
vertex.children.splice(sentinelIdx, 1);
|
|
812
832
|
const vertexInSentinelIdx = this._sentinel.parents.indexOf(vertex);
|
|
813
|
-
|
|
814
|
-
F:
|
|
833
|
+
invariant4(vertexInSentinelIdx >= 0, void 0, {
|
|
834
|
+
F: __dxlog_file4,
|
|
815
835
|
L: 90,
|
|
816
836
|
S: this,
|
|
817
837
|
A: [
|
|
@@ -824,8 +844,8 @@ var CredentialGraph = class {
|
|
|
824
844
|
}
|
|
825
845
|
async _onVertexInserted(newVertex) {
|
|
826
846
|
const { credential, assertion } = newVertex;
|
|
827
|
-
|
|
828
|
-
F:
|
|
847
|
+
invariant4(credential, void 0, {
|
|
848
|
+
F: __dxlog_file4,
|
|
829
849
|
L: 97,
|
|
830
850
|
S: this,
|
|
831
851
|
A: [
|
|
@@ -870,7 +890,7 @@ var CredentialGraph = class {
|
|
|
870
890
|
log("visit vertex", {
|
|
871
891
|
id: path.head.id
|
|
872
892
|
}, {
|
|
873
|
-
F:
|
|
893
|
+
F: __dxlog_file4,
|
|
874
894
|
L: 132,
|
|
875
895
|
S: this,
|
|
876
896
|
C: (f, a) => f(...a)
|
|
@@ -879,7 +899,7 @@ var CredentialGraph = class {
|
|
|
879
899
|
const convergedPaths = this._handleMergePoint(paths, pendingPaths, path);
|
|
880
900
|
if (convergedPaths == null) {
|
|
881
901
|
log("waiting for other paths", void 0, {
|
|
882
|
-
F:
|
|
902
|
+
F: __dxlog_file4,
|
|
883
903
|
L: 136,
|
|
884
904
|
S: this,
|
|
885
905
|
C: (f, a) => f(...a)
|
|
@@ -908,7 +928,7 @@ var CredentialGraph = class {
|
|
|
908
928
|
head: p.head.id
|
|
909
929
|
}))
|
|
910
930
|
}, {
|
|
911
|
-
F:
|
|
931
|
+
F: __dxlog_file4,
|
|
912
932
|
L: 155,
|
|
913
933
|
S: this,
|
|
914
934
|
C: (f, a) => f(...a)
|
|
@@ -934,7 +954,7 @@ var CredentialGraph = class {
|
|
|
934
954
|
overrides: path?.stateOverrides?.mapValues((v) => this._stateHandler.toLogString(v.assertion))
|
|
935
955
|
}))
|
|
936
956
|
}), {
|
|
937
|
-
F:
|
|
957
|
+
F: __dxlog_file4,
|
|
938
958
|
L: 175,
|
|
939
959
|
S: this,
|
|
940
960
|
C: (f, a) => f(...a)
|
|
@@ -951,7 +971,7 @@ var CredentialGraph = class {
|
|
|
951
971
|
}
|
|
952
972
|
if (path.head.id === this._sentinel.id && paths.length > 0) {
|
|
953
973
|
log("waiting for all the active paths to converge on the sentinel", void 0, {
|
|
954
|
-
F:
|
|
974
|
+
F: __dxlog_file4,
|
|
955
975
|
L: 199,
|
|
956
976
|
S: this,
|
|
957
977
|
C: (f, a) => f(...a)
|
|
@@ -981,7 +1001,7 @@ var CredentialGraph = class {
|
|
|
981
1001
|
subject: updatedSubject,
|
|
982
1002
|
newState: this._stateHandler.toLogString(path.head.assertion)
|
|
983
1003
|
}), {
|
|
984
|
-
F:
|
|
1004
|
+
F: __dxlog_file4,
|
|
985
1005
|
L: 223,
|
|
986
1006
|
S: this,
|
|
987
1007
|
C: (f, a) => f(...a)
|
|
@@ -996,7 +1016,7 @@ var CredentialGraph = class {
|
|
|
996
1016
|
from: path.head.id,
|
|
997
1017
|
to: choice.id
|
|
998
1018
|
}, {
|
|
999
|
-
F:
|
|
1019
|
+
F: __dxlog_file4,
|
|
1000
1020
|
L: 234,
|
|
1001
1021
|
S: this,
|
|
1002
1022
|
C: (f, a) => f(...a)
|
|
@@ -1093,8 +1113,8 @@ var CredentialGraph = class {
|
|
|
1093
1113
|
return path;
|
|
1094
1114
|
}
|
|
1095
1115
|
_mergePaths(convergedPaths) {
|
|
1096
|
-
|
|
1097
|
-
F:
|
|
1116
|
+
invariant4(convergedPaths.length >= 1, void 0, {
|
|
1117
|
+
F: __dxlog_file4,
|
|
1098
1118
|
L: 324,
|
|
1099
1119
|
S: this,
|
|
1100
1120
|
A: [
|
|
@@ -1114,14 +1134,14 @@ var CredentialGraph = class {
|
|
|
1114
1134
|
pathCount: convergedPaths.length,
|
|
1115
1135
|
forkPoints: convergedPaths.map((fp) => fp.forkPoint?.head.id)
|
|
1116
1136
|
}), {
|
|
1117
|
-
F:
|
|
1137
|
+
F: __dxlog_file4,
|
|
1118
1138
|
L: 329,
|
|
1119
1139
|
S: this,
|
|
1120
1140
|
C: (f, a) => f(...a)
|
|
1121
1141
|
});
|
|
1122
1142
|
const paths = convergedPaths.map((p) => this._moveUpToForkPoint(forkPoint, p));
|
|
1123
|
-
|
|
1124
|
-
F:
|
|
1143
|
+
invariant4(forkPoint, void 0, {
|
|
1144
|
+
F: __dxlog_file4,
|
|
1125
1145
|
L: 335,
|
|
1126
1146
|
S: this,
|
|
1127
1147
|
A: [
|
|
@@ -1150,7 +1170,7 @@ var CredentialGraph = class {
|
|
|
1150
1170
|
forkIssuers: path.forkIssuers,
|
|
1151
1171
|
state: path.state.mapValues((v) => this._stateHandler.toLogString(v.assertion))
|
|
1152
1172
|
}), {
|
|
1153
|
-
F:
|
|
1173
|
+
F: __dxlog_file4,
|
|
1154
1174
|
L: 348,
|
|
1155
1175
|
S: this,
|
|
1156
1176
|
C: (f, a) => f(...a)
|
|
@@ -1175,7 +1195,7 @@ var CredentialGraph = class {
|
|
|
1175
1195
|
subject,
|
|
1176
1196
|
state: this._stateHandler.toLogString(vertex.assertion)
|
|
1177
1197
|
}), {
|
|
1178
|
-
F:
|
|
1198
|
+
F: __dxlog_file4,
|
|
1179
1199
|
L: 370,
|
|
1180
1200
|
S: this,
|
|
1181
1201
|
C: (f, a) => f(...a)
|
|
@@ -1219,7 +1239,7 @@ var CredentialGraph = class {
|
|
|
1219
1239
|
log("merge point chosen to break the tie", {
|
|
1220
1240
|
mergePointId: existing.head.id
|
|
1221
1241
|
}, {
|
|
1222
|
-
F:
|
|
1242
|
+
F: __dxlog_file4,
|
|
1223
1243
|
L: 408,
|
|
1224
1244
|
S: this,
|
|
1225
1245
|
C: (f, a) => f(...a)
|
|
@@ -1233,7 +1253,7 @@ var CredentialGraph = class {
|
|
|
1233
1253
|
current: currentVertex.id,
|
|
1234
1254
|
candidate: candidateVertex.id
|
|
1235
1255
|
}, {
|
|
1236
|
-
F:
|
|
1256
|
+
F: __dxlog_file4,
|
|
1237
1257
|
L: 415,
|
|
1238
1258
|
S: this,
|
|
1239
1259
|
C: (f, a) => f(...a)
|
|
@@ -1251,7 +1271,7 @@ var CredentialGraph = class {
|
|
|
1251
1271
|
candidate.forkIssuers.size
|
|
1252
1272
|
]
|
|
1253
1273
|
}, {
|
|
1254
|
-
F:
|
|
1274
|
+
F: __dxlog_file4,
|
|
1255
1275
|
L: 432,
|
|
1256
1276
|
S: this,
|
|
1257
1277
|
C: (f, a) => f(...a)
|
|
@@ -1259,7 +1279,7 @@ var CredentialGraph = class {
|
|
|
1259
1279
|
return candidate.forkIssuers.size > existing.forkIssuers.size;
|
|
1260
1280
|
}
|
|
1261
1281
|
log("issuance date used to break the tie", void 0, {
|
|
1262
|
-
F:
|
|
1282
|
+
F: __dxlog_file4,
|
|
1263
1283
|
L: 437,
|
|
1264
1284
|
S: this,
|
|
1265
1285
|
C: (f, a) => f(...a)
|
|
@@ -1285,7 +1305,7 @@ var toChosenPath = (path) => {
|
|
|
1285
1305
|
};
|
|
1286
1306
|
|
|
1287
1307
|
// packages/core/halo/credentials/src/state-machine/member-state-machine.ts
|
|
1288
|
-
var
|
|
1308
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/state-machine/member-state-machine.ts";
|
|
1289
1309
|
var MemberStateMachine = class {
|
|
1290
1310
|
constructor(_spaceKey) {
|
|
1291
1311
|
this._spaceKey = _spaceKey;
|
|
@@ -1313,8 +1333,8 @@ var MemberStateMachine = class {
|
|
|
1313
1333
|
const assertion = getCredentialAssertion(credential);
|
|
1314
1334
|
switch (assertion["@type"]) {
|
|
1315
1335
|
case "dxos.halo.credentials.SpaceMember": {
|
|
1316
|
-
|
|
1317
|
-
F:
|
|
1336
|
+
invariant5(assertion.spaceKey.equals(this._spaceKey), void 0, {
|
|
1337
|
+
F: __dxlog_file5,
|
|
1318
1338
|
L: 66,
|
|
1319
1339
|
S: this,
|
|
1320
1340
|
A: [
|
|
@@ -1339,7 +1359,7 @@ var MemberStateMachine = class {
|
|
|
1339
1359
|
log2.warn("Member not found", {
|
|
1340
1360
|
id: credential.subject.id
|
|
1341
1361
|
}, {
|
|
1342
|
-
F:
|
|
1362
|
+
F: __dxlog_file5,
|
|
1343
1363
|
L: 81,
|
|
1344
1364
|
S: this,
|
|
1345
1365
|
C: (f, a) => f(...a)
|
|
@@ -1389,7 +1409,7 @@ var MemberStateMachine = class {
|
|
|
1389
1409
|
const path2IssuerRole = this._getRole(scope2, update2.issuer);
|
|
1390
1410
|
if (path2IssuerRole === SpaceMember2.Role.OWNER !== (path1IssuerRole === SpaceMember2.Role.OWNER)) {
|
|
1391
1411
|
log2("owner decision used to break the tie", void 0, {
|
|
1392
|
-
F:
|
|
1412
|
+
F: __dxlog_file5,
|
|
1393
1413
|
L: 139,
|
|
1394
1414
|
S: this,
|
|
1395
1415
|
C: (f, a) => f(...a)
|
|
@@ -1418,7 +1438,7 @@ var MemberStateMachine = class {
|
|
|
1418
1438
|
roleOverride: this.toLogString(override.assertion),
|
|
1419
1439
|
realRole: this.toLogString(scope.state.get(memberId)?.assertion)
|
|
1420
1440
|
}), {
|
|
1421
|
-
F:
|
|
1441
|
+
F: __dxlog_file5,
|
|
1422
1442
|
L: 162,
|
|
1423
1443
|
S: this,
|
|
1424
1444
|
C: (f, a) => f(...a)
|
|
@@ -1431,7 +1451,7 @@ var MemberStateMachine = class {
|
|
|
1431
1451
|
};
|
|
1432
1452
|
|
|
1433
1453
|
// packages/core/halo/credentials/src/state-machine/space-state-machine.ts
|
|
1434
|
-
var
|
|
1454
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/state-machine/space-state-machine.ts";
|
|
1435
1455
|
var SpaceStateMachine = class {
|
|
1436
1456
|
constructor(_spaceKey) {
|
|
1437
1457
|
this._spaceKey = _spaceKey;
|
|
@@ -1509,7 +1529,7 @@ var SpaceStateMachine = class {
|
|
|
1509
1529
|
const result = await verifyCredential(credential);
|
|
1510
1530
|
if (result.kind !== "pass") {
|
|
1511
1531
|
log3.warn(`Invalid credential: ${result.errors.join(", ")}`, void 0, {
|
|
1512
|
-
F:
|
|
1532
|
+
F: __dxlog_file6,
|
|
1513
1533
|
L: 155,
|
|
1514
1534
|
S: this,
|
|
1515
1535
|
C: (f, a) => f(...a)
|
|
@@ -1522,7 +1542,7 @@ var SpaceStateMachine = class {
|
|
|
1522
1542
|
case "dxos.halo.credentials.SpaceGenesis": {
|
|
1523
1543
|
if (this._genesisCredential) {
|
|
1524
1544
|
log3.warn("Space already has a genesis credential.", void 0, {
|
|
1525
|
-
F:
|
|
1545
|
+
F: __dxlog_file6,
|
|
1526
1546
|
L: 164,
|
|
1527
1547
|
S: this,
|
|
1528
1548
|
C: (f, a) => f(...a)
|
|
@@ -1531,7 +1551,7 @@ var SpaceStateMachine = class {
|
|
|
1531
1551
|
}
|
|
1532
1552
|
if (!credential.issuer.equals(this._spaceKey)) {
|
|
1533
1553
|
log3.warn("Space genesis credential must be issued by space.", void 0, {
|
|
1534
|
-
F:
|
|
1554
|
+
F: __dxlog_file6,
|
|
1535
1555
|
L: 168,
|
|
1536
1556
|
S: this,
|
|
1537
1557
|
C: (f, a) => f(...a)
|
|
@@ -1540,7 +1560,7 @@ var SpaceStateMachine = class {
|
|
|
1540
1560
|
}
|
|
1541
1561
|
if (!credential.subject.id.equals(this._spaceKey)) {
|
|
1542
1562
|
log3.warn("Space genesis credential must be issued to space.", void 0, {
|
|
1543
|
-
F:
|
|
1563
|
+
F: __dxlog_file6,
|
|
1544
1564
|
L: 172,
|
|
1545
1565
|
S: this,
|
|
1546
1566
|
C: (f, a) => f(...a)
|
|
@@ -1556,7 +1576,7 @@ var SpaceStateMachine = class {
|
|
|
1556
1576
|
}
|
|
1557
1577
|
if (!this._genesisCredential) {
|
|
1558
1578
|
log3.warn("Space must have a genesis credential before adding members.", void 0, {
|
|
1559
|
-
F:
|
|
1579
|
+
F: __dxlog_file6,
|
|
1560
1580
|
L: 185,
|
|
1561
1581
|
S: this,
|
|
1562
1582
|
C: (f, a) => f(...a)
|
|
@@ -1565,7 +1585,7 @@ var SpaceStateMachine = class {
|
|
|
1565
1585
|
}
|
|
1566
1586
|
if (!this._canInviteNewMembers(credential.issuer)) {
|
|
1567
1587
|
log3.warn(`Space member is not authorized to invite new members: ${credential.issuer}`, void 0, {
|
|
1568
|
-
F:
|
|
1588
|
+
F: __dxlog_file6,
|
|
1569
1589
|
L: 189,
|
|
1570
1590
|
S: this,
|
|
1571
1591
|
C: (f, a) => f(...a)
|
|
@@ -1579,7 +1599,7 @@ var SpaceStateMachine = class {
|
|
|
1579
1599
|
case "dxos.halo.credentials.MemberProfile": {
|
|
1580
1600
|
if (!this._genesisCredential) {
|
|
1581
1601
|
log3.warn("Space must have a genesis credential before adding members.", void 0, {
|
|
1582
|
-
F:
|
|
1602
|
+
F: __dxlog_file6,
|
|
1583
1603
|
L: 200,
|
|
1584
1604
|
S: this,
|
|
1585
1605
|
C: (f, a) => f(...a)
|
|
@@ -1592,7 +1612,7 @@ var SpaceStateMachine = class {
|
|
|
1592
1612
|
case "dxos.halo.credentials.AdmittedFeed": {
|
|
1593
1613
|
if (!this._genesisCredential) {
|
|
1594
1614
|
log3.warn("Space must have a genesis credential before admitting feeds.", void 0, {
|
|
1595
|
-
F:
|
|
1615
|
+
F: __dxlog_file6,
|
|
1596
1616
|
L: 210,
|
|
1597
1617
|
S: this,
|
|
1598
1618
|
C: (f, a) => f(...a)
|
|
@@ -1601,7 +1621,7 @@ var SpaceStateMachine = class {
|
|
|
1601
1621
|
}
|
|
1602
1622
|
if (!this._canAdmitFeeds(credential.issuer)) {
|
|
1603
1623
|
log3.warn(`Space member is not authorized to admit feeds: ${credential.issuer}`, void 0, {
|
|
1604
|
-
F:
|
|
1624
|
+
F: __dxlog_file6,
|
|
1605
1625
|
L: 214,
|
|
1606
1626
|
S: this,
|
|
1607
1627
|
C: (f, a) => f(...a)
|
|
@@ -1615,7 +1635,7 @@ var SpaceStateMachine = class {
|
|
|
1615
1635
|
case "dxos.halo.invitations.DelegateSpaceInvitation": {
|
|
1616
1636
|
if (!this._canInviteNewMembers(credential.issuer)) {
|
|
1617
1637
|
log3.warn(`Invalid invitation, space member is not authorized to invite new members: ${credential.issuer}`, void 0, {
|
|
1618
|
-
F:
|
|
1638
|
+
F: __dxlog_file6,
|
|
1619
1639
|
L: 225,
|
|
1620
1640
|
S: this,
|
|
1621
1641
|
C: (f, a) => f(...a)
|
|
@@ -1663,7 +1683,7 @@ var CredentialConsumer = class {
|
|
|
1663
1683
|
this._onOpen = _onOpen;
|
|
1664
1684
|
this._onClose = _onClose;
|
|
1665
1685
|
this._ctx = new Context(void 0, {
|
|
1666
|
-
F:
|
|
1686
|
+
F: __dxlog_file6,
|
|
1667
1687
|
L: 275
|
|
1668
1688
|
});
|
|
1669
1689
|
this._isReadyForLiveCredentials = false;
|
|
@@ -1690,11 +1710,11 @@ var CredentialConsumer = class {
|
|
|
1690
1710
|
|
|
1691
1711
|
// packages/core/halo/credentials/src/processor/device-state-machine.ts
|
|
1692
1712
|
import { Trigger } from "@dxos/async";
|
|
1693
|
-
import { invariant as
|
|
1713
|
+
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1694
1714
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
1695
1715
|
import { log as log4 } from "@dxos/log";
|
|
1696
1716
|
import { ComplexMap as ComplexMap6 } from "@dxos/util";
|
|
1697
|
-
var
|
|
1717
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/processor/device-state-machine.ts";
|
|
1698
1718
|
var DeviceStateMachine = class {
|
|
1699
1719
|
constructor(_params) {
|
|
1700
1720
|
this._params = _params;
|
|
@@ -1707,7 +1727,7 @@ var DeviceStateMachine = class {
|
|
|
1707
1727
|
deviceKey: this._params.deviceKey,
|
|
1708
1728
|
credential
|
|
1709
1729
|
}, {
|
|
1710
|
-
F:
|
|
1730
|
+
F: __dxlog_file7,
|
|
1711
1731
|
L: 35,
|
|
1712
1732
|
S: this,
|
|
1713
1733
|
C: (f, a) => f(...a)
|
|
@@ -1721,8 +1741,8 @@ var DeviceStateMachine = class {
|
|
|
1721
1741
|
const assertion = getCredentialAssertion(credential);
|
|
1722
1742
|
switch (assertion["@type"]) {
|
|
1723
1743
|
case "dxos.halo.credentials.AuthorizedDevice": {
|
|
1724
|
-
|
|
1725
|
-
F:
|
|
1744
|
+
invariant6(!this.authorizedDeviceKeys.has(assertion.deviceKey), "Device already added.", {
|
|
1745
|
+
F: __dxlog_file7,
|
|
1726
1746
|
L: 51,
|
|
1727
1747
|
S: this,
|
|
1728
1748
|
A: [
|
|
@@ -1736,7 +1756,7 @@ var DeviceStateMachine = class {
|
|
|
1736
1756
|
deviceKey: assertion.deviceKey,
|
|
1737
1757
|
size: this.authorizedDeviceKeys.size
|
|
1738
1758
|
}, {
|
|
1739
|
-
F:
|
|
1759
|
+
F: __dxlog_file7,
|
|
1740
1760
|
L: 54,
|
|
1741
1761
|
S: this,
|
|
1742
1762
|
C: (f, a) => f(...a)
|
|
@@ -1745,8 +1765,8 @@ var DeviceStateMachine = class {
|
|
|
1745
1765
|
break;
|
|
1746
1766
|
}
|
|
1747
1767
|
case "dxos.halo.credentials.DeviceProfile": {
|
|
1748
|
-
|
|
1749
|
-
F:
|
|
1768
|
+
invariant6(this.authorizedDeviceKeys.has(credential.subject.id), "Device not found.", {
|
|
1769
|
+
F: __dxlog_file7,
|
|
1750
1770
|
L: 64,
|
|
1751
1771
|
S: this,
|
|
1752
1772
|
A: [
|
|
@@ -1759,7 +1779,7 @@ var DeviceStateMachine = class {
|
|
|
1759
1779
|
deviceKey: credential.subject.id,
|
|
1760
1780
|
profile: assertion.profile
|
|
1761
1781
|
}, {
|
|
1762
|
-
F:
|
|
1782
|
+
F: __dxlog_file7,
|
|
1763
1783
|
L: 67,
|
|
1764
1784
|
S: this,
|
|
1765
1785
|
C: (f, a) => f(...a)
|
|
@@ -1775,7 +1795,7 @@ var DeviceStateMachine = class {
|
|
|
1775
1795
|
|
|
1776
1796
|
// packages/core/halo/credentials/src/processor/profile-state-machine.ts
|
|
1777
1797
|
import { log as log5 } from "@dxos/log";
|
|
1778
|
-
var
|
|
1798
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/processor/profile-state-machine.ts";
|
|
1779
1799
|
var ProfileStateMachine = class {
|
|
1780
1800
|
constructor(_params) {
|
|
1781
1801
|
this._params = _params;
|
|
@@ -1789,7 +1809,7 @@ var ProfileStateMachine = class {
|
|
|
1789
1809
|
expectedIdentity: this._params.identityKey,
|
|
1790
1810
|
credential
|
|
1791
1811
|
}, {
|
|
1792
|
-
F:
|
|
1812
|
+
F: __dxlog_file8,
|
|
1793
1813
|
L: 34,
|
|
1794
1814
|
S: this,
|
|
1795
1815
|
C: (f, a) => f(...a)
|
|
@@ -1801,7 +1821,7 @@ var ProfileStateMachine = class {
|
|
|
1801
1821
|
identityKey: this._params.identityKey,
|
|
1802
1822
|
profile: this.profile
|
|
1803
1823
|
}, {
|
|
1804
|
-
F:
|
|
1824
|
+
F: __dxlog_file8,
|
|
1805
1825
|
L: 40,
|
|
1806
1826
|
S: this,
|
|
1807
1827
|
C: (f, a) => f(...a)
|
|
@@ -1835,10 +1855,12 @@ export {
|
|
|
1835
1855
|
defaultSecretProvider,
|
|
1836
1856
|
defaultSecretValidator,
|
|
1837
1857
|
generatePasscode,
|
|
1858
|
+
generateSeedPhrase,
|
|
1838
1859
|
getCredentialAssertion,
|
|
1839
1860
|
getCredentialProofPayload,
|
|
1840
1861
|
getPresentationProofPayload,
|
|
1841
1862
|
isValidAuthorizedDeviceCredential,
|
|
1863
|
+
keyPairFromSeedPhrase,
|
|
1842
1864
|
signPresentation,
|
|
1843
1865
|
verifyChain,
|
|
1844
1866
|
verifyCredential,
|