@dxos/credentials 0.8.3 → 0.8.4-main.1da679c

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.
Files changed (47) hide show
  1. package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
  2. package/dist/lib/browser/index.mjs +268 -120
  3. package/dist/lib/browser/index.mjs.map +3 -3
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/node-esm/index.mjs +268 -120
  6. package/dist/lib/node-esm/index.mjs.map +3 -3
  7. package/dist/lib/node-esm/meta.json +1 -1
  8. package/dist/types/src/credentials/assertions.d.ts +1 -1
  9. package/dist/types/src/credentials/assertions.d.ts.map +1 -1
  10. package/dist/types/src/credentials/credential-generator.d.ts.map +1 -1
  11. package/dist/types/src/did.d.ts +1 -1
  12. package/dist/types/src/did.d.ts.map +1 -1
  13. package/dist/types/src/presentations/presentation.d.ts.map +1 -1
  14. package/dist/types/src/presentations/verifier.d.ts.map +1 -1
  15. package/dist/types/src/processor/device-state-machine.d.ts.map +1 -1
  16. package/dist/types/src/processor/index.d.ts +1 -1
  17. package/dist/types/src/processor/index.d.ts.map +1 -1
  18. package/dist/types/src/processor/profile-state-machine.d.ts.map +1 -1
  19. package/dist/types/src/state-machine/member-state-machine.d.ts +1 -1
  20. package/dist/types/src/state-machine/member-state-machine.d.ts.map +1 -1
  21. package/dist/types/src/state-machine/space-state-machine.d.ts +1 -1
  22. package/dist/types/src/state-machine/space-state-machine.d.ts.map +1 -1
  23. package/dist/types/tsconfig.tsbuildinfo +1 -1
  24. package/moon.yml +11 -0
  25. package/package.json +13 -12
  26. package/src/credentials/assertions.ts +1 -1
  27. package/src/credentials/credential-factory.ts +1 -1
  28. package/src/credentials/credential-generator.ts +1 -1
  29. package/src/did.ts +2 -2
  30. package/src/presentations/json-encoding.test.ts +3 -1
  31. package/src/presentations/presentation.ts +2 -1
  32. package/src/presentations/verifier.test.ts +2 -1
  33. package/src/presentations/verifier.ts +2 -1
  34. package/src/processor/device-state-machine.ts +2 -1
  35. package/src/processor/index.ts +1 -1
  36. package/src/processor/profile-state-machine.ts +2 -1
  37. package/src/state-machine/invitation-state-machine.test.ts +3 -2
  38. package/src/state-machine/member-state-machine.test.ts +2 -1
  39. package/src/state-machine/member-state-machine.ts +1 -1
  40. package/src/state-machine/space-state-machine.test.ts +2 -1
  41. package/src/state-machine/space-state-machine.ts +14 -8
  42. package/vitest.config.ts +5 -2
  43. package/.eslintrc.cjs +0 -7
  44. package/dist/lib/node/index.cjs +0 -1894
  45. package/dist/lib/node/index.cjs.map +0 -7
  46. package/dist/lib/node/meta.json +0 -1
  47. package/project.json +0 -27
@@ -1,8 +1,8 @@
1
1
  import "@dxos/node-std/globals";
2
2
 
3
- // packages/core/halo/credentials/src/did.ts
3
+ // src/did.ts
4
4
  import { subtleCrypto } from "@dxos/crypto";
5
- import { PublicKey, IdentityDid } from "@dxos/keys";
5
+ import { IdentityDid, PublicKey } from "@dxos/keys";
6
6
  import { ComplexMap } from "@dxos/util";
7
7
  var IDENTITY_DIDS_CACHE = new ComplexMap(PublicKey.hash);
