@dxos/credentials 0.8.4-main.dedc0f3 → 0.8.4-main.dfabb4ec29

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 (50) hide show
  1. package/dist/lib/{browser → neutral}/index.mjs +187 -529
  2. package/dist/lib/neutral/index.mjs.map +7 -0
  3. package/dist/lib/neutral/meta.json +1 -0
  4. package/dist/types/src/credentials/assertions.d.ts.map +1 -1
  5. package/dist/types/src/credentials/credential-factory.d.ts +4 -4
  6. package/dist/types/src/credentials/credential-factory.d.ts.map +1 -1
  7. package/dist/types/src/credentials/credential-generator.d.ts +3 -3
  8. package/dist/types/src/credentials/credential-generator.d.ts.map +1 -1
  9. package/dist/types/src/credentials/signing.d.ts.map +1 -1
  10. package/dist/types/src/credentials/verifier.d.ts.map +1 -1
  11. package/dist/types/src/did.d.ts.map +1 -1
  12. package/dist/types/src/graph/credential-graph.d.ts.map +1 -1
  13. package/dist/types/src/passcode.d.ts.map +1 -1
  14. package/dist/types/src/presentations/presentation.d.ts.map +1 -1
  15. package/dist/types/src/presentations/signing.d.ts.map +1 -1
  16. package/dist/types/src/presentations/verifier.d.ts.map +1 -1
  17. package/dist/types/src/processor/device-state-machine.d.ts +2 -2
  18. package/dist/types/src/processor/device-state-machine.d.ts.map +1 -1
  19. package/dist/types/src/processor/profile-state-machine.d.ts +2 -2
  20. package/dist/types/src/processor/profile-state-machine.d.ts.map +1 -1
  21. package/dist/types/src/seedphrase.d.ts.map +1 -1
  22. package/dist/types/src/state-machine/feed-state-machine.d.ts.map +1 -1
  23. package/dist/types/src/state-machine/invitation-state-machine.d.ts.map +1 -1
  24. package/dist/types/src/state-machine/member-state-machine.d.ts.map +1 -1
  25. package/dist/types/src/state-machine/space-state-machine.d.ts +7 -1
  26. package/dist/types/src/state-machine/space-state-machine.d.ts.map +1 -1
  27. package/dist/types/tsconfig.tsbuildinfo +1 -1
  28. package/docs/README.md +17 -17
  29. package/moon.yml +2 -1
  30. package/package.json +19 -23
  31. package/src/credentials/credential-factory.ts +4 -4
  32. package/src/credentials/credential-generator.ts +5 -0
  33. package/src/credentials/signing.ts +12 -0
  34. package/src/presentations/json-encoding.test.ts +0 -2
  35. package/src/presentations/presentation.ts +0 -1
  36. package/src/presentations/verifier.test.ts +0 -1
  37. package/src/presentations/verifier.ts +0 -1
  38. package/src/processor/device-state-machine.ts +2 -3
  39. package/src/processor/profile-state-machine.ts +2 -3
  40. package/src/state-machine/invitation-state-machine.test.ts +0 -1
  41. package/src/state-machine/member-state-machine.test.ts +0 -1
  42. package/src/state-machine/space-state-machine.test.ts +243 -2
  43. package/src/state-machine/space-state-machine.ts +20 -2
  44. package/vitest.config.ts +7 -6
  45. package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
  46. package/dist/lib/browser/index.mjs.map +0 -7
  47. package/dist/lib/browser/meta.json +0 -1
  48. package/dist/lib/node-esm/index.mjs +0 -2018
  49. package/dist/lib/node-esm/index.mjs.map +0 -7
  50. package/dist/lib/node-esm/meta.json +0 -1
@@ -28,15 +28,7 @@ import { invariant } from "@dxos/invariant";
28
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
- invariant(seedPhrase, void 0, {
32
- F: __dxlog_file,
33
- L: 20,
34
- S: void 0,
35
- A: [
36
- "seedPhrase",
37
- ""
38
- ]
39
- });
31
+ invariant(seedPhrase, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 13, S: void 0, A: ["seedPhrase", ""] });
40
32
  const seed = mnemonicToSeedSync(seedPhrase);
41
33
  return createKeyPair(seed);
42
34
  };
@@ -68,6 +60,14 @@ var getCredentialProofPayload = (credential) => {
68
60
  delete copy.parentCredentialIds;
69
61
  }
70
62
  delete copy.id;
63
+ const assertion = copy.subject?.assertion;
64
+ if (assertion) {
65
+ for (const key of Object.keys(assertion)) {
66
+ if (Array.isArray(assertion[key]) && assertion[key].length === 0) {
67
+ delete assertion[key];
68
+ }
69
+ }
70
+ }
71
71
  return Buffer.from(canonicalStringify(copy));
72
72
  };
