@dxos/credentials 0.6.13 → 0.6.14-main.69511f5
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 -77
- 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 -40
- 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 +2 -49
- package/vitest.config.ts +9 -0
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
import "@dxos/node-std/globals";
|
|
2
2
|
|
|
3
|
-
// inject-globals:@inject-globals
|
|
4
|
-
import {
|
|
5
|
-
global,
|
|
6
|
-
Buffer,
|
|
7
|
-
process
|
|
8
|
-
} from "@dxos/node-std/inject-globals";
|
|
9
|
-
|
|
10
3
|
// packages/core/halo/credentials/src/invitations.ts
|
|
11
4
|
var defaultSecretProvider = async () => Buffer.from("0000");
|
|
12
5
|
var defaultSecretValidator = async (invitation, secret) => true;
|
|
13
6
|
|
|
7
|
+
// packages/core/halo/credentials/src/seedphrase.ts
|
|
8
|
+
import { generateMnemonic, mnemonicToSeedSync } from "bip39";
|
|
9
|
+
import { createKeyPair } from "@dxos/crypto";
|
|
10
|
+
import { invariant } from "@dxos/invariant";
|
|
11
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/seedphrase.ts";
|
|
12
|
+
var generateSeedPhrase = () => generateMnemonic();
|
|
13
|
+
var keyPairFromSeedPhrase = (seedPhrase) => {
|
|
14
|
+
invariant(seedPhrase, void 0, {
|
|
15
|
+
F: __dxlog_file,
|
|
16
|
+
L: 20,
|
|
17
|
+
S: void 0,
|
|
18
|
+
A: [
|
|
19
|
+
"seedPhrase",
|
|
20
|
+
""
|
|
21
|
+
]
|
|
22
|
+
});
|
|
23
|
+
const seed = mnemonicToSeedSync(seedPhrase);
|
|
24
|
+
return createKeyPair(seed);
|
|
25
|
+
};
|
|
26
|
+
|
|
14
27
|
// packages/core/halo/credentials/src/passcode.ts
|
|
15
28
|
var generatePasscode = (length = 4) => {
|
|
16
29
|
let passcode = "";
|
|
@@ -123,7 +136,7 @@ var credentialTypeFilter = (type) => (credential) => checkCredentialType(credent
|
|
|
123
136
|
|
|
124
137
|
// packages/core/halo/credentials/src/credentials/credential-factory.ts
|
|
125
138
|
import { subtleCrypto } from "@dxos/crypto";
|
|
126
|
-
import { invariant } from "@dxos/invariant";
|
|
139
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
127
140
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
128
141
|
|
|
129
142
|
// packages/core/halo/credentials/src/credentials/verifier.ts
|
|
@@ -196,10 +209,10 @@ var verifyChain = async (chain, authority, subject) => {
|
|
|
196
209
|
};
|
|
197
210
|
|
|
198
211
|
// packages/core/halo/credentials/src/credentials/credential-factory.ts
|
|
199
|
-
var
|
|
212
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/credentials/credential-factory.ts";
|
|
200
213
|
var createCredential = async ({ signer, issuer, subject, assertion, signingKey, chain, nonce, parentCredentialIds }) => {
|
|
201
|
-
|
|
202
|
-
F:
|
|
214
|
+
invariant2(assertion["@type"], "Invalid assertion.", {
|
|
215
|
+
F: __dxlog_file2,
|
|
203
216
|
L: 48,
|
|
204
217
|
S: void 0,
|
|
205
218
|
A: [
|
|
@@ -207,8 +220,8 @@ var createCredential = async ({ signer, issuer, subject, assertion, signingKey,
|
|
|
207
220
|
"'Invalid assertion.'"
|
|
208
221
|
]
|
|
209
222
|
});
|
|
210
|
-
|
|
211
|
-
F:
|
|
223
|
+
invariant2(!!signingKey === !!chain, "Chain must be provided if and only if the signing key differs from the issuer.", {
|
|
224
|
+
F: __dxlog_file2,
|
|
212
225
|
L: 49,
|
|
213
226
|
S: void 0,
|
|
214
227
|
A: [
|
|
@@ -218,8 +231,8 @@ var createCredential = async ({ signer, issuer, subject, assertion, signingKey,
|
|
|
218
231
|
});
|
|
219
232
|
if (chain) {
|
|
220
233
|
const result = await verifyChain(chain, issuer, signingKey);
|
|
221
|
-
|
|
222
|
-
F:
|
|
234
|
+
invariant2(result.kind === "pass", "Invalid chain.", {
|
|
235
|
+
F: __dxlog_file2,
|
|
223
236
|
L: 52,
|
|
224
237
|
S: void 0,
|
|
225
238
|
A: [
|
|
@@ -602,10 +615,10 @@ import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/cre
|
|
|
602
615
|
import { Callback as Callback4, ComplexMap as ComplexMap5, ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
603
616
|
|
|
604
617
|
// packages/core/halo/credentials/src/state-machine/feed-state-machine.ts
|
|
605
|
-
import { invariant as
|
|
618
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
606
619
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
607
620
|
import { Callback, ComplexMap } from "@dxos/util";
|
|
608
|
-
var
|
|
621
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/state-machine/feed-state-machine.ts";
|
|
609
622
|
var FeedStateMachine = class {
|
|
610
623
|
constructor(_spaceKey) {
|
|
611
624
|
this._spaceKey = _spaceKey;
|
|
@@ -623,8 +636,8 @@ var FeedStateMachine = class {
|
|
|
623
636
|
*/
|
|
624
637
|
async process(credential, fromFeed) {
|
|
625
638
|
const assertion = getCredentialAssertion(credential);
|
|
626
|
-
|
|
627
|
-
F:
|
|
639
|
+
invariant3(assertion["@type"] === "dxos.halo.credentials.AdmittedFeed", void 0, {
|
|
640
|
+
F: __dxlog_file3,
|
|
628
641
|
L: 47,
|
|
629
642
|
S: this,
|
|
630
643
|
A: [
|
|
@@ -632,8 +645,8 @@ var FeedStateMachine = class {
|
|
|
632
645
|
""
|
|
633
646
|
]
|
|
634
647
|
});
|
|
635
|
-
|
|
636
|
-
F:
|
|
648
|
+
invariant3(assertion.spaceKey.equals(this._spaceKey), void 0, {
|
|
649
|
+
F: __dxlog_file3,
|
|
637
650
|
L: 48,
|
|
638
651
|
S: this,
|
|
639
652
|
A: [
|
|
@@ -723,18 +736,18 @@ var InvitationStateMachine = class {
|
|
|
723
736
|
};
|
|
724
737
|
|
|
725
738
|
// packages/core/halo/credentials/src/state-machine/member-state-machine.ts
|
|
726
|
-
import { invariant as
|
|
739
|
+
import { invariant as invariant5 } from "@dxos/invariant";
|
|
727
740
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
728
741
|
import { log as log2 } from "@dxos/log";
|
|
729
742
|
import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
730
743
|
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
731
744
|
|
|
732
745
|
// packages/core/halo/credentials/src/graph/credential-graph.ts
|
|
733
|
-
import { invariant as
|
|
746
|
+
import { invariant as invariant4 } from "@dxos/invariant";
|
|
734
747
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
735
748
|
import { log } from "@dxos/log";
|
|
736
749
|
import { Callback as Callback3, ComplexMap as ComplexMap3, ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
737
|
-
var
|
|
750
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/graph/credential-graph.ts";
|
|
738
751
|
var CredentialGraph = class {
|
|
739
752
|
constructor(_stateHandler) {
|
|
740
753
|
this._stateHandler = _stateHandler;
|
|
@@ -789,7 +802,7 @@ var CredentialGraph = class {
|
|
|
789
802
|
credential,
|
|
790
803
|
parentId
|
|
791
804
|
}, {
|
|
792
|
-
F:
|
|
805
|
+
F: __dxlog_file4,
|
|
793
806
|
L: 72,
|
|
794
807
|
S: this,
|
|
795
808
|
C: (f, a) => f(...a)
|
|
@@ -810,8 +823,8 @@ var CredentialGraph = class {
|
|
|
810
823
|
if (sentinelIdx >= 0) {
|
|
811
824
|
vertex.children.splice(sentinelIdx, 1);
|
|
812
825
|
const vertexInSentinelIdx = this._sentinel.parents.indexOf(vertex);
|
|
813
|
-
|
|
814
|
-
F:
|
|
826
|
+
invariant4(vertexInSentinelIdx >= 0, void 0, {
|
|
827
|
+
F: __dxlog_file4,
|
|
815
828
|
L: 90,
|
|
816
829
|
S: this,
|
|
817
830
|
A: [
|
|
@@ -824,8 +837,8 @@ var CredentialGraph = class {
|
|
|
824
837
|
}
|
|
825
838
|
async _onVertexInserted(newVertex) {
|
|
826
839
|
const { credential, assertion } = newVertex;
|
|
827
|
-
|
|
828
|
-
F:
|
|
840
|
+
invariant4(credential, void 0, {
|
|
841
|
+
F: __dxlog_file4,
|
|
829
842
|
L: 97,
|
|
830
843
|
S: this,
|
|
831
844
|
A: [
|
|
@@ -870,7 +883,7 @@ var CredentialGraph = class {
|
|
|
870
883
|
log("visit vertex", {
|
|
871
884
|
id: path.head.id
|
|
872
885
|
}, {
|
|
873
|
-
F:
|
|
886
|
+
F: __dxlog_file4,
|
|
874
887
|
L: 132,
|
|
875
888
|
S: this,
|
|
876
889
|
C: (f, a) => f(...a)
|
|
@@ -879,7 +892,7 @@ var CredentialGraph = class {
|
|
|
879
892
|
const convergedPaths = this._handleMergePoint(paths, pendingPaths, path);
|
|
880
893
|
if (convergedPaths == null) {
|
|
881
894
|
log("waiting for other paths", void 0, {
|
|
882
|
-
F:
|
|
895
|
+
F: __dxlog_file4,
|
|
883
896
|
L: 136,
|
|
884
897
|
S: this,
|
|
885
898
|
C: (f, a) => f(...a)
|
|
@@ -908,7 +921,7 @@ var CredentialGraph = class {
|
|
|
908
921
|
head: p.head.id
|
|
909
922
|
}))
|
|
910
923
|
}, {
|
|
911
|
-
F:
|
|
924
|
+
F: __dxlog_file4,
|
|
912
925
|
L: 155,
|
|
913
926
|
S: this,
|
|
914
927
|
C: (f, a) => f(...a)
|
|
@@ -934,7 +947,7 @@ var CredentialGraph = class {
|
|
|
934
947
|
overrides: path?.stateOverrides?.mapValues((v) => this._stateHandler.toLogString(v.assertion))
|
|
935
948
|
}))
|
|
936
949
|
}), {
|
|
937
|
-
F:
|
|
950
|
+
F: __dxlog_file4,
|
|
938
951
|
L: 175,
|
|
939
952
|
S: this,
|
|
940
953
|
C: (f, a) => f(...a)
|
|
@@ -951,7 +964,7 @@ var CredentialGraph = class {
|
|
|
951
964
|
}
|
|
952
965
|
if (path.head.id === this._sentinel.id && paths.length > 0) {
|
|
953
966
|
log("waiting for all the active paths to converge on the sentinel", void 0, {
|
|
954
|
-
F:
|
|
967
|
+
F: __dxlog_file4,
|
|
955
968
|
L: 199,
|
|
956
969
|
S: this,
|
|
957
970
|
C: (f, a) => f(...a)
|
|
@@ -981,7 +994,7 @@ var CredentialGraph = class {
|
|
|
981
994
|
subject: updatedSubject,
|
|
982
995
|
newState: this._stateHandler.toLogString(path.head.assertion)
|
|
983
996
|
}), {
|
|
984
|
-
F:
|
|
997
|
+
F: __dxlog_file4,
|
|
985
998
|
L: 223,
|
|
986
999
|
S: this,
|
|
987
1000
|
C: (f, a) => f(...a)
|
|
@@ -996,7 +1009,7 @@ var CredentialGraph = class {
|
|
|
996
1009
|
from: path.head.id,
|
|
997
1010
|
to: choice.id
|
|
998
1011
|
}, {
|
|
999
|
-
F:
|
|
1012
|
+
F: __dxlog_file4,
|
|
1000
1013
|
L: 234,
|
|
1001
1014
|
S: this,
|
|
1002
1015
|
C: (f, a) => f(...a)
|
|
@@ -1093,8 +1106,8 @@ var CredentialGraph = class {
|
|
|
1093
1106
|
return path;
|
|
1094
1107
|
}
|
|
1095
1108
|
_mergePaths(convergedPaths) {
|
|
1096
|
-
|
|
1097
|
-
F:
|
|
1109
|
+
invariant4(convergedPaths.length >= 1, void 0, {
|
|
1110
|
+
F: __dxlog_file4,
|
|
1098
1111
|
L: 324,
|
|
1099
1112
|
S: this,
|
|
1100
1113
|
A: [
|
|
@@ -1114,14 +1127,14 @@ var CredentialGraph = class {
|
|
|
1114
1127
|
pathCount: convergedPaths.length,
|
|
1115
1128
|
forkPoints: convergedPaths.map((fp) => fp.forkPoint?.head.id)
|
|
1116
1129
|
}), {
|
|
1117
|
-
F:
|
|
1130
|
+
F: __dxlog_file4,
|
|
1118
1131
|
L: 329,
|
|
1119
1132
|
S: this,
|
|
1120
1133
|
C: (f, a) => f(...a)
|
|
1121
1134
|
});
|
|
1122
1135
|
const paths = convergedPaths.map((p) => this._moveUpToForkPoint(forkPoint, p));
|
|
1123
|
-
|
|
1124
|
-
F:
|
|
1136
|
+
invariant4(forkPoint, void 0, {
|
|
1137
|
+
F: __dxlog_file4,
|
|
1125
1138
|
L: 335,
|
|
1126
1139
|
S: this,
|
|
1127
1140
|
A: [
|
|
@@ -1150,7 +1163,7 @@ var CredentialGraph = class {
|
|
|
1150
1163
|
forkIssuers: path.forkIssuers,
|
|
1151
1164
|
state: path.state.mapValues((v) => this._stateHandler.toLogString(v.assertion))
|
|
1152
1165
|
}), {
|
|
1153
|
-
F:
|
|
1166
|
+
F: __dxlog_file4,
|
|
1154
1167
|
L: 348,
|
|
1155
1168
|
S: this,
|
|
1156
1169
|
C: (f, a) => f(...a)
|
|
@@ -1175,7 +1188,7 @@ var CredentialGraph = class {
|
|
|
1175
1188
|
subject,
|
|
1176
1189
|
state: this._stateHandler.toLogString(vertex.assertion)
|
|
1177
1190
|
}), {
|
|
1178
|
-
F:
|
|
1191
|
+
F: __dxlog_file4,
|
|
1179
1192
|
L: 370,
|
|
1180
1193
|
S: this,
|
|
1181
1194
|
C: (f, a) => f(...a)
|
|
@@ -1219,7 +1232,7 @@ var CredentialGraph = class {
|
|
|
1219
1232
|
log("merge point chosen to break the tie", {
|
|
1220
1233
|
mergePointId: existing.head.id
|
|
1221
1234
|
}, {
|
|
1222
|
-
F:
|
|
1235
|
+
F: __dxlog_file4,
|
|
1223
1236
|
L: 408,
|
|
1224
1237
|
S: this,
|
|
1225
1238
|
C: (f, a) => f(...a)
|
|
@@ -1233,7 +1246,7 @@ var CredentialGraph = class {
|
|
|
1233
1246
|
current: currentVertex.id,
|
|
1234
1247
|
candidate: candidateVertex.id
|
|
1235
1248
|
}, {
|
|
1236
|
-
F:
|
|
1249
|
+
F: __dxlog_file4,
|
|
1237
1250
|
L: 415,
|
|
1238
1251
|
S: this,
|
|
1239
1252
|
C: (f, a) => f(...a)
|
|
@@ -1251,7 +1264,7 @@ var CredentialGraph = class {
|
|
|
1251
1264
|
candidate.forkIssuers.size
|
|
1252
1265
|
]
|
|
1253
1266
|
}, {
|
|
1254
|
-
F:
|
|
1267
|
+
F: __dxlog_file4,
|
|
1255
1268
|
L: 432,
|
|
1256
1269
|
S: this,
|
|
1257
1270
|
C: (f, a) => f(...a)
|
|
@@ -1259,7 +1272,7 @@ var CredentialGraph = class {
|
|
|
1259
1272
|
return candidate.forkIssuers.size > existing.forkIssuers.size;
|
|
1260
1273
|
}
|
|
1261
1274
|
log("issuance date used to break the tie", void 0, {
|
|
1262
|
-
F:
|
|
1275
|
+
F: __dxlog_file4,
|
|
1263
1276
|
L: 437,
|
|
1264
1277
|
S: this,
|
|
1265
1278
|
C: (f, a) => f(...a)
|
|
@@ -1285,7 +1298,7 @@ var toChosenPath = (path) => {
|
|
|
1285
1298
|
};
|
|
1286
1299
|
|
|
1287
1300
|
// packages/core/halo/credentials/src/state-machine/member-state-machine.ts
|
|
1288
|
-
var
|
|
1301
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/state-machine/member-state-machine.ts";
|
|
1289
1302
|
var MemberStateMachine = class {
|
|
1290
1303
|
constructor(_spaceKey) {
|
|
1291
1304
|
this._spaceKey = _spaceKey;
|
|
@@ -1313,8 +1326,8 @@ var MemberStateMachine = class {
|
|
|
1313
1326
|
const assertion = getCredentialAssertion(credential);
|
|
1314
1327
|
switch (assertion["@type"]) {
|
|
1315
1328
|
case "dxos.halo.credentials.SpaceMember": {
|
|
1316
|
-
|
|
1317
|
-
F:
|
|
1329
|
+
invariant5(assertion.spaceKey.equals(this._spaceKey), void 0, {
|
|
1330
|
+
F: __dxlog_file5,
|
|
1318
1331
|
L: 66,
|
|
1319
1332
|
S: this,
|
|
1320
1333
|
A: [
|
|
@@ -1339,7 +1352,7 @@ var MemberStateMachine = class {
|
|
|
1339
1352
|
log2.warn("Member not found", {
|
|
1340
1353
|
id: credential.subject.id
|
|
1341
1354
|
}, {
|
|
1342
|
-
F:
|
|
1355
|
+
F: __dxlog_file5,
|
|
1343
1356
|
L: 81,
|
|
1344
1357
|
S: this,
|
|
1345
1358
|
C: (f, a) => f(...a)
|
|
@@ -1389,7 +1402,7 @@ var MemberStateMachine = class {
|
|
|
1389
1402
|
const path2IssuerRole = this._getRole(scope2, update2.issuer);
|
|
1390
1403
|
if (path2IssuerRole === SpaceMember2.Role.OWNER !== (path1IssuerRole === SpaceMember2.Role.OWNER)) {
|
|
1391
1404
|
log2("owner decision used to break the tie", void 0, {
|
|
1392
|
-
F:
|
|
1405
|
+
F: __dxlog_file5,
|
|
1393
1406
|
L: 139,
|
|
1394
1407
|
S: this,
|
|
1395
1408
|
C: (f, a) => f(...a)
|
|
@@ -1418,7 +1431,7 @@ var MemberStateMachine = class {
|
|
|
1418
1431
|
roleOverride: this.toLogString(override.assertion),
|
|
1419
1432
|
realRole: this.toLogString(scope.state.get(memberId)?.assertion)
|
|
1420
1433
|
}), {
|
|
1421
|
-
F:
|
|
1434
|
+
F: __dxlog_file5,
|
|
1422
1435
|
L: 162,
|
|
1423
1436
|
S: this,
|
|
1424
1437
|
C: (f, a) => f(...a)
|
|
@@ -1431,7 +1444,7 @@ var MemberStateMachine = class {
|
|
|
1431
1444
|
};
|
|
1432
1445
|
|
|
1433
1446
|
// packages/core/halo/credentials/src/state-machine/space-state-machine.ts
|
|
1434
|
-
var
|
|
1447
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/state-machine/space-state-machine.ts";
|
|
1435
1448
|
var SpaceStateMachine = class {
|
|
1436
1449
|
constructor(_spaceKey) {
|
|
1437
1450
|
this._spaceKey = _spaceKey;
|
|
@@ -1509,7 +1522,7 @@ var SpaceStateMachine = class {
|
|
|
1509
1522
|
const result = await verifyCredential(credential);
|
|
1510
1523
|
if (result.kind !== "pass") {
|
|
1511
1524
|
log3.warn(`Invalid credential: ${result.errors.join(", ")}`, void 0, {
|
|
1512
|
-
F:
|
|
1525
|
+
F: __dxlog_file6,
|
|
1513
1526
|
L: 155,
|
|
1514
1527
|
S: this,
|
|
1515
1528
|
C: (f, a) => f(...a)
|
|
@@ -1522,7 +1535,7 @@ var SpaceStateMachine = class {
|
|
|
1522
1535
|
case "dxos.halo.credentials.SpaceGenesis": {
|
|
1523
1536
|
if (this._genesisCredential) {
|
|
1524
1537
|
log3.warn("Space already has a genesis credential.", void 0, {
|
|
1525
|
-
F:
|
|
1538
|
+
F: __dxlog_file6,
|
|
1526
1539
|
L: 164,
|
|
1527
1540
|
S: this,
|
|
1528
1541
|
C: (f, a) => f(...a)
|
|
@@ -1531,7 +1544,7 @@ var SpaceStateMachine = class {
|
|
|
1531
1544
|
}
|
|
1532
1545
|
if (!credential.issuer.equals(this._spaceKey)) {
|
|
1533
1546
|
log3.warn("Space genesis credential must be issued by space.", void 0, {
|
|
1534
|
-
F:
|
|
1547
|
+
F: __dxlog_file6,
|
|
1535
1548
|
L: 168,
|
|
1536
1549
|
S: this,
|
|
1537
1550
|
C: (f, a) => f(...a)
|
|
@@ -1540,7 +1553,7 @@ var SpaceStateMachine = class {
|
|
|
1540
1553
|
}
|
|
1541
1554
|
if (!credential.subject.id.equals(this._spaceKey)) {
|
|
1542
1555
|
log3.warn("Space genesis credential must be issued to space.", void 0, {
|
|
1543
|
-
F:
|
|
1556
|
+
F: __dxlog_file6,
|
|
1544
1557
|
L: 172,
|
|
1545
1558
|
S: this,
|
|
1546
1559
|
C: (f, a) => f(...a)
|
|
@@ -1556,7 +1569,7 @@ var SpaceStateMachine = class {
|
|
|
1556
1569
|
}
|
|
1557
1570
|
if (!this._genesisCredential) {
|
|
1558
1571
|
log3.warn("Space must have a genesis credential before adding members.", void 0, {
|
|
1559
|
-
F:
|
|
1572
|
+
F: __dxlog_file6,
|
|
1560
1573
|
L: 185,
|
|
1561
1574
|
S: this,
|
|
1562
1575
|
C: (f, a) => f(...a)
|
|
@@ -1565,7 +1578,7 @@ var SpaceStateMachine = class {
|
|
|
1565
1578
|
}
|
|
1566
1579
|
if (!this._canInviteNewMembers(credential.issuer)) {
|
|
1567
1580
|
log3.warn(`Space member is not authorized to invite new members: ${credential.issuer}`, void 0, {
|
|
1568
|
-
F:
|
|
1581
|
+
F: __dxlog_file6,
|
|
1569
1582
|
L: 189,
|
|
1570
1583
|
S: this,
|
|
1571
1584
|
C: (f, a) => f(...a)
|
|
@@ -1579,7 +1592,7 @@ var SpaceStateMachine = class {
|
|
|
1579
1592
|
case "dxos.halo.credentials.MemberProfile": {
|
|
1580
1593
|
if (!this._genesisCredential) {
|
|
1581
1594
|
log3.warn("Space must have a genesis credential before adding members.", void 0, {
|
|
1582
|
-
F:
|
|
1595
|
+
F: __dxlog_file6,
|
|
1583
1596
|
L: 200,
|
|
1584
1597
|
S: this,
|
|
1585
1598
|
C: (f, a) => f(...a)
|
|
@@ -1592,7 +1605,7 @@ var SpaceStateMachine = class {
|
|
|
1592
1605
|
case "dxos.halo.credentials.AdmittedFeed": {
|
|
1593
1606
|
if (!this._genesisCredential) {
|
|
1594
1607
|
log3.warn("Space must have a genesis credential before admitting feeds.", void 0, {
|
|
1595
|
-
F:
|
|
1608
|
+
F: __dxlog_file6,
|
|
1596
1609
|
L: 210,
|
|
1597
1610
|
S: this,
|
|
1598
1611
|
C: (f, a) => f(...a)
|
|
@@ -1601,7 +1614,7 @@ var SpaceStateMachine = class {
|
|
|
1601
1614
|
}
|
|
1602
1615
|
if (!this._canAdmitFeeds(credential.issuer)) {
|
|
1603
1616
|
log3.warn(`Space member is not authorized to admit feeds: ${credential.issuer}`, void 0, {
|
|
1604
|
-
F:
|
|
1617
|
+
F: __dxlog_file6,
|
|
1605
1618
|
L: 214,
|
|
1606
1619
|
S: this,
|
|
1607
1620
|
C: (f, a) => f(...a)
|
|
@@ -1615,7 +1628,7 @@ var SpaceStateMachine = class {
|
|
|
1615
1628
|
case "dxos.halo.invitations.DelegateSpaceInvitation": {
|
|
1616
1629
|
if (!this._canInviteNewMembers(credential.issuer)) {
|
|
1617
1630
|
log3.warn(`Invalid invitation, space member is not authorized to invite new members: ${credential.issuer}`, void 0, {
|
|
1618
|
-
F:
|
|
1631
|
+
F: __dxlog_file6,
|
|
1619
1632
|
L: 225,
|
|
1620
1633
|
S: this,
|
|
1621
1634
|
C: (f, a) => f(...a)
|
|
@@ -1663,7 +1676,7 @@ var CredentialConsumer = class {
|
|
|
1663
1676
|
this._onOpen = _onOpen;
|
|
1664
1677
|
this._onClose = _onClose;
|
|
1665
1678
|
this._ctx = new Context(void 0, {
|
|
1666
|
-
F:
|
|
1679
|
+
F: __dxlog_file6,
|
|
1667
1680
|
L: 275
|
|
1668
1681
|
});
|
|
1669
1682
|
this._isReadyForLiveCredentials = false;
|
|
@@ -1690,11 +1703,11 @@ var CredentialConsumer = class {
|
|
|
1690
1703
|
|
|
1691
1704
|
// packages/core/halo/credentials/src/processor/device-state-machine.ts
|
|
1692
1705
|
import { Trigger } from "@dxos/async";
|
|
1693
|
-
import { invariant as
|
|
1706
|
+
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1694
1707
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
1695
1708
|
import { log as log4 } from "@dxos/log";
|
|
1696
1709
|
import { ComplexMap as ComplexMap6 } from "@dxos/util";
|
|
1697
|
-
var
|
|
1710
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/processor/device-state-machine.ts";
|
|
1698
1711
|
var DeviceStateMachine = class {
|
|
1699
1712
|
constructor(_params) {
|
|
1700
1713
|
this._params = _params;
|
|
@@ -1707,7 +1720,7 @@ var DeviceStateMachine = class {
|
|
|
1707
1720
|
deviceKey: this._params.deviceKey,
|
|
1708
1721
|
credential
|
|
1709
1722
|
}, {
|
|
1710
|
-
F:
|
|
1723
|
+
F: __dxlog_file7,
|
|
1711
1724
|
L: 35,
|
|
1712
1725
|
S: this,
|
|
1713
1726
|
C: (f, a) => f(...a)
|
|
@@ -1721,8 +1734,8 @@ var DeviceStateMachine = class {
|
|
|
1721
1734
|
const assertion = getCredentialAssertion(credential);
|
|
1722
1735
|
switch (assertion["@type"]) {
|
|
1723
1736
|
case "dxos.halo.credentials.AuthorizedDevice": {
|
|
1724
|
-
|
|
1725
|
-
F:
|
|
1737
|
+
invariant6(!this.authorizedDeviceKeys.has(assertion.deviceKey), "Device already added.", {
|
|
1738
|
+
F: __dxlog_file7,
|
|
1726
1739
|
L: 51,
|
|
1727
1740
|
S: this,
|
|
1728
1741
|
A: [
|
|
@@ -1736,7 +1749,7 @@ var DeviceStateMachine = class {
|
|
|
1736
1749
|
deviceKey: assertion.deviceKey,
|
|
1737
1750
|
size: this.authorizedDeviceKeys.size
|
|
1738
1751
|
}, {
|
|
1739
|
-
F:
|
|
1752
|
+
F: __dxlog_file7,
|
|
1740
1753
|
L: 54,
|
|
1741
1754
|
S: this,
|
|
1742
1755
|
C: (f, a) => f(...a)
|
|
@@ -1745,8 +1758,8 @@ var DeviceStateMachine = class {
|
|
|
1745
1758
|
break;
|
|
1746
1759
|
}
|
|
1747
1760
|
case "dxos.halo.credentials.DeviceProfile": {
|
|
1748
|
-
|
|
1749
|
-
F:
|
|
1761
|
+
invariant6(this.authorizedDeviceKeys.has(credential.subject.id), "Device not found.", {
|
|
1762
|
+
F: __dxlog_file7,
|
|
1750
1763
|
L: 64,
|
|
1751
1764
|
S: this,
|
|
1752
1765
|
A: [
|
|
@@ -1759,7 +1772,7 @@ var DeviceStateMachine = class {
|
|
|
1759
1772
|
deviceKey: credential.subject.id,
|
|
1760
1773
|
profile: assertion.profile
|
|
1761
1774
|
}, {
|
|
1762
|
-
F:
|
|
1775
|
+
F: __dxlog_file7,
|
|
1763
1776
|
L: 67,
|
|
1764
1777
|
S: this,
|
|
1765
1778
|
C: (f, a) => f(...a)
|
|
@@ -1775,7 +1788,7 @@ var DeviceStateMachine = class {
|
|
|
1775
1788
|
|
|
1776
1789
|
// packages/core/halo/credentials/src/processor/profile-state-machine.ts
|
|
1777
1790
|
import { log as log5 } from "@dxos/log";
|
|
1778
|
-
var
|
|
1791
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/processor/profile-state-machine.ts";
|
|
1779
1792
|
var ProfileStateMachine = class {
|
|
1780
1793
|
constructor(_params) {
|
|
1781
1794
|
this._params = _params;
|
|
@@ -1789,7 +1802,7 @@ var ProfileStateMachine = class {
|
|
|
1789
1802
|
expectedIdentity: this._params.identityKey,
|
|
1790
1803
|
credential
|
|
1791
1804
|
}, {
|
|
1792
|
-
F:
|
|
1805
|
+
F: __dxlog_file8,
|
|
1793
1806
|
L: 34,
|
|
1794
1807
|
S: this,
|
|
1795
1808
|
C: (f, a) => f(...a)
|
|
@@ -1801,7 +1814,7 @@ var ProfileStateMachine = class {
|
|
|
1801
1814
|
identityKey: this._params.identityKey,
|
|
1802
1815
|
profile: this.profile
|
|
1803
1816
|
}, {
|
|
1804
|
-
F:
|
|
1817
|
+
F: __dxlog_file8,
|
|
1805
1818
|
L: 40,
|
|
1806
1819
|
S: this,
|
|
1807
1820
|
C: (f, a) => f(...a)
|
|
@@ -1835,10 +1848,12 @@ export {
|
|
|
1835
1848
|
defaultSecretProvider,
|
|
1836
1849
|
defaultSecretValidator,
|
|
1837
1850
|
generatePasscode,
|
|
1851
|
+
generateSeedPhrase,
|
|
1838
1852
|
getCredentialAssertion,
|
|
1839
1853
|
getCredentialProofPayload,
|
|
1840
1854
|
getPresentationProofPayload,
|
|
1841
1855
|
isValidAuthorizedDeviceCredential,
|
|
1856
|
+
keyPairFromSeedPhrase,
|
|
1842
1857
|
signPresentation,
|
|
1843
1858
|
verifyChain,
|
|
1844
1859
|
verifyCredential,
|