8
8
  var createDidFromIdentityKey = async (identityKey) => {
@@ -17,15 +17,15 @@ var createDidFromIdentityKey = async (identityKey) => {
17
17
  return identityDid;
18
18
  };
19
19
 
20
- // packages/core/halo/credentials/src/invitations.ts
20
+ // src/invitations.ts
21
21
  var defaultSecretProvider = async () => Buffer.from("0000");
22
22
  var defaultSecretValidator = async (invitation, secret) => true;
23
23
 
24
- // packages/core/halo/credentials/src/seedphrase.ts
24
+ // src/seedphrase.ts
25
25
  import { generateMnemonic, mnemonicToSeedSync } from "bip39";
26
26
  import { createKeyPair } from "@dxos/crypto";
27
27
  import { invariant } from "@dxos/invariant";
28
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/seedphrase.ts";
28
+ var __dxlog_file = "/__w/dxos/dxos/packages/core/halo/credentials/src/seedphrase.ts";
29
29
  var generateSeedPhrase = () => generateMnemonic();
30
30
  var keyPairFromSeedPhrase = (seedPhrase) => {
31
31
  invariant(seedPhrase, void 0, {
@@ -41,7 +41,7 @@ var keyPairFromSeedPhrase = (seedPhrase) => {
41
41
  return createKeyPair(seed);
42
42
  };
43
43
 
44
- // packages/core/halo/credentials/src/passcode.ts
44
+ // src/passcode.ts
45
45
  var generatePasscode = (length = 4) => {
46
46
  let passcode = "";
47
47
  for (let i = 0; i < length; i++) {
@@ -50,7 +50,7 @@ var generatePasscode = (length = 4) => {
50
50
  return passcode;
51
51
  };
52
52
 
53
- // packages/core/halo/credentials/src/credentials/signing.ts
53
+ // src/credentials/signing.ts
54
54
  import stableStringify from "json-stable-stringify";
55
55
  import { PublicKey as PublicKey2 } from "@dxos/keys";
56
56
  import { Timeframe } from "@dxos/timeframe";
@@ -114,7 +114,7 @@ var truncateKey = (key) => {
114
114
  return `${str.substring(0, 4)}...${str.substring(str.length - 4)}`;
115
115
  };
116
116
 
117
- // packages/core/halo/credentials/src/presentations/signing.ts
117
+ // src/presentations/signing.ts
118
118
  var getPresentationProofPayload = (credentials, proof) => {
119
119
  const copy = {
120
120
  credentials: credentials.map((credential) => removeEmptyParentCredentialIds(credential)),
@@ -142,7 +142,7 @@ var removeEmptyParentCredentialIds = (credential) => {
142
142
  return copy;
143
143
  };
144
144
 
145
- // packages/core/halo/credentials/src/credentials/assertions.ts
145
+ // src/credentials/assertions.ts
146
146
  var getCredentialAssertion = (credential) => credential.subject.assertion;
147
147
  var isValidAuthorizedDeviceCredential = (credential, identityKey, deviceKey) => {
148
148
  const assertion = getCredentialAssertion(credential);
@@ -151,12 +151,12 @@ var isValidAuthorizedDeviceCredential = (credential, identityKey, deviceKey) =>
151
151
  var checkCredentialType = (credential, type) => credential.subject.assertion["@type"] === type;
152
152
  var credentialTypeFilter = (type) => (credential) => checkCredentialType(credential, type);
153
153
 
154
- // packages/core/halo/credentials/src/credentials/credential-factory.ts
154
+ // src/credentials/credential-factory.ts
155
155
  import { subtleCrypto as subtleCrypto2 } from "@dxos/crypto";
156
156
  import { invariant as invariant2 } from "@dxos/invariant";
157
157
  import { PublicKey as PublicKey3 } from "@dxos/keys";
158
158
 
159
- // packages/core/halo/credentials/src/credentials/verifier.ts
159
+ // src/credentials/verifier.ts
160
160
  import { verifySignature } from "@dxos/crypto";
161
161
  var SIGNATURE_TYPE_ED25519 = "ED25519Signature";
162
162
  var verifyCredential = async (credential) => {
@@ -225,8 +225,8 @@ var verifyChain = async (chain, authority, subject) => {
225
225
  };
226
226
  };
227
227
 
228
- // packages/core/halo/credentials/src/credentials/credential-factory.ts
229
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/credentials/credential-factory.ts";
228
+ // src/credentials/credential-factory.ts
229
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/core/halo/credentials/src/credentials/credential-factory.ts";
230
230
  var createCredential = async ({ signer, issuer, subject, assertion, signingKey, chain, nonce, parentCredentialIds }) => {
231
231
  invariant2(assertion["@type"], "Invalid assertion.", {
232
232
  F: __dxlog_file2,
@@ -313,15 +313,23 @@ var createCredentialSignerWithChain = (signer, chain, signingKey) => ({
313
313
  })
314
314
  });
315
315
 
316
- // packages/core/halo/credentials/src/credentials/credential-generator.ts
316
+ // src/credentials/credential-generator.ts
317
317
  import { AdmittedFeed, SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
318
318
  import { Timeframe as Timeframe2 } from "@dxos/timeframe";
319
- var CredentialGenerator = class {
320
- constructor(_signer, _identityKey, _deviceKey) {
321
- this._signer = _signer;
322
- this._identityKey = _identityKey;
323
- this._deviceKey = _deviceKey;
319
+ function _define_property(obj, key, value) {
320
+ if (key in obj) {
321
+ Object.defineProperty(obj, key, {
322
+ value,
323
+ enumerable: true,
324
+ configurable: true,
325
+ writable: true
326
+ });
327
+ } else {
328
+ obj[key] = value;
324
329
  }
330
+ return obj;
331
+ }
332
+ var CredentialGenerator = class {
325
333
  /**
326
334
  * Create genesis messages for new Space.
327
335
  */
@@ -443,6 +451,14 @@ var CredentialGenerator = class {
443
451
  }
444
452
  });
445
453
  }
454
+ constructor(_signer, _identityKey, _deviceKey) {
455
+ _define_property(this, "_signer", void 0);
456
+ _define_property(this, "_identityKey", void 0);
457
+ _define_property(this, "_deviceKey", void 0);
458
+ this._signer = _signer;
459
+ this._identityKey = _identityKey;
460
+ this._deviceKey = _deviceKey;
461
+ }
446
462
  };
447
463
  var createDeviceAuthorization = async (signer, identityKey, deviceKey) => {
448
464
  const credentials = await Promise.all([
@@ -516,7 +532,7 @@ var createCancelDelegatedSpaceInvitationCredential = async (signer, subject, inv
516
532
  };
517
533
  };
518
534
 
519
- // packages/core/halo/credentials/src/presentations/presentation.ts
535
+ // src/presentations/presentation.ts
520
536
  var signPresentation = async ({ presentation, signer, signerKey, chain, nonce }) => {
521
537
  const proof = {
522
538
  type: SIGNATURE_TYPE_ED25519,
@@ -539,7 +555,7 @@ var signPresentation = async ({ presentation, signer, signerKey, chain, nonce })
539
555
  };
540
556
  };
541
557
 
542
- // packages/core/halo/credentials/src/presentations/verifier.ts
558
+ // src/presentations/verifier.ts
543
559
  import { verifySignature as verifySignature2 } from "@dxos/crypto";
544
560
  var verifyPresentation = async (presentation) => {
545
561
  const errors = [];
@@ -623,7 +639,7 @@ var verifyPresentationSignature = async (presentation, proof) => {
623
639
  };
624
640
  };
625
641
 
626
- // packages/core/halo/credentials/src/state-machine/space-state-machine.ts
642
+ // src/state-machine/space-state-machine.ts
627
643
  import { runInContextAsync, synchronized } from "@dxos/async";
628
644
  import { Context } from "@dxos/context";
629
645
  import { PublicKey as PublicKey8 } from "@dxos/keys";
@@ -631,17 +647,25 @@ import { log as log3 } from "@dxos/log";
631
647
  import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
632
648
  import { Callback as Callback4, ComplexMap as ComplexMap6, ComplexSet as ComplexSet3 } from "@dxos/util";
633
649
 
634
- // packages/core/halo/credentials/src/state-machine/feed-state-machine.ts
650
+ // src/state-machine/feed-state-machine.ts
635
651
  import { invariant as invariant3 } from "@dxos/invariant";
636
652
  import { PublicKey as PublicKey4 } from "@dxos/keys";
637
653
  import { Callback, ComplexMap as ComplexMap2 } from "@dxos/util";
638
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/state-machine/feed-state-machine.ts";
639
- var FeedStateMachine = class {
640
- constructor(_spaceKey) {
641
- this._spaceKey = _spaceKey;
642
- this._feeds = new ComplexMap2(PublicKey4.hash);
643
- this.onFeedAdmitted = new Callback();
654
+ function _define_property2(obj, key, value) {
655
+ if (key in obj) {
656
+ Object.defineProperty(obj, key, {
657
+ value,
658
+ enumerable: true,
659
+ configurable: true,
660
+ writable: true
661
+ });
662
+ } else {
663
+ obj[key] = value;
644
664
  }
665
+ return obj;
666
+ }
667
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/core/halo/credentials/src/state-machine/feed-state-machine.ts";
668
+ var FeedStateMachine = class {
645
669
  get feeds() {
646
670
  return this._feeds;
647
671
  }
@@ -680,19 +704,33 @@ var FeedStateMachine = class {
680
704
  this._feeds.set(credential.subject.id, info);
681
705
  await this.onFeedAdmitted.callIfSet(info);
682
706
  }
707
+ constructor(_spaceKey) {
708
+ _define_property2(this, "_spaceKey", void 0);
709
+ _define_property2(this, "_feeds", void 0);
710
+ _define_property2(this, "onFeedAdmitted", void 0);
711
+ this._spaceKey = _spaceKey;
712
+ this._feeds = new ComplexMap2(PublicKey4.hash);
713
+ this.onFeedAdmitted = new Callback();
714
+ }
683
715
  };
684
716
 
685
- // packages/core/halo/credentials/src/state-machine/invitation-state-machine.ts
717
+ // src/state-machine/invitation-state-machine.ts
686
718
  import { PublicKey as PublicKey5 } from "@dxos/keys";
687
719
  import { Callback as Callback2, ComplexMap as ComplexMap3, ComplexSet } from "@dxos/util";
688
- var InvitationStateMachine = class {
689
- constructor() {
690
- this._invitations = new ComplexMap3(PublicKey5.hash);
691
- this._redeemedInvitationCredentialIds = new ComplexSet(PublicKey5.hash);
692
- this._cancelledInvitationCredentialIds = new ComplexSet(PublicKey5.hash);
693
- this.onDelegatedInvitation = new Callback2();
694
- this.onDelegatedInvitationRemoved = new Callback2();
720
+ function _define_property3(obj, key, value) {
721
+ if (key in obj) {
722
+ Object.defineProperty(obj, key, {
723
+ value,
724
+ enumerable: true,
725
+ configurable: true,
726
+ writable: true
727
+ });
728
+ } else {
729
+ obj[key] = value;
695
730
  }
731
+ return obj;
732
+ }
733
+ var InvitationStateMachine = class {
696
734
  get invitations() {
697
735
  return this._invitations;
698
736
  }
@@ -750,40 +788,42 @@ var InvitationStateMachine = class {
750
788
  }
751
789
  }
752
790
  }
791
+ constructor() {
792
+ _define_property3(this, "_invitations", new ComplexMap3(PublicKey5.hash));
793
+ _define_property3(this, "_redeemedInvitationCredentialIds", new ComplexSet(PublicKey5.hash));
794
+ _define_property3(this, "_cancelledInvitationCredentialIds", new ComplexSet(PublicKey5.hash));
795
+ _define_property3(this, "onDelegatedInvitation", new Callback2());
796
+ _define_property3(this, "onDelegatedInvitationRemoved", new Callback2());
797
+ }
753
798
  };
754
799
 
755
- // packages/core/halo/credentials/src/state-machine/member-state-machine.ts
800
+ // src/state-machine/member-state-machine.ts
756
801
  import { invariant as invariant5 } from "@dxos/invariant";
757
802
  import { PublicKey as PublicKey7 } from "@dxos/keys";
758
803
  import { log as log2 } from "@dxos/log";
759
804
  import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
760
805
  import { ComplexMap as ComplexMap5 } from "@dxos/util";
761
806
 
762
- // packages/core/halo/credentials/src/graph/credential-graph.ts
807
+ // src/graph/credential-graph.ts
763
808
  import { invariant as invariant4 } from "@dxos/invariant";
764
809
  import { PublicKey as PublicKey6 } from "@dxos/keys";
765
810
  import { log } from "@dxos/log";
766
811
  import { Callback as Callback3, ComplexMap as ComplexMap4, ComplexSet as ComplexSet2 } from "@dxos/util";
767
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/graph/credential-graph.ts";
768
- var CredentialGraph = class {
769
- constructor(_stateHandler) {
770
- this._stateHandler = _stateHandler;
771
- this._vertexIdGenerator = 1;
772
- this._root = {
773
- id: -1,
774
- parents: [],
775
- children: []
776
- };
777
- this._sentinel = {
778
- id: -2,
779
- parents: [],
780
- children: []
781
- };
782
- this._vertexByCredentialId = new ComplexMap4(PublicKey6.hash);
783
- this._subjectToVertex = new ComplexMap4(PublicKey6.hash);
784
- this._subjectToState = new ComplexMap4(PublicKey6.hash);
785
- this.onSubjectStateChanged = new Callback3();
812
+ function _define_property4(obj, key, value) {
813
+ if (key in obj) {
814
+ Object.defineProperty(obj, key, {
815
+ value,
816
+ enumerable: true,
817
+ configurable: true,
818
+ writable: true
819
+ });
820
+ } else {
821
+ obj[key] = value;
786
822
  }
823
+ return obj;
824
+ }
825
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/core/halo/credentials/src/graph/credential-graph.ts";
826
+ var CredentialGraph = class {
787
827
  getSubjectState(subjectId) {
788
828
  return this._subjectToState.get(subjectId);
789
829
  }
@@ -1306,6 +1346,32 @@ var CredentialGraph = class {
1306
1346
  credentials: new ComplexSet2(PublicKey6.hash)
1307
1347
  };
1308
1348
  }
1349
+ constructor(_stateHandler) {
1350
+ _define_property4(this, "_stateHandler", void 0);
1351
+ _define_property4(this, "_vertexIdGenerator", void 0);
1352
+ _define_property4(this, "_root", void 0);
1353
+ _define_property4(this, "_sentinel", void 0);
1354
+ _define_property4(this, "_vertexByCredentialId", void 0);
1355
+ _define_property4(this, "_subjectToVertex", void 0);
1356
+ _define_property4(this, "_subjectToState", void 0);
1357
+ _define_property4(this, "onSubjectStateChanged", void 0);
1358
+ this._stateHandler = _stateHandler;
1359
+ this._vertexIdGenerator = 1;
1360
+ this._root = {
1361
+ id: -1,
1362
+ parents: [],
1363
+ children: []
1364
+ };
1365
+ this._sentinel = {
1366
+ id: -2,
1367
+ parents: [],
1368
+ children: []
1369
+ };
1370
+ this._vertexByCredentialId = new ComplexMap4(PublicKey6.hash);
1371
+ this._subjectToVertex = new ComplexMap4(PublicKey6.hash);
1372
+ this._subjectToState = new ComplexMap4(PublicKey6.hash);
1373
+ this.onSubjectStateChanged = new Callback3();
1374
+ }
1309
1375
  };
1310
1376
  var toChosenPath = (path) => {
1311
1377
  return Object.fromEntries(Object.entries(path.chosenPath).map(([k, vs]) => [
@@ -1314,15 +1380,22 @@ var toChosenPath = (path) => {
1314
1380
  ]));
1315
1381
  };
1316
1382
 
1317
- // packages/core/halo/credentials/src/state-machine/member-state-machine.ts
1318
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/state-machine/member-state-machine.ts";
1319
- var MemberStateMachine = class {
1320
- constructor(_spaceKey) {
1321
- this._spaceKey = _spaceKey;
1322
- this._memberProfiles = new ComplexMap5(PublicKey7.hash);
1323
- this._hashgraph = new CredentialGraph(this);
1324
- this.onMemberRoleChanged = this._hashgraph.onSubjectStateChanged;
1383
+ // src/state-machine/member-state-machine.ts
1384
+ function _define_property5(obj, key, value) {
1385
+ if (key in obj) {
1386
+ Object.defineProperty(obj, key, {
1387
+ value,
1388
+ enumerable: true,
1389
+ configurable: true,
1390
+ writable: true
1391
+ });
1392
+ } else {
1393
+ obj[key] = value;
1325
1394
  }
1395
+ return obj;
1396
+ }
1397
+ var __dxlog_file5 = "/__w/dxos/dxos/packages/core/halo/credentials/src/state-machine/member-state-machine.ts";
1398
+ var MemberStateMachine = class {
1326
1399
  get creator() {
1327
1400
  return this._ownerKey && this._hashgraph.getSubjectState(this._ownerKey);
1328
1401
  }
@@ -1458,32 +1531,41 @@ var MemberStateMachine = class {
1458
1531
  }
1459
1532
  return realRole;
1460
1533
  }
1534
+ constructor(_spaceKey) {
1535
+ _define_property5(this, "_spaceKey", void 0);
1536
+ _define_property5(this, "_ownerKey", void 0);
1537
+ _define_property5(this, "_memberProfiles", void 0);
1538
+ _define_property5(this, "_hashgraph", void 0);
1539
+ _define_property5(this, "onMemberRoleChanged", void 0);
1540
+ this._spaceKey = _spaceKey;
1541
+ this._memberProfiles = new ComplexMap5(PublicKey7.hash);
1542
+ this._hashgraph = new CredentialGraph(this);
1543
+ this.onMemberRoleChanged = this._hashgraph.onSubjectStateChanged;
1544
+ }
1461
1545
  };
1462
1546
 
1463
- // packages/core/halo/credentials/src/state-machine/space-state-machine.ts
1547
+ // src/state-machine/space-state-machine.ts
1548
+ function _define_property6(obj, key, value) {
1549
+ if (key in obj) {
1550
+ Object.defineProperty(obj, key, {
1551
+ value,
1552
+ enumerable: true,
1553
+ configurable: true,
1554
+ writable: true
1555
+ });
1556
+ } else {
1557
+ obj[key] = value;
1558
+ }
1559
+ return obj;
1560
+ }
1464
1561
  function _ts_decorate(decorators, target, key, desc) {
1465
1562
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1466
1563
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1467
1564
  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
1565
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1469
1566
  }
1470
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/state-machine/space-state-machine.ts";
1567
+ var __dxlog_file6 = "/__w/dxos/dxos/packages/core/halo/credentials/src/state-machine/space-state-machine.ts";
1471
1568
  var SpaceStateMachine = class {
1472
- constructor(_spaceKey) {
1473
- this._spaceKey = _spaceKey;
1474
- this._members = new MemberStateMachine(this._spaceKey);
1475
- this._feeds = new FeedStateMachine(this._spaceKey);
1476
- this._invitations = new InvitationStateMachine();
1477
- this._credentials = [];
1478
- this._credentialsById = new ComplexMap6(PublicKey8.hash);
1479
- this._processedCredentials = new ComplexSet3(PublicKey8.hash);
1480
- this._credentialProcessors = [];
1481
- this.onCredentialProcessed = new Callback4();
1482
- this.onMemberRoleChanged = this._members.onMemberRoleChanged;
1483
- this.onFeedAdmitted = this._feeds.onFeedAdmitted;
1484
- this.onDelegatedInvitation = this._invitations.onDelegatedInvitation;
1485
- this.onDelegatedInvitationRemoved = this._invitations.onDelegatedInvitationRemoved;
1486
- }
1487
1569
  get creator() {
1488
1570
  return this._members.creator;
1489
1571
  }
@@ -1546,7 +1628,7 @@ var SpaceStateMachine = class {
1546
1628
  if (result.kind !== "pass") {
1547
1629
  log3.warn(`Invalid credential: ${result.errors.join(", ")}`, void 0, {
1548
1630
  F: __dxlog_file6,
1549
- L: 156,
1631
+ L: 162,
1550
1632
  S: this,
1551
1633
  C: (f, a) => f(...a)
1552
1634
  });
@@ -1559,7 +1641,7 @@ var SpaceStateMachine = class {
1559
1641
  if (this._genesisCredential) {
1560
1642
  log3.warn("Space already has a genesis credential.", void 0, {
1561
1643
  F: __dxlog_file6,
1562
- L: 165,
1644
+ L: 171,
1563
1645
  S: this,
1564
1646
  C: (f, a) => f(...a)
1565
1647
  });
@@ -1568,7 +1650,7 @@ var SpaceStateMachine = class {
1568
1650
  if (!credential.issuer.equals(this._spaceKey)) {
1569
1651
  log3.warn("Space genesis credential must be issued by space.", void 0, {
1570
1652
  F: __dxlog_file6,
1571
- L: 169,
1653
+ L: 175,
1572
1654
  S: this,
1573
1655
  C: (f, a) => f(...a)
1574
1656
  });
@@ -1577,7 +1659,7 @@ var SpaceStateMachine = class {
1577
1659
  if (!credential.subject.id.equals(this._spaceKey)) {
1578
1660
  log3.warn("Space genesis credential must be issued to space.", void 0, {
1579
1661
  F: __dxlog_file6,
1580
- L: 173,
1662
+ L: 179,
1581
1663
  S: this,
1582
1664
  C: (f, a) => f(...a)
1583
1665
  });
@@ -1593,7 +1675,7 @@ var SpaceStateMachine = class {
1593
1675
  if (!this._genesisCredential) {
1594
1676
  log3.warn("Space must have a genesis credential before adding members.", void 0, {
1595
1677
  F: __dxlog_file6,
1596
- L: 186,
1678
+ L: 192,
1597
1679
  S: this,
1598
1680
  C: (f, a) => f(...a)
1599
1681
  });
@@ -1602,7 +1684,7 @@ var SpaceStateMachine = class {
1602
1684
  if (!this._canInviteNewMembers(credential.issuer)) {
1603
1685
  log3.warn(`Space member is not authorized to invite new members: ${credential.issuer}`, void 0, {
1604
1686
  F: __dxlog_file6,
1605
- L: 190,
1687
+ L: 196,
1606
1688
  S: this,
1607
1689
  C: (f, a) => f(...a)
1608
1690
  });
@@ -1616,7 +1698,7 @@ var SpaceStateMachine = class {
1616
1698
  if (!this._genesisCredential) {
1617
1699
  log3.warn("Space must have a genesis credential before adding members.", void 0, {
1618
1700
  F: __dxlog_file6,
1619
- L: 201,
1701
+ L: 207,
1620
1702
  S: this,
1621
1703
  C: (f, a) => f(...a)
1622
1704
  });
@@ -1629,7 +1711,7 @@ var SpaceStateMachine = class {
1629
1711
  if (!this._genesisCredential) {
1630
1712
  log3.warn("Space must have a genesis credential before admitting feeds.", void 0, {
1631
1713
  F: __dxlog_file6,
1632
- L: 211,
1714
+ L: 217,
1633
1715
  S: this,
1634
1716
  C: (f, a) => f(...a)
1635
1717
  });
@@ -1643,7 +1725,7 @@ var SpaceStateMachine = class {
1643
1725
  if (!this._canInviteNewMembers(credential.issuer)) {
1644
1726
  log3.warn(`Invalid invitation, space member is not authorized to invite new members: ${credential.issuer}`, void 0, {
1645
1727
  F: __dxlog_file6,
1646
- L: 222,
1728
+ L: 228,
1647
1729
  S: this,
1648
1730
  C: (f, a) => f(...a)
1649
1731
  });
@@ -1679,21 +1761,40 @@ var SpaceStateMachine = class {
1679
1761
  _canInviteNewMembers(key) {
1680
1762
  return key.equals(this._spaceKey) || this._members.getRole(key) === SpaceMember3.Role.ADMIN || this._members.getRole(key) === SpaceMember3.Role.OWNER;
1681
1763
  }
1764
+ constructor(_spaceKey) {
1765
+ _define_property6(this, "_spaceKey", void 0);
1766
+ _define_property6(this, "_members", void 0);
1767
+ _define_property6(this, "_feeds", void 0);
1768
+ _define_property6(this, "_invitations", void 0);
1769
+ _define_property6(this, "_credentials", void 0);
1770
+ _define_property6(this, "_credentialsById", void 0);
1771
+ _define_property6(this, "_processedCredentials", void 0);
1772
+ _define_property6(this, "_genesisCredential", void 0);
1773
+ _define_property6(this, "_credentialProcessors", void 0);
1774
+ _define_property6(this, "onCredentialProcessed", void 0);
1775
+ _define_property6(this, "onMemberRoleChanged", void 0);
1776
+ _define_property6(this, "onFeedAdmitted", void 0);
1777
+ _define_property6(this, "onDelegatedInvitation", void 0);
1778
+ _define_property6(this, "onDelegatedInvitationRemoved", void 0);
1779
+ this._spaceKey = _spaceKey;
1780
+ this._invitations = new InvitationStateMachine();
1781
+ this._credentials = [];
1782
+ this._credentialsById = new ComplexMap6(PublicKey8.hash);
1783
+ this._processedCredentials = new ComplexSet3(PublicKey8.hash);
1784
+ this._credentialProcessors = [];
1785
+ this.onCredentialProcessed = new Callback4();
1786
+ this.onDelegatedInvitation = this._invitations.onDelegatedInvitation;
1787
+ this.onDelegatedInvitationRemoved = this._invitations.onDelegatedInvitationRemoved;
1788
+ this._members = new MemberStateMachine(this._spaceKey);
1789
+ this._feeds = new FeedStateMachine(this._spaceKey);
1790
+ this.onMemberRoleChanged = this._members.onMemberRoleChanged;
1791
+ this.onFeedAdmitted = this._feeds.onFeedAdmitted;
1792
+ }
1682
1793
  };
1683
1794
  _ts_decorate([
1684
1795
  synchronized
1685
1796
  ], SpaceStateMachine.prototype, "process", null);
1686
1797
  var CredentialConsumer = class {
1687
- constructor(processor, _onOpen, _onClose) {
1688
- this.processor = processor;
1689
- this._onOpen = _onOpen;
1690
- this._onClose = _onClose;
1691
- this._ctx = new Context(void 0, {
1692
- F: __dxlog_file6,
1693
- L: 267
1694
- });
1695
- this._isReadyForLiveCredentials = false;
1696
- }
1697
1798
  /**
1698
1799
  * @internal
1699
1800
  */
@@ -1712,21 +1813,44 @@ var CredentialConsumer = class {
1712
1813
  await this._ctx.dispose();
1713
1814
  await this._onClose();
1714
1815
  }
1816
+ constructor(processor, _onOpen, _onClose) {
1817
+ _define_property6(this, "processor", void 0);
1818
+ _define_property6(this, "_onOpen", void 0);
1819
+ _define_property6(this, "_onClose", void 0);
1820
+ _define_property6(this, "_ctx", void 0);
1821
+ _define_property6(this, "_isReadyForLiveCredentials", void 0);
1822
+ this.processor = processor;
1823
+ this._onOpen = _onOpen;
1824
+ this._onClose = _onClose;
1825
+ this._ctx = new Context(void 0, {
1826
+ F: __dxlog_file6,
1827
+ L: 273
1828
+ });
1829
+ this._isReadyForLiveCredentials = false;
1830
+ }
1715
1831
  };
1716
1832
 
1717
- // packages/core/halo/credentials/src/processor/device-state-machine.ts
1833
+ // src/processor/device-state-machine.ts
1718
1834
  import { Trigger } from "@dxos/async";
1719
1835
  import { invariant as invariant6 } from "@dxos/invariant";
1720
1836
  import { PublicKey as PublicKey9 } from "@dxos/keys";
1721
1837
  import { log as log4 } from "@dxos/log";
1722
1838
  import { ComplexMap as ComplexMap7 } from "@dxos/util";
1723
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/processor/device-state-machine.ts";
1724
- var DeviceStateMachine = class {
1725
- constructor(_params) {
1726
- this._params = _params;
1727
- this.authorizedDeviceKeys = new ComplexMap7(PublicKey9.hash);
1728
- this.deviceChainReady = new Trigger();
1839
+ function _define_property7(obj, key, value) {
1840
+ if (key in obj) {
1841
+ Object.defineProperty(obj, key, {
1842
+ value,
1843
+ enumerable: true,
1844
+ configurable: true,
1845
+ writable: true
1846
+ });
1847
+ } else {
1848
+ obj[key] = value;
1729
1849
  }
1850
+ return obj;
1851
+ }
1852
+ var __dxlog_file7 = "/__w/dxos/dxos/packages/core/halo/credentials/src/processor/device-state-machine.ts";
1853
+ var DeviceStateMachine = class {
1730
1854
  async processCredential(credential) {
1731
1855
  log4("processing credential...", {
1732
1856
  identityKey: this._params.identityKey,
@@ -1734,7 +1858,7 @@ var DeviceStateMachine = class {
1734
1858
  credential
1735
1859
  }, {
1736
1860
  F: __dxlog_file7,
1737
- L: 35,
1861
+ L: 36,
1738
1862
  S: this,
1739
1863
  C: (f, a) => f(...a)
1740
1864
  });
@@ -1754,7 +1878,7 @@ var DeviceStateMachine = class {
1754
1878
  size: this.authorizedDeviceKeys.size
1755
1879
  }, {
1756
1880
  F: __dxlog_file7,
1757
- L: 55,
1881
+ L: 56,
1758
1882
  S: this,
1759
1883
  C: (f, a) => f(...a)
1760
1884
  });
@@ -1764,7 +1888,7 @@ var DeviceStateMachine = class {
1764
1888
  case "dxos.halo.credentials.DeviceProfile": {
1765
1889
  invariant6(this.authorizedDeviceKeys.has(credential.subject.id), "Device not found.", {
1766
1890
  F: __dxlog_file7,
1767
- L: 65,
1891
+ L: 66,
1768
1892
  S: this,
1769
1893
  A: [
1770
1894
  "this.authorizedDeviceKeys.has(credential.subject.id)",
@@ -1777,7 +1901,7 @@ var DeviceStateMachine = class {
1777
1901
  profile: assertion.profile
1778
1902
  }, {
1779
1903
  F: __dxlog_file7,
1780
- L: 68,
1904
+ L: 69,
1781
1905
  S: this,
1782
1906
  C: (f, a) => f(...a)
1783
1907
  });
@@ -1788,15 +1912,34 @@ var DeviceStateMachine = class {
1788
1912
  }
1789
1913
  }
1790
1914
  }
1915
+ constructor(_params) {
1916
+ _define_property7(this, "_params", void 0);
1917
+ _define_property7(this, "authorizedDeviceKeys", void 0);
1918
+ _define_property7(this, "deviceChainReady", void 0);
1919
+ _define_property7(this, "deviceCredentialChain", void 0);
1920
+ this._params = _params;
1921
+ this.authorizedDeviceKeys = new ComplexMap7(PublicKey9.hash);
1922
+ this.deviceChainReady = new Trigger();
1923
+ }
1791
1924
  };
1792
1925
 
1793
- // packages/core/halo/credentials/src/processor/profile-state-machine.ts
1926
+ // src/processor/profile-state-machine.ts
1794
1927
  import { log as log5 } from "@dxos/log";
1795
- var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/halo/credentials/src/processor/profile-state-machine.ts";
1796
- var ProfileStateMachine = class {
1797
- constructor(_params) {
1798
- this._params = _params;
1928
+ function _define_property8(obj, key, value) {
1929
+ if (key in obj) {
1930
+ Object.defineProperty(obj, key, {
1931
+ value,
1932
+ enumerable: true,
1933
+ configurable: true,
1934
+ writable: true
1935
+ });
1936
+ } else {
1937
+ obj[key] = value;
1799
1938
  }
1939
+ return obj;
1940
+ }
1941
+ var __dxlog_file8 = "/__w/dxos/dxos/packages/core/halo/credentials/src/processor/profile-state-machine.ts";
1942
+ var ProfileStateMachine = class {
1800
1943
  async processCredential(credential) {
1801
1944
  const assertion = getCredentialAssertion(credential);
1802
1945
  switch (assertion["@type"]) {
@@ -1807,7 +1950,7 @@ var ProfileStateMachine = class {
1807
1950
  credential
1808
1951
  }, {
1809
1952
  F: __dxlog_file8,
1810
- L: 34,
1953
+ L: 35,
1811
1954
  S: this,
1812
1955
  C: (f, a) => f(...a)
1813
1956
  });
@@ -1819,7 +1962,7 @@ var ProfileStateMachine = class {
1819
1962
  profile: this.profile
1820
1963
  }, {
1821
1964
  F: __dxlog_file8,
1822
- L: 40,
1965
+ L: 41,
1823
1966
  S: this,
1824
1967
  C: (f, a) => f(...a)
1825
1968
  });
@@ -1828,6 +1971,11 @@ var ProfileStateMachine = class {
1828
1971
  }
1829
1972
  }
1830
1973
  }
1974
+ constructor(_params) {
1975
+ _define_property8(this, "_params", void 0);
1976
+ _define_property8(this, "profile", void 0);
1977
+ this._params = _params;
1978
+ }
1831
1979
  };
1832
1980
  export {
1833
1981
  CredentialGenerator,