73
73
  var canonicalStringify = (obj) => stableStringify(obj, {
@@ -228,35 +228,11 @@ var verifyChain = async (chain, authority, subject) => {
228
228
  // src/credentials/credential-factory.ts
229
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
- invariant2(assertion["@type"], "Invalid assertion.", {
232
- F: __dxlog_file2,
233
- L: 48,
234
- S: void 0,
235
- A: [
236
- "assertion['@type']",
237
- "'Invalid assertion.'"
238
- ]
239
- });
240
- invariant2(!!signingKey === !!chain, "Chain must be provided if and only if the signing key differs from the issuer.", {
241
- F: __dxlog_file2,
242
- L: 49,
243
- S: void 0,
244
- A: [
245
- "!!signingKey === !!chain",
246
- "'Chain must be provided if and only if the signing key differs from the issuer.'"
247
- ]
248
- });
231
+ invariant2(assertion["@type"], "Invalid assertion.", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 12, S: void 0, A: ["assertion['@type']", "'Invalid assertion.'"] });
232
+ invariant2(!!signingKey === !!chain, "Chain must be provided if and only if the signing key differs from the issuer.", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 13, S: void 0, A: ["!!signingKey === !!chain", "'Chain must be provided if and only if the signing key differs from the issuer.'"] });
249
233
  if (chain) {
250
234
  const result = await verifyChain(chain, issuer, signingKey);
251
- invariant2(result.kind === "pass", "Invalid chain.", {
252
- F: __dxlog_file2,
253
- L: 52,
254
- S: void 0,
255
- A: [
256
- "result.kind === 'pass'",
257
- "'Invalid chain.'"
258
- ]
259
- });
235
+ invariant2(result.kind === "pass", "Invalid chain.", { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 16, S: void 0, A: ["result.kind === 'pass'", "'Invalid chain.'"] });
260
236
  }
261
237
  const credential = {
262
238
  issuer,
@@ -314,26 +290,21 @@ var createCredentialSignerWithChain = (signer, chain, signingKey) => ({
314
290
  });
315
291
 
316
292
  // src/credentials/credential-generator.ts
317
- import { AdmittedFeed, SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
293
+ import { AdmittedFeed, MembershipPolicy, SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
318
294
  import { Timeframe as Timeframe2 } from "@dxos/timeframe";
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;
329
- }
330
- return obj;
331
- }
332
295
  var CredentialGenerator = class {
296
+ _signer;
297
+ _identityKey;
298
+ _deviceKey;
299
+ constructor(_signer, _identityKey, _deviceKey) {
300
+ this._signer = _signer;
301
+ this._identityKey = _identityKey;
302
+ this._deviceKey = _deviceKey;
303
+ }
333
304
  /**
334
305
  * Create genesis messages for new Space.
335
306
  */
336
- async createSpaceGenesis(spaceKey, controlKey, creatorProfile) {
307
+ async createSpaceGenesis(spaceKey, controlKey, creatorProfile, membershipPolicy = MembershipPolicy.INVITE) {
337
308
  return [
338
309
  await createCredential({
339
310
  signer: this._signer,
@@ -341,7 +312,8 @@ var CredentialGenerator = class {
341
312
  subject: spaceKey,
342
313
  assertion: {
343
314
  "@type": "dxos.halo.credentials.SpaceGenesis",
344
- spaceKey
315
+ spaceKey,
316
+ membershipPolicy
345
317
  }
346
318
  }),
347
319
  await createCredential({
@@ -451,14 +423,6 @@ var CredentialGenerator = class {
451
423
  }
452
424
  });
453
425
  }
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
- }
462
426
  };
463
427
  var createDeviceAuthorization = async (signer, identityKey, deviceKey) => {
464
428
  const credentials = await Promise.all([
@@ -476,7 +440,7 @@ var createDeviceAuthorization = async (signer, identityKey, deviceKey) => {
476
440
  credential
477
441
  }));
478
442
  };
479
- var createAdmissionCredentials = async (signer, identityKey, spaceKey, genesisFeedKey, role = SpaceMember.Role.ADMIN, membershipChainHeads = [], profile, invitationCredentialId) => {
443
+ var createAdmissionCredentials = async (signer, identityKey, spaceKey, genesisFeedKey, role = SpaceMember.Role.ADMIN, membershipChainHeads = [], profile, invitationCredentialId, tags) => {
480
444
  const credentials = await Promise.all([
481
445
  await signer.createCredential({
482
446
  subject: identityKey,
@@ -487,7 +451,8 @@ var createAdmissionCredentials = async (signer, identityKey, spaceKey, genesisFe
487
451
  role,
488
452
  profile,
489
453
  genesisFeedKey,
490
- invitationCredentialId
454
+ invitationCredentialId,
455
+ tags: tags ?? []
491
456
  }
492
457
  })
493
458
  ]);
@@ -644,28 +609,21 @@ import { runInContextAsync, synchronized } from "@dxos/async";
644
609
  import { Context } from "@dxos/context";
645
610
  import { PublicKey as PublicKey8 } from "@dxos/keys";
646
611
  import { log as log3 } from "@dxos/log";
647
- import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
612
+ import { MembershipPolicy as MembershipPolicy2, SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
648
613
  import { Callback as Callback4, ComplexMap as ComplexMap6, ComplexSet as ComplexSet3 } from "@dxos/util";
649
614
 
650
615
  // src/state-machine/feed-state-machine.ts
651
616
  import { invariant as invariant3 } from "@dxos/invariant";
652
617
  import { PublicKey as PublicKey4 } from "@dxos/keys";
653
618
  import { Callback, ComplexMap as ComplexMap2 } from "@dxos/util";
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;
664
- }
665
- return obj;
666
- }
667
619
  var __dxlog_file3 = "/__w/dxos/dxos/packages/core/halo/credentials/src/state-machine/feed-state-machine.ts";
668
620
  var FeedStateMachine = class {
621
+ _spaceKey;
622
+ _feeds = new ComplexMap2(PublicKey4.hash);
623
+ onFeedAdmitted = new Callback();
624
+ constructor(_spaceKey) {
625
+ this._spaceKey = _spaceKey;
626
+ }
669
627
  get feeds() {
670
628
  return this._feeds;
671
629
  }
@@ -677,24 +635,8 @@ var FeedStateMachine = class {
677
635
  */
678
636
  async process(credential, fromFeed) {
679
637
  const assertion = getCredentialAssertion(credential);
680
- invariant3(assertion["@type"] === "dxos.halo.credentials.AdmittedFeed", void 0, {
681
- F: __dxlog_file3,
682
- L: 47,
683
- S: this,
684
- A: [
685
- "assertion['@type'] === 'dxos.halo.credentials.AdmittedFeed'",
686
- ""
687
- ]
688
- });
689
- invariant3(assertion.spaceKey.equals(this._spaceKey), void 0, {
690
- F: __dxlog_file3,
691
- L: 48,
692
- S: this,
693
- A: [
694
- "assertion.spaceKey.equals(this._spaceKey)",
695
- ""
696
- ]
697
- });
638
+ invariant3(assertion["@type"] === "dxos.halo.credentials.AdmittedFeed", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 28, S: this, A: ["assertion['@type'] === 'dxos.halo.credentials.AdmittedFeed'", ""] });
639
+ invariant3(assertion.spaceKey.equals(this._spaceKey), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 29, S: this, A: ["assertion.spaceKey.equals(this._spaceKey)", ""] });
698
640
  const info = {
699
641
  key: credential.subject.id,
700
642
  credential,
@@ -704,33 +646,17 @@ var FeedStateMachine = class {
704
646
  this._feeds.set(credential.subject.id, info);
705
647
  await this.onFeedAdmitted.callIfSet(info);
706
648
  }
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
- }
715
649
  };
716
650
 
717
651
  // src/state-machine/invitation-state-machine.ts
718
652
  import { PublicKey as PublicKey5 } from "@dxos/keys";
719
653
  import { Callback as Callback2, ComplexMap as ComplexMap3, ComplexSet } from "@dxos/util";
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;
730
- }
731
- return obj;
732
- }
733
654
  var InvitationStateMachine = class {
655
+ _invitations = new ComplexMap3(PublicKey5.hash);
656
+ _redeemedInvitationCredentialIds = new ComplexSet(PublicKey5.hash);
657
+ _cancelledInvitationCredentialIds = new ComplexSet(PublicKey5.hash);
658
+ onDelegatedInvitation = new Callback2();
659
+ onDelegatedInvitationRemoved = new Callback2();
734
660
  get invitations() {
735
661
  return this._invitations;
736
662
  }
@@ -788,13 +714,6 @@ var InvitationStateMachine = class {
788
714
  }
789
715
  }
790
716
  }
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
- }
798
717
  };
799
718
 
800
719
  // src/state-machine/member-state-machine.ts
@@ -809,21 +728,43 @@ import { invariant as invariant4 } from "@dxos/invariant";
809
728
  import { PublicKey as PublicKey6 } from "@dxos/keys";
810
729
  import { log } from "@dxos/log";
811
730
  import { Callback as Callback3, ComplexMap as ComplexMap4, ComplexSet as ComplexSet2 } from "@dxos/util";
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;
822
- }
823
- return obj;
824
- }
825
731
  var __dxlog_file4 = "/__w/dxos/dxos/packages/core/halo/credentials/src/graph/credential-graph.ts";
826
732
  var CredentialGraph = class {
733
+ _stateHandler;
734
+ /**
735
+ * Local ids are used during traversals.
736
+ */
737
+ _vertexIdGenerator = 1;
738
+ /**
739
+ * All credentials without parent references are connected to the root.
740
+ */
741
+ _root = {
742
+ id: -1,
743
+ parents: [],
744
+ children: []
745
+ };
746
+ /**
747
+ * A credential which is not a parent of any other credential has the sentinel as a child.
748
+ * Sentinel is a virtual merge-point of all credentials.
749
+ */
750
+ _sentinel = {
751
+ id: -2,
752
+ parents: [],
753
+ children: []
754
+ };
755
+ /**
756
+ * Vertex references are used for fast credential inserts into the graph.
757
+ */
758
+ _vertexByCredentialId = new ComplexMap4(PublicKey6.hash);
759
+ /**
760
+ * The current state of the graph.
761
+ */
762
+ _subjectToVertex = new ComplexMap4(PublicKey6.hash);
763
+ _subjectToState = new ComplexMap4(PublicKey6.hash);
764
+ onSubjectStateChanged = new Callback3();
765
+ constructor(_stateHandler) {
766
+ this._stateHandler = _stateHandler;
767
+ }
827
768
  getSubjectState(subjectId) {
828
769
  return this._subjectToState.get(subjectId);
829
770
  }
@@ -858,12 +799,7 @@ var CredentialGraph = class {
858
799
  log.error("credential skipped because of the unknown parent", {
859
800
  credential,
860
801
  parentId
861
- }, {
862
- F: __dxlog_file4,
863
- L: 72,
864
- S: this,
865
- C: (f, a) => f(...a)
866
- });
802
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 70, S: this });
867
803
  continue;
868
804
  }
869
805
  parentVertex.children.push(newVertex);
@@ -880,29 +816,13 @@ var CredentialGraph = class {
880
816
  if (sentinelIdx >= 0) {
881
817
  vertex.children.splice(sentinelIdx, 1);
882
818
  const vertexInSentinelIdx = this._sentinel.parents.indexOf(vertex);
883
- invariant4(vertexInSentinelIdx >= 0, void 0, {
884
- F: __dxlog_file4,
885
- L: 90,
886
- S: this,
887
- A: [
888
- "vertexInSentinelIdx >= 0",
889
- ""
890
- ]
891
- });
819
+ invariant4(vertexInSentinelIdx >= 0, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 90, S: this, A: ["vertexInSentinelIdx >= 0", ""] });
892
820
  this._sentinel.parents.splice(vertexInSentinelIdx, 1);
893
821
  }
894
822
  }
895
823
  async _onVertexInserted(newVertex) {
896
824
  const { credential, assertion } = newVertex;
897
- invariant4(credential, void 0, {
898
- F: __dxlog_file4,
899
- L: 97,
900
- S: this,
901
- A: [
902
- "credential",
903
- ""
904
- ]
905
- });
825
+ invariant4(credential, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 96, S: this, A: ["credential", ""] });
906
826
  let changedSubjects = [];
907
827
  const isUpdateAppliedOnTopOfThePreviousState = this._sentinel.parents.length === 1;
908
828
  if (isUpdateAppliedOnTopOfThePreviousState) {
@@ -939,21 +859,11 @@ var CredentialGraph = class {
939
859
  const path = paths.pop();
940
860
  log("visit vertex", {
941
861
  id: path.head.id
942
- }, {
943
- F: __dxlog_file4,
944
- L: 132,
945
- S: this,
946
- C: (f, a) => f(...a)
947
- });
862
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 131, S: this });
948
863
  this._updatePathState(path);
949
864
  const convergedPaths = this._handleMergePoint(paths, pendingPaths, path);
950
865
  if (convergedPaths == null) {
951
- log("waiting for other paths", void 0, {
952
- F: __dxlog_file4,
953
- L: 136,
954
- S: this,
955
- C: (f, a) => f(...a)
956
- });
866
+ log("waiting for other paths", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 137, S: this });
957
867
  continue;
958
868
  }
959
869
  const mergeResult = this._mergePaths(convergedPaths);
@@ -977,12 +887,7 @@ var CredentialGraph = class {
977
887
  path: toChosenPath(p),
978
888
  head: p.head.id
979
889
  }))
980
- }, {
981
- F: __dxlog_file4,
982
- L: 155,
983
- S: this,
984
- C: (f, a) => f(...a)
985
- });
890
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 156, S: this });
986
891
  }
987
892
  return this._setCurrentState(lastPath);
988
893
  }
@@ -1003,12 +908,7 @@ var CredentialGraph = class {
1003
908
  path: toChosenPath(path),
1004
909
  overrides: path?.stateOverrides?.mapValues((v) => this._stateHandler.toLogString(v.assertion))
1005
910
  }))
1006
- }), {
1007
- F: __dxlog_file4,
1008
- L: 175,
1009
- S: this,
1010
- C: (f, a) => f(...a)
1011
- });
911
+ }), { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 175, S: this });
1012
912
  const clearedPending = convergedPaths.filter((l) => !mergeResult.replay.includes(l));
1013
913
  pendingPaths.set(convergedPaths[0].head.id, clearedPending);
1014
914
  }
@@ -1020,12 +920,7 @@ var CredentialGraph = class {
1020
920
  return null;
1021
921
  }
1022
922
  if (path.head.id === this._sentinel.id && paths.length > 0) {
1023
- log("waiting for all the active paths to converge on the sentinel", void 0, {
1024
- F: __dxlog_file4,
1025
- L: 199,
1026
- S: this,
1027
- C: (f, a) => f(...a)
1028
- });
923
+ log("waiting for all the active paths to converge on the sentinel", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 194, S: this });
1029
924
  return null;
1030
925
  }
1031
926
  pendingPaths.delete(path.head.id);
@@ -1050,12 +945,7 @@ var CredentialGraph = class {
1050
945
  log("path state updated", () => ({
1051
946
  subject: updatedSubject,
1052
947
  newState: this._stateHandler.toLogString(path.head.assertion)
1053
- }), {
1054
- F: __dxlog_file4,
1055
- L: 223,
1056
- S: this,
1057
- C: (f, a) => f(...a)
1058
- });
948
+ }), { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 217, S: this });
1059
949
  }
1060
950
  }
1061
951
  _forkTraversal(paths, path) {
@@ -1065,12 +955,7 @@ var CredentialGraph = class {
1065
955
  log("edge traversal", {
1066
956
  from: path.head.id,
1067
957
  to: choice.id
1068
- }, {
1069
- F: __dxlog_file4,
1070
- L: 234,
1071
- S: this,
1072
- C: (f, a) => f(...a)
1073
- });
958
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 227, S: this });
1074
959
  const fork = {
1075
960
  forkPoint: path,
1076
961
  chosenPath: {
@@ -1163,15 +1048,7 @@ var CredentialGraph = class {
1163
1048
  return path;
1164
1049
  }
1165
1050
  _mergePaths(convergedPaths) {
1166
- invariant4(convergedPaths.length >= 1, void 0, {
1167
- F: __dxlog_file4,
1168
- L: 324,
1169
- S: this,
1170
- A: [
1171
- "convergedPaths.length >= 1",
1172
- ""
1173
- ]
1174
- });
1051
+ invariant4(convergedPaths.length >= 1, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 320, S: this, A: ["convergedPaths.length >= 1", ""] });
1175
1052
  if (convergedPaths.length === 1) {
1176
1053
  return {
1177
1054
  type: "merged",
@@ -1183,22 +1060,9 @@ var CredentialGraph = class {
1183
1060
  forkPointId: forkPoint.head.id,
1184
1061
  pathCount: convergedPaths.length,
1185
1062
  forkPoints: convergedPaths.map((fp) => fp.forkPoint?.head.id)
1186
- }), {
1187
- F: __dxlog_file4,
1188
- L: 329,
1189
- S: this,
1190
- C: (f, a) => f(...a)
1191
- });
1063
+ }), { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 328, S: this });
1192
1064
  const paths = convergedPaths.map((p) => this._moveUpToForkPoint(forkPoint, p));
1193
- invariant4(forkPoint, void 0, {
1194
- F: __dxlog_file4,
1195
- L: 335,
1196
- S: this,
1197
- A: [
1198
- "forkPoint",
1199
- ""
1200
- ]
1201
- });
1065
+ invariant4(forkPoint, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 334, S: this, A: ["forkPoint", ""] });
1202
1066
  const result = {
1203
1067
  forkPoint: forkPoint.forkPoint,
1204
1068
  chosenPath: {
@@ -1219,12 +1083,7 @@ var CredentialGraph = class {
1219
1083
  modified: path.forkChangedSubjects,
1220
1084
  forkIssuers: path.forkIssuers,
1221
1085
  state: path.state.mapValues((v) => this._stateHandler.toLogString(v.assertion))
1222
- }), {
1223
- F: __dxlog_file4,
1224
- L: 348,
1225
- S: this,
1226
- C: (f, a) => f(...a)
1227
- });
1086
+ }), { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 350, S: this });
1228
1087
  path.forkIssuers.forEach((iss) => result.forkIssuers.add(iss));
1229
1088
  path.credentials.forEach((cred) => result.credentials.add(cred));
1230
1089
  result.chosenPath[forkPoint.head.id].push(...path.chosenPath[forkPoint.head.id] ?? []);
@@ -1244,12 +1103,7 @@ var CredentialGraph = class {
1244
1103
  log("set subject state", () => ({
1245
1104
  subject,
1246
1105
  state: this._stateHandler.toLogString(vertex.assertion)
1247
- }), {
1248
- F: __dxlog_file4,
1249
- L: 370,
1250
- S: this,
1251
- C: (f, a) => f(...a)
1252
- });
1106
+ }), { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 372, S: this });
1253
1107
  const otherPaths = paths.filter((p) => p !== branch);
1254
1108
  this._stateHandler.getConflictingPaths(otherPaths, vertex).forEach(addReplayPath);
1255
1109
  }
@@ -1288,12 +1142,7 @@ var CredentialGraph = class {
1288
1142
  if (candidateVertex.id === mergePointId || currentVertex.id === mergePointId) {
1289
1143
  log("merge point chosen to break the tie", {
1290
1144
  mergePointId: existing.head.id
1291
- }, {
1292
- F: __dxlog_file4,
1293
- L: 408,
1294
- S: this,
1295
- C: (f, a) => f(...a)
1296
- });
1145
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 412, S: this });
1297
1146
  return mergePointId === candidateVertex.id;
1298
1147
  }
1299
1148
  const candidateCredential = candidateVertex.credential;
@@ -1302,12 +1151,7 @@ var CredentialGraph = class {
1302
1151
  log("one of the credentials was overridden in another branch", {
1303
1152
  current: currentVertex.id,
1304
1153
  candidate: candidateVertex.id
1305
- }, {
1306
- F: __dxlog_file4,
1307
- L: 415,
1308
- S: this,
1309
- C: (f, a) => f(...a)
1310
- });
1154
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 421, S: this });
1311
1155
  return candidate.credentials.has(currentCredential.id);
1312
1156
  }
1313
1157
  const winningCredential = this._stateHandler.tryPickWinningUpdate(existing, currentCredential, candidate, candidateCredential);
@@ -1320,20 +1164,10 @@ var CredentialGraph = class {
1320
1164
  existing.forkIssuers.size,
1321
1165
  candidate.forkIssuers.size
1322
1166
  ]
1323
- }, {
1324
- F: __dxlog_file4,
1325
- L: 432,
1326
- S: this,
1327
- C: (f, a) => f(...a)
1328
- });
1167
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 433, S: this });
1329
1168
  return candidate.forkIssuers.size > existing.forkIssuers.size;
1330
1169
  }
1331
- log("issuance date used to break the tie", void 0, {
1332
- F: __dxlog_file4,
1333
- L: 437,
1334
- S: this,
1335
- C: (f, a) => f(...a)
1336
- });
1170
+ log("issuance date used to break the tie", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 441, S: this });
1337
1171
  return candidateCredential.issuanceDate.getTime() > currentCredential.issuanceDate.getTime();
1338
1172
  }
1339
1173
  _createRootPath() {
@@ -1346,32 +1180,6 @@ var CredentialGraph = class {
1346
1180
  credentials: new ComplexSet2(PublicKey6.hash)
1347
1181
  };
1348
1182
  }
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
- }
1375
1183
  };
1376
1184
  var toChosenPath = (path) => {
1377
1185
  return Object.fromEntries(Object.entries(path.chosenPath).map(([k, vs]) => [
@@ -1381,21 +1189,16 @@ var toChosenPath = (path) => {
1381
1189
  };
1382
1190
 
1383
1191
  // 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;
1394
- }
1395
- return obj;
1396
- }
1397
1192
  var __dxlog_file5 = "/__w/dxos/dxos/packages/core/halo/credentials/src/state-machine/member-state-machine.ts";
1398
1193
  var MemberStateMachine = class {
1194
+ _spaceKey;
1195
+ _ownerKey;
1196
+ _memberProfiles = new ComplexMap5(PublicKey7.hash);
1197
+ _hashgraph = new CredentialGraph(this);
1198
+ onMemberRoleChanged = this._hashgraph.onSubjectStateChanged;
1199
+ constructor(_spaceKey) {
1200
+ this._spaceKey = _spaceKey;
1201
+ }
1399
1202
  get creator() {
1400
1203
  return this._ownerKey && this._hashgraph.getSubjectState(this._ownerKey);
1401
1204
  }
@@ -1416,15 +1219,7 @@ var MemberStateMachine = class {
1416
1219
  const assertion = getCredentialAssertion(credential);
1417
1220
  switch (assertion["@type"]) {
1418
1221
  case "dxos.halo.credentials.SpaceMember": {
1419
- invariant5(assertion.spaceKey.equals(this._spaceKey), void 0, {
1420
- F: __dxlog_file5,
1421
- L: 66,
1422
- S: this,
1423
- A: [
1424
- "assertion.spaceKey.equals(this._spaceKey)",
1425
- ""
1426
- ]
1427
- });
1222
+ invariant5(assertion.spaceKey.equals(this._spaceKey), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 43, S: this, A: ["assertion.spaceKey.equals(this._spaceKey)", ""] });
1428
1223
  if (this._ownerKey == null && credential.issuer === this._spaceKey) {
1429
1224
  this._ownerKey = credential.subject.id;
1430
1225
  }
@@ -1441,12 +1236,7 @@ var MemberStateMachine = class {
1441
1236
  } else {
1442
1237
  log2.warn("Member not found", {
1443
1238
  id: credential.subject.id
1444
- }, {
1445
- F: __dxlog_file5,
1446
- L: 81,
1447
- S: this,
1448
- C: (f, a) => f(...a)
1449
- });
1239
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 59, S: this });
1450
1240
  }
1451
1241
  this._memberProfiles.set(credential.subject.id, assertion.profile);
1452
1242
  break;
@@ -1491,12 +1281,7 @@ var MemberStateMachine = class {
1491
1281
  const path1IssuerRole = this._getRole(scope1, update1.issuer);
1492
1282
  const path2IssuerRole = this._getRole(scope2, update2.issuer);
1493
1283
  if (path2IssuerRole === SpaceMember2.Role.OWNER !== (path1IssuerRole === SpaceMember2.Role.OWNER)) {
1494
- log2("owner decision used to break the tie", void 0, {
1495
- F: __dxlog_file5,
1496
- L: 139,
1497
- S: this,
1498
- C: (f, a) => f(...a)
1499
- });
1284
+ log2("owner decision used to break the tie", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 107, S: this });
1500
1285
  return path1IssuerRole === SpaceMember2.Role.OWNER ? update1 : update2;
1501
1286
  }
1502
1287
  return null;
@@ -1520,52 +1305,46 @@ var MemberStateMachine = class {
1520
1305
  headId: scope.head?.id,
1521
1306
  roleOverride: this.toLogString(override.assertion),
1522
1307
  realRole: this.toLogString(scope.state.get(memberId)?.assertion)
1523
- }), {
1524
- F: __dxlog_file5,
1525
- L: 162,
1526
- S: this,
1527
- C: (f, a) => f(...a)
1528
- });
1308
+ }), { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 127, S: this });
1529
1309
  return override.assertion.role;
1530
1310
  }
1531
1311
  }
1532
1312
  return realRole;
1533
1313
  }
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
- }
1545
1314
  };
1546
1315
 
1547
1316
  // 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
- }
1317
+ var __dxlog_file6 = "/__w/dxos/dxos/packages/core/halo/credentials/src/state-machine/space-state-machine.ts";
1561
1318
  function _ts_decorate(decorators, target, key, desc) {
1562
1319
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1563
1320
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1564
1321
  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;
1565
1322
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1566
1323
  }
1567
- var __dxlog_file6 = "/__w/dxos/dxos/packages/core/halo/credentials/src/state-machine/space-state-machine.ts";
1568
1324
  var SpaceStateMachine = class {
1325
+ _spaceKey;
1326
+ _members;
1327
+ _feeds;
1328
+ _invitations = new InvitationStateMachine();
1329
+ _credentials = [];
1330
+ _credentialsById = new ComplexMap6(PublicKey8.hash);
1331
+ _processedCredentials = new ComplexSet3(PublicKey8.hash);
1332
+ _genesisCredential;
1333
+ _tags = [];
1334
+ _membershipPolicy = MembershipPolicy2.INVITE;
1335
+ _credentialProcessors = [];
1336
+ onCredentialProcessed = new Callback4();
1337
+ onMemberRoleChanged;
1338
+ onFeedAdmitted;
1339
+ onDelegatedInvitation = this._invitations.onDelegatedInvitation;
1340
+ onDelegatedInvitationRemoved = this._invitations.onDelegatedInvitationRemoved;
1341
+ constructor(_spaceKey) {
1342
+ this._spaceKey = _spaceKey;
1343
+ this._members = new MemberStateMachine(this._spaceKey);
1344
+ this._feeds = new FeedStateMachine(this._spaceKey);
1345
+ this.onMemberRoleChanged = this._members.onMemberRoleChanged;
1346
+ this.onFeedAdmitted = this._feeds.onFeedAdmitted;
1347
+ }
1569
1348
  get creator() {
1570
1349
  return this._members.creator;
1571
1350
  }
@@ -1587,6 +1366,12 @@ var SpaceStateMachine = class {
1587
1366
  get genesisCredential() {
1588
1367
  return this._genesisCredential;
1589
1368
  }
1369
+ get tags() {
1370
+ return this._tags;
1371
+ }
1372
+ get membershipPolicy() {
1373
+ return this._membershipPolicy;
1374
+ }
1590
1375
  get invitations() {
1591
1376
  return this._invitations.invitations;
1592
1377
  }
@@ -1626,12 +1411,7 @@ var SpaceStateMachine = class {
1626
1411
  if (!skipVerification) {
1627
1412
  const result = await verifyCredential(credential);
1628
1413
  if (result.kind !== "pass") {
1629
- log3.warn(`Invalid credential: ${result.errors.join(", ")}`, void 0, {
1630
- F: __dxlog_file6,
1631
- L: 162,
1632
- S: this,
1633
- C: (f, a) => f(...a)
1634
- });
1414
+ log3.warn(`Invalid credential: ${result.errors.join(", ")}`, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 116, S: this });
1635
1415
  return false;
1636
1416
  }
1637
1417
  }
@@ -1639,33 +1419,20 @@ var SpaceStateMachine = class {
1639
1419
  switch (assertion["@type"]) {
1640
1420
  case "dxos.halo.credentials.SpaceGenesis": {
1641
1421
  if (this._genesisCredential) {
1642
- log3.warn("Space already has a genesis credential.", void 0, {
1643
- F: __dxlog_file6,
1644
- L: 171,
1645
- S: this,
1646
- C: (f, a) => f(...a)
1647
- });
1422
+ log3.warn("Space already has a genesis credential.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 125, S: this });
1648
1423
  return false;
1649
1424
  }
1650
1425
  if (!credential.issuer.equals(this._spaceKey)) {
1651
- log3.warn("Space genesis credential must be issued by space.", void 0, {
1652
- F: __dxlog_file6,
1653
- L: 175,
1654
- S: this,
1655
- C: (f, a) => f(...a)
1656
- });
1426
+ log3.warn("Space genesis credential must be issued by space.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 129, S: this });
1657
1427
  return false;
1658
1428
  }
1659
1429
  if (!credential.subject.id.equals(this._spaceKey)) {
1660
- log3.warn("Space genesis credential must be issued to space.", void 0, {
1661
- F: __dxlog_file6,
1662
- L: 179,
1663
- S: this,
1664
- C: (f, a) => f(...a)
1665
- });
1430
+ log3.warn("Space genesis credential must be issued to space.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 133, S: this });
1666
1431
  return false;
1667
1432
  }
1668
1433
  this._genesisCredential = credential;
1434
+ this._tags = assertion.tags ?? [];
1435
+ this._membershipPolicy = assertion.membershipPolicy ?? MembershipPolicy2.INVITE;
1669
1436
  break;
1670
1437
  }
1671
1438
  case "dxos.halo.credentials.SpaceMember": {
@@ -1673,21 +1440,11 @@ var SpaceStateMachine = class {
1673
1440
  break;
1674
1441
  }
1675
1442
  if (!this._genesisCredential) {
1676
- log3.warn("Space must have a genesis credential before adding members.", void 0, {
1677
- F: __dxlog_file6,
1678
- L: 192,
1679
- S: this,
1680
- C: (f, a) => f(...a)
1681
- });
1443
+ log3.warn("Space must have a genesis credential before adding members.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 147, S: this });
1682
1444
  return false;
1683
1445
  }
1684
1446
  if (!this._canInviteNewMembers(credential.issuer)) {
1685
- log3.warn(`Space member is not authorized to invite new members: ${credential.issuer}`, void 0, {
1686
- F: __dxlog_file6,
1687
- L: 196,
1688
- S: this,
1689
- C: (f, a) => f(...a)
1690
- });
1447
+ log3.warn(`Space member is not authorized to invite new members: ${credential.issuer}`, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 151, S: this });
1691
1448
  return false;
1692
1449
  }
1693
1450
  await this._members.process(credential);
@@ -1696,12 +1453,7 @@ var SpaceStateMachine = class {
1696
1453
  }
1697
1454
  case "dxos.halo.credentials.MemberProfile": {
1698
1455
  if (!this._genesisCredential) {
1699
- log3.warn("Space must have a genesis credential before adding members.", void 0, {
1700
- F: __dxlog_file6,
1701
- L: 207,
1702
- S: this,
1703
- C: (f, a) => f(...a)
1704
- });
1456
+ log3.warn("Space must have a genesis credential before adding members.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 161, S: this });
1705
1457
  return false;
1706
1458
  }
1707
1459
  await this._members.process(credential);
@@ -1709,12 +1461,7 @@ var SpaceStateMachine = class {
1709
1461
  }
1710
1462
  case "dxos.halo.credentials.AdmittedFeed": {
1711
1463
  if (!this._genesisCredential) {
1712
- log3.warn("Space must have a genesis credential before admitting feeds.", void 0, {
1713
- F: __dxlog_file6,
1714
- L: 217,
1715
- S: this,
1716
- C: (f, a) => f(...a)
1717
- });
1464
+ log3.warn("Space must have a genesis credential before admitting feeds.", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 170, S: this });
1718
1465
  return false;
1719
1466
  }
1720
1467
  await this._feeds.process(credential, sourceFeed);
@@ -1723,12 +1470,7 @@ var SpaceStateMachine = class {
1723
1470
  case "dxos.halo.invitations.CancelDelegatedInvitation":
1724
1471
  case "dxos.halo.invitations.DelegateSpaceInvitation": {
1725
1472
  if (!this._canInviteNewMembers(credential.issuer)) {
1726
- log3.warn(`Invalid invitation, space member is not authorized to invite new members: ${credential.issuer}`, void 0, {
1727
- F: __dxlog_file6,
1728
- L: 228,
1729
- S: this,
1730
- C: (f, a) => f(...a)
1731
- });
1473
+ log3.warn(`Invalid invitation, space member is not authorized to invite new members: ${credential.issuer}`, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 181, S: this });
1732
1474
  return false;
1733
1475
  }
1734
1476
  await this._invitations.process(credential);
@@ -1759,42 +1501,32 @@ var SpaceStateMachine = class {
1759
1501
  return this._canInviteNewMembers(memberKey);
1760
1502
  }
1761
1503
  _canInviteNewMembers(key) {
1504
+ if (this._membershipPolicy === MembershipPolicy2.LOCKED) {
1505
+ return key.equals(this._spaceKey) && this._members.members.size === 0;
1506
+ }
1762
1507
  return key.equals(this._spaceKey) || this._members.getRole(key) === SpaceMember3.Role.ADMIN || this._members.getRole(key) === SpaceMember3.Role.OWNER;
1763
1508
  }
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
- }
1793
1509
  };
1794
1510
  _ts_decorate([
1795
1511
  synchronized
1796
1512
  ], SpaceStateMachine.prototype, "process", null);
1797
1513
  var CredentialConsumer = class {
1514
+ processor;
1515
+ _onOpen;
1516
+ _onClose;
1517
+ _ctx = new Context(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 229 });
1518
+ /**
1519
+ * @internal
1520
+ * Processor is ready to process live credentials.
1521
+ * NOTE: Setting this flag before all existing credentials are processed will cause them to be processed out of order.
1522
+ * Set externally.
1523
+ */
1524
+ _isReadyForLiveCredentials = false;
1525
+ constructor(processor, _onOpen, _onClose) {
1526
+ this.processor = processor;
1527
+ this._onOpen = _onOpen;
1528
+ this._onClose = _onClose;
1529
+ }
1798
1530
  /**
1799
1531
  * @internal
1800
1532
  */
@@ -1813,21 +1545,6 @@ var CredentialConsumer = class {
1813
1545
  await this._ctx.dispose();
1814
1546
  await this._onClose();
1815
1547
  }
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
- }
1831
1548
  };
1832
1549
 
1833
1550
  // src/processor/device-state-machine.ts
@@ -1836,32 +1553,22 @@ import { invariant as invariant6 } from "@dxos/invariant";
1836
1553
  import { PublicKey as PublicKey9 } from "@dxos/keys";
1837
1554
  import { log as log4 } from "@dxos/log";
1838
1555
  import { ComplexMap as ComplexMap7 } from "@dxos/util";
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;
1849
- }
1850
- return obj;
1851
- }
1852
1556
  var __dxlog_file7 = "/__w/dxos/dxos/packages/core/halo/credentials/src/processor/device-state-machine.ts";
1853
1557
  var DeviceStateMachine = class {
1558
+ _params;
1559
+ // TODO(burdon): Return values via getter.
1560
+ authorizedDeviceKeys = new ComplexMap7(PublicKey9.hash);
1561
+ deviceChainReady = new Trigger();
1562
+ deviceCredentialChain;
1563
+ constructor(_params) {
1564
+ this._params = _params;
1565
+ }
1854
1566
  async processCredential(credential) {
1855
1567
  log4("processing credential...", {
1856
1568
  identityKey: this._params.identityKey,
1857
1569
  deviceKey: this._params.deviceKey,
1858
1570
  credential
1859
- }, {
1860
- F: __dxlog_file7,
1861
- L: 36,
1862
- S: this,
1863
- C: (f, a) => f(...a)
1864
- });
1571
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 22, S: this });
1865
1572
  if (isValidAuthorizedDeviceCredential(credential, this._params.identityKey, this._params.deviceKey)) {
1866
1573
  this.deviceCredentialChain = {
1867
1574
  credential
@@ -1876,35 +1583,17 @@ var DeviceStateMachine = class {
1876
1583
  localDeviceKey: this._params.deviceKey,
1877
1584
  deviceKey: assertion.deviceKey,
1878
1585
  size: this.authorizedDeviceKeys.size
1879
- }, {
1880
- F: __dxlog_file7,
1881
- L: 56,
1882
- S: this,
1883
- C: (f, a) => f(...a)
1884
- });
1586
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 41, S: this });
1885
1587
  this._params.onUpdate?.();
1886
1588
  break;
1887
1589
  }
1888
1590
  case "dxos.halo.credentials.DeviceProfile": {
1889
- invariant6(this.authorizedDeviceKeys.has(credential.subject.id), "Device not found.", {
1890
- F: __dxlog_file7,
1891
- L: 66,
1892
- S: this,
1893
- A: [
1894
- "this.authorizedDeviceKeys.has(credential.subject.id)",
1895
- "'Device not found.'"
1896
- ]
1897
- });
1591
+ invariant6(this.authorizedDeviceKeys.has(credential.subject.id), "Device not found.", { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 51, S: this, A: ["this.authorizedDeviceKeys.has(credential.subject.id)", "'Device not found.'"] });
1898
1592
  if (assertion && credential.subject.id.equals(this._params.deviceKey)) {
1899
1593
  log4.trace("dxos.halo.device", {
1900
1594
  deviceKey: credential.subject.id,
1901
1595
  profile: assertion.profile
1902
- }, {
1903
- F: __dxlog_file7,
1904
- L: 69,
1905
- S: this,
1906
- C: (f, a) => f(...a)
1907
- });
1596
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 53, S: this });
1908
1597
  }
1909
1598
  this.authorizedDeviceKeys.set(credential.subject.id, assertion.profile);
1910
1599
  this._params.onUpdate?.();
@@ -1912,34 +1601,18 @@ var DeviceStateMachine = class {
1912
1601
  }
1913
1602
  }
1914
1603
  }
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
- }
1924
1604
  };
1925
1605
 
1926
1606
  // src/processor/profile-state-machine.ts
1927
1607
  import { log as log5 } from "@dxos/log";
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;
1938
- }
1939
- return obj;
1940
- }
1941
1608
  var __dxlog_file8 = "/__w/dxos/dxos/packages/core/halo/credentials/src/processor/profile-state-machine.ts";
1942
1609
  var ProfileStateMachine = class {
1610
+ _params;
1611
+ // TODO(burdon): Return values via getter.
1612
+ profile;
1613
+ constructor(_params) {
1614
+ this._params = _params;
1615
+ }
1943
1616
  async processCredential(credential) {
1944
1617
  const assertion = getCredentialAssertion(credential);
1945
1618
  switch (assertion["@type"]) {
@@ -1948,34 +1621,19 @@ var ProfileStateMachine = class {
1948
1621
  log5.warn("Invalid profile credential", {
1949
1622
  expectedIdentity: this._params.identityKey,
1950
1623
  credential
1951
- }, {
1952
- F: __dxlog_file8,
1953
- L: 35,
1954
- S: this,
1955
- C: (f, a) => f(...a)
1956
- });
1624
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 21, S: this });
1957
1625
  return;
1958
1626
  }
1959
1627
  this.profile = assertion.profile;
1960
1628
  log5("updated profile", {
1961
1629
  identityKey: this._params.identityKey,
1962
1630
  profile: this.profile
1963
- }, {
1964
- F: __dxlog_file8,
1965
- L: 41,
1966
- S: this,
1967
- C: (f, a) => f(...a)
1968
- });
1631
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file8, L: 29, S: this });
1969
1632
  this._params.onUpdate?.();
1970
1633
  break;
1971
1634
  }
1972
1635
  }
1973
1636
  }
1974
- constructor(_params) {
1975
- _define_property8(this, "_params", void 0);
1976
- _define_property8(this, "profile", void 0);
1977
- this._params = _params;
1978
- }
1979
1637
  };
1980
1638
  export {
1981
1639
  CredentialGenerator,