@ibgib/space-gib 0.0.4 → 0.0.5

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.
@@ -1,4 +1,4 @@
1
- import{$b as ar,Aa as Fi,B as ye,C as Gi,D as ke,E as Qe,Fb as Zi,G as Di,Gb as ji,H as Li,Hb as er,I as Y,Ib as tr,Jb as nr,La as Gt,Mb as or,Sa as Vi,Sb as se,Ua as Hi,Ub as Ze,Vb as ir,W as ki,Wb as rr,X as Ui,Yb as Fe,Zb as sr,a as f,ab as On,ac as ve,b as Pt,bb as qi,bc as lr,c as K,cc as je,d as Nt,db as ae,dc as cr,e as Rt,eb as le,f as Ri,fb as V,g as D,h as j,hb as Bi,i as y,ib as Oi,ic as dr,jb as Ji,jc as zn,k as Le,kb as zi,kc as ur,lb as Wi,lc as W,m as ht,n as Ye,nb as re,o as $t,ob as Xi,p as Mt,pb as yt,q as gt,qb as Ki,rb as Ue,sb as Et,t as q,tb as Yi,u as x,ub as Qi,v as de,vb as Dt,w as $i,wb as Jn,y as Mi,yb as Ee,z as bt,zb as Lt}from"./chunk-NCXKCVYS.mjs";var ue=V,Wn=class n{static{f(this,"IbGibComponentService")}lc=`[${n.name}]`;_registeredComponentsMeta=[];initialized;constructor(){this.initialized=this.initialize()}async initialize(){let e=`[${this.initialize.name}]`;try{ue&&console.log(`${e} starting... (I: 1cf04e8d768f4b5c55e7c3861e2d2225)`),console.log(`${e} does nothing atow (I: 65bb46c88c82b637ad928b8bf1a07225)`)}catch(t){throw console.error(`${e} ${y(t)}`),t}finally{ue&&console.log(`${e} complete.`)}}registerComponentMeta(e){this._registeredComponentsMeta.push(e),ue&&console.log(`${this.lc}[registerComponentMeta] component meta registered: ${e.constructor.name} (I: 88ddcbd0c8caa2342af0e7348f171225)`)}unregisterComponentMeta(e){this._registeredComponentsMeta=this._registeredComponentsMeta.filter(t=>t!==e),ue&&console.log(`${this.lc}[unregisterComponentMeta] component meta unregistered: ${e.constructor.name} (I: 4e84b5274de688248984896a90f5cc25)`)}async getComponentInstance({useRegExpPrefilter:e,path:t,ibGibAddr:o}){let i=`${this.lc}[${this.getComponentInstance.name}]`;try{ue&&console.log(`${i} starting... (I: 684ef316cbdb4a3b1fdc96096c273b25)`);let s,l=It.getRegisteredComponentsMeta(),c=e?l.filter(d=>{let u=d.routeRegExp?d.routeRegExp.test(t):!1;return ue&&console.log(`${i} ${d.componentName} ${d.routeRegExp} componentMatchesPath: ${u} (I: 3758520e6a4a57f218396c8649283425)`),u}):l.concat();for(let d of c)if(d.fnHandleRoute?await d.fnHandleRoute({path:t,ibGibAddr:o}):!0){s=await d.createInstance({path:t,ibGibAddr:o});break}return s}catch(s){throw console.error(`${i} ${y(s)}`),s}finally{ue&&console.log(`${i} complete.`)}}async inject({parentEl:e,componentToInject:t}){let o=`${this.lc}[${this.inject.name}]`;try{if(ue&&console.log(`${o} starting... (I: 6844cf07eaf8a5b1b106784f7db17125)`),!e)throw new Error(`${o} parentEl required. (E: 6f4eb2d682856ef47d173b970ec3c825)`);if(!t)throw new Error(`${o} componentToInject required. (E: decf0b51ad49257ce44fecbcf84c3a25)`);if(!t.meta)throw new Error(`${o} componentToInject.meta required. (E: f8827c0602ca7b0e030d0b3e2c4a4825)`);if(!t.meta.componentName)throw new Error(`${o} componentToInject.meta.componentName required. (E: 5dcae244ae32690f7b73ce27a32a3c25)`);e.innerHTML="",e.appendChild(t),e.classList.remove("fade-out")}catch(i){console.error(`${o} ${y(i)}`),e.innerHTML=`<p class="error">Error loading component for route. error:</p><br /><br /><p>${i.message}</p>`}finally{ue&&console.log(`${o} complete.`)}}getRegisteredComponentsMeta(){return[...this._registeredComponentsMeta]}},It;async function _e(){let n=`[${_e.name}]`;try{return ue&&console.log(`${n} starting... (I: 853694c88223381339103a3765129925)`),It||(It=new Wn,await It.initialized),It}catch(e){throw console.error(`${n} ${y(e)}`),e}finally{ue&&console.log(`${n} complete.`)}}f(_e,"getComponentSvc");var fr="left-panel";var pr="right-panel";var mr="left-resizer",hr="right-resizer",gr="footer-resizer",br="btn-left-panel-toggle",yr="btn-right-panel-toggle",Er="btn-create-keystone",Xn="center-panel-content";var Ir=`:host {
1
+ import{$b as ar,Aa as Fi,B as ye,C as Gi,D as ke,E as Qe,Fb as Zi,G as Di,Gb as ji,H as Li,Hb as er,I as Y,Ib as tr,Jb as nr,La as Gt,Mb as or,Sa as Vi,Sb as se,Ua as Hi,Ub as Ze,Vb as ir,W as ki,Wb as rr,X as Ui,Yb as Fe,Zb as sr,a as f,ab as On,ac as ve,b as Pt,bb as qi,bc as lr,c as K,cc as je,d as Nt,db as ae,dc as cr,e as Rt,eb as le,f as Ri,fb as V,g as D,h as j,hb as Bi,i as y,ib as Oi,ic as dr,jb as Ji,jc as zn,k as Le,kb as zi,kc as ur,lb as Wi,lc as W,m as ht,n as Ye,nb as re,o as $t,ob as Xi,p as Mt,pb as yt,q as gt,qb as Ki,rb as Ue,sb as Et,t as q,tb as Yi,u as x,ub as Qi,v as de,vb as Dt,w as $i,wb as Jn,y as Mi,yb as Ee,z as bt,zb as Lt}from"./chunk-ANGVYAEK.mjs";var ue=V,Wn=class n{static{f(this,"IbGibComponentService")}lc=`[${n.name}]`;_registeredComponentsMeta=[];initialized;constructor(){this.initialized=this.initialize()}async initialize(){let e=`[${this.initialize.name}]`;try{ue&&console.log(`${e} starting... (I: 1cf04e8d768f4b5c55e7c3861e2d2225)`),console.log(`${e} does nothing atow (I: 65bb46c88c82b637ad928b8bf1a07225)`)}catch(t){throw console.error(`${e} ${y(t)}`),t}finally{ue&&console.log(`${e} complete.`)}}registerComponentMeta(e){this._registeredComponentsMeta.push(e),ue&&console.log(`${this.lc}[registerComponentMeta] component meta registered: ${e.constructor.name} (I: 88ddcbd0c8caa2342af0e7348f171225)`)}unregisterComponentMeta(e){this._registeredComponentsMeta=this._registeredComponentsMeta.filter(t=>t!==e),ue&&console.log(`${this.lc}[unregisterComponentMeta] component meta unregistered: ${e.constructor.name} (I: 4e84b5274de688248984896a90f5cc25)`)}async getComponentInstance({useRegExpPrefilter:e,path:t,ibGibAddr:o}){let i=`${this.lc}[${this.getComponentInstance.name}]`;try{ue&&console.log(`${i} starting... (I: 684ef316cbdb4a3b1fdc96096c273b25)`);let s,l=It.getRegisteredComponentsMeta(),c=e?l.filter(d=>{let u=d.routeRegExp?d.routeRegExp.test(t):!1;return ue&&console.log(`${i} ${d.componentName} ${d.routeRegExp} componentMatchesPath: ${u} (I: 3758520e6a4a57f218396c8649283425)`),u}):l.concat();for(let d of c)if(d.fnHandleRoute?await d.fnHandleRoute({path:t,ibGibAddr:o}):!0){s=await d.createInstance({path:t,ibGibAddr:o});break}return s}catch(s){throw console.error(`${i} ${y(s)}`),s}finally{ue&&console.log(`${i} complete.`)}}async inject({parentEl:e,componentToInject:t}){let o=`${this.lc}[${this.inject.name}]`;try{if(ue&&console.log(`${o} starting... (I: 6844cf07eaf8a5b1b106784f7db17125)`),!e)throw new Error(`${o} parentEl required. (E: 6f4eb2d682856ef47d173b970ec3c825)`);if(!t)throw new Error(`${o} componentToInject required. (E: decf0b51ad49257ce44fecbcf84c3a25)`);if(!t.meta)throw new Error(`${o} componentToInject.meta required. (E: f8827c0602ca7b0e030d0b3e2c4a4825)`);if(!t.meta.componentName)throw new Error(`${o} componentToInject.meta.componentName required. (E: 5dcae244ae32690f7b73ce27a32a3c25)`);e.innerHTML="",e.appendChild(t),e.classList.remove("fade-out")}catch(i){console.error(`${o} ${y(i)}`),e.innerHTML=`<p class="error">Error loading component for route. error:</p><br /><br /><p>${i.message}</p>`}finally{ue&&console.log(`${o} complete.`)}}getRegisteredComponentsMeta(){return[...this._registeredComponentsMeta]}},It;async function _e(){let n=`[${_e.name}]`;try{return ue&&console.log(`${n} starting... (I: 853694c88223381339103a3765129925)`),It||(It=new Wn,await It.initialized),It}catch(e){throw console.error(`${n} ${y(e)}`),e}finally{ue&&console.log(`${n} complete.`)}}f(_e,"getComponentSvc");var fr="left-panel";var pr="right-panel";var mr="left-resizer",hr="right-resizer",gr="footer-resizer",br="btn-left-panel-toggle",yr="btn-right-panel-toggle",Er="btn-create-keystone",Xn="center-panel-content";var Ir=`:host {
2
2
  display: block;
3
3
  width: 100%;
4
4
  max-width: 600px;
@@ -1917,4 +1917,4 @@ Click to manage.`;let o=await this.getKeystoneDetails(e),i="-";if(o.username)i=o
1917
1917
  * SPDX-License-Identifier: Apache-2.0
1918
1918
  *)
1919
1919
  */
1920
- //# sourceMappingURL=chunk-ZUEU37Z5.mjs.map
1920
+ //# sourceMappingURL=chunk-IRGFDQRD.mjs.map
@@ -1,2 +1,2 @@
1
- import{Qb as c,Rb as l,Tb as a,a as r,i as e,mb as n,mc as s,nb as i}from"./chunk-NCXKCVYS.mjs";l(i);var m=n;async function d(){let o=`[${d.name}]`;try{m&&console.log(`${o} starting... (I: 3d893846d02c4ff49181f9b8e586eb74)`),console.time(o),document.addEventListener("DOMContentLoaded",async()=>{try{console.timeLog(o,"DOMContentLoaded fired"),await c(i),console.timeLog(o,"initIbGibStorage complete"),await a("./bootstrap.mjs"),console.timeLog(o,"dynamicallyLoadBootstrapScript complete"),s(),console.timeLog(o,"initDevTools complete"),console.timeEnd(o)}catch(t){throw console.error(`${o} ${e(t)}`),t}})}catch(t){console.timeEnd(o);debugger;throw console.error(`${o} ${e(t)}`),t}finally{m&&console.log(`${o} complete.`)}}r(d,"spinOffStartup");d();
1
+ import{Qb as c,Rb as l,Tb as a,a as r,i as e,mb as n,mc as s,nb as i}from"./chunk-ANGVYAEK.mjs";l(i);var m=n;async function d(){let o=`[${d.name}]`;try{m&&console.log(`${o} starting... (I: 3d893846d02c4ff49181f9b8e586eb74)`),console.time(o),document.addEventListener("DOMContentLoaded",async()=>{try{console.timeLog(o,"DOMContentLoaded fired"),await c(i),console.timeLog(o,"initIbGibStorage complete"),await a("./bootstrap.mjs"),console.timeLog(o,"dynamicallyLoadBootstrapScript complete"),s(),console.timeLog(o,"initDevTools complete"),console.timeEnd(o)}catch(t){throw console.error(`${o} ${e(t)}`),t}})}catch(t){console.timeEnd(o);debugger;throw console.error(`${o} ${e(t)}`),t}finally{m&&console.log(`${o} complete.`)}}r(d,"spinOffStartup");d();
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,2 +1,2 @@
1
- import{p as e}from"./chunk-ZUEU37Z5.mjs";import"./chunk-NCXKCVYS.mjs";console.log("space-gib early script executing...");e();
1
+ import{p as e}from"./chunk-IRGFDQRD.mjs";import"./chunk-ANGVYAEK.mjs";console.log("space-gib early script executing...");e();
2
2
  //# sourceMappingURL=script.mjs.map
@@ -17693,6 +17693,7 @@ var KeystoneVerb = {
17693
17693
  };
17694
17694
  var KEYSTONE_VERB_VALID_VALUES = Object.values(KeystoneVerb);
17695
17695
  var POOL_ID_REVOKE = KEYSTONE_VERB_REVOKE;
17696
+ var POOL_ID_MANAGE = KEYSTONE_VERB_MANAGE;
17696
17697
  var POOL_ID_CONNECT = KEYSTONE_VERB_CONNECT;
17697
17698
  var POOL_ID_SYNC = KEYSTONE_VERB_SYNC;
17698
17699
  var KEYSTONE_CONFIG_DEFAULT_SIZE = 200;
@@ -17940,6 +17941,14 @@ async function parseKeystoneIb({ ib }) {
17940
17941
  }
17941
17942
  }
17942
17943
  }
17944
+ async function validateKeystoneIb({ ib }) {
17945
+ try {
17946
+ await parseKeystoneIb({ ib });
17947
+ return true;
17948
+ } catch {
17949
+ return false;
17950
+ }
17951
+ }
17943
17952
  async function getDeterministicRequirements({ pool, requiredChallengeIds, targetAddr }) {
17944
17953
  const behavior = pool.config.behavior;
17945
17954
  const mandatory = /* @__PURE__ */ new Set();
@@ -18267,6 +18276,10 @@ async function validateGenesisKeystone({ keystoneIbGib }) {
18267
18276
  }
18268
18277
  const errors = [];
18269
18278
  const { data, rel8ns } = keystoneIbGib;
18279
+ const isValidIb = await validateKeystoneIb({ ib: keystoneIbGib.ib });
18280
+ if (!isValidIb) {
18281
+ errors.push(`${lc2} invalid keystone ib (${keystoneIbGib.ib}). (E: ad7a88bc38c290a184dfbd42be48f526)`);
18282
+ }
18270
18283
  const metadataErrors = validateKeystoneMetadata({ data });
18271
18284
  metadataErrors.forEach((x) => errors.push(x));
18272
18285
  if (data.proofs && data.proofs.length > 0) {
@@ -18292,6 +18305,54 @@ async function validateGenesisKeystone({ keystoneIbGib }) {
18292
18305
  }
18293
18306
  }
18294
18307
  }
18308
+ function isDelegatesChanged({ currDelegates, prevDelegates }) {
18309
+ const curr = currDelegates || {};
18310
+ const prev = prevDelegates || {};
18311
+ const currKeys = Object.keys(curr);
18312
+ const prevKeys = Object.keys(prev);
18313
+ if (currKeys.length !== prevKeys.length) {
18314
+ return true;
18315
+ }
18316
+ for (const key of currKeys) {
18317
+ const currVal = curr[key];
18318
+ const prevVal = prev[key];
18319
+ if (!prevVal) {
18320
+ return true;
18321
+ }
18322
+ if (currVal.delegateTjpAddr !== prevVal.delegateTjpAddr || currVal.delegateAddr !== prevVal.delegateAddr || currVal.thisAddr !== prevVal.thisAddr) {
18323
+ return true;
18324
+ }
18325
+ }
18326
+ return false;
18327
+ }
18328
+ async function validateDelegates({ currDelegates, prevIbGib, lc: lc2, errors }) {
18329
+ const currKeys = Object.keys(currDelegates);
18330
+ const prevAddr = getIbGibAddr({ ibGib: prevIbGib });
18331
+ for (const key of currKeys) {
18332
+ const info = currDelegates[key];
18333
+ if (key !== info.delegateTjpAddr) {
18334
+ errors.push(`${lc2} Invalid delegate mapping: Key '${key}' does not match delegateTjpAddr '${info.delegateTjpAddr}'. (E: 9c8da8bc38c290a184dfbd42be48f526)`);
18335
+ }
18336
+ const [parsedDelegateTjp, parsedDelegate, parsedThis] = await Promise.all([
18337
+ validateKeystoneIb({ ib: info.delegateTjpAddr.split("^")[0] }),
18338
+ validateKeystoneIb({ ib: info.delegateAddr.split("^")[0] }),
18339
+ validateKeystoneIb({ ib: info.thisAddr.split("^")[0] })
18340
+ ]);
18341
+ if (!parsedDelegateTjp) {
18342
+ errors.push(`${lc2} Delegate delegateTjpAddr '${info.delegateTjpAddr}' is not a valid keystone address. (E: 10d8a8bc38c290a184dfbd42be48f526)`);
18343
+ }
18344
+ if (!parsedDelegate) {
18345
+ errors.push(`${lc2} Delegate delegateAddr '${info.delegateAddr}' is not a valid keystone address. (E: 20d8a8bc38c290a184dfbd42be48f526)`);
18346
+ }
18347
+ if (!parsedThis) {
18348
+ errors.push(`${lc2} Delegate thisAddr '${info.thisAddr}' is not a valid keystone address. (E: 30d8a8bc38c290a184dfbd42be48f526)`);
18349
+ }
18350
+ const isHistoricalParent = info.thisAddr === prevAddr || (prevIbGib.rel8ns?.past || []).includes(info.thisAddr);
18351
+ if (!isHistoricalParent) {
18352
+ errors.push(`${lc2} Delegate thisAddr '${info.thisAddr}' is not a valid historical address in the parent keystone timeline. (E: 40d8a8bc38c290a184dfbd42be48f526)`);
18353
+ }
18354
+ }
18355
+ }
18295
18356
  async function validateKeystoneTransition({ currentIbGib, prevIbGib }) {
18296
18357
  const lc2 = `[${validateKeystoneTransition.name}]`;
18297
18358
  const errors = [];
@@ -18308,23 +18369,37 @@ async function validateKeystoneTransition({ currentIbGib, prevIbGib }) {
18308
18369
  }
18309
18370
  const currData = currentIbGib.data;
18310
18371
  const prevData = prevIbGib.data;
18372
+ const isValidIb = await validateKeystoneIb({ ib: currentIbGib.ib });
18373
+ if (!isValidIb) {
18374
+ errors.push(`${lc2} invalid keystone ib (${currentIbGib.ib}). (E: a98dc8bc38c290a184dfbd42be48f526)`);
18375
+ }
18311
18376
  const metadataErrors = validateKeystoneMetadata({ data: currData });
18312
18377
  metadataErrors.forEach((x) => errors.push(x));
18378
+ const currDelegates = currData.delegates || {};
18379
+ const prevDelegates = prevData.delegates || {};
18380
+ const delegatesChanged = isDelegatesChanged({ currDelegates, prevDelegates });
18381
+ if (delegatesChanged) {
18382
+ const hasManageProof = currData.proofs?.some((proof) => proof.claim?.verb === KEYSTONE_VERB_MANAGE);
18383
+ if (!hasManageProof) {
18384
+ errors.push(`${lc2} Policy Violation: Delegates map was mutated but no proof for manage verb ('${KEYSTONE_VERB_MANAGE}') is present. (E: 819fa8cb28c9b60e68994511a5825)`);
18385
+ }
18386
+ }
18387
+ await validateDelegates({ currDelegates, prevIbGib, lc: lc2, errors });
18313
18388
  const currDataN = currData.n ?? -2;
18314
18389
  const prevDataN = prevData.n ?? -2;
18315
18390
  if (currDataN < 0) {
18316
- errors.push("invalid keystone.currData.n is undefined or null.");
18391
+ errors.push("invalid keystone.currData.n is undefined or null. (E: 9fbe38704b68829d18ea1d0940d0aa26)");
18317
18392
  }
18318
18393
  if (prevDataN < 0) {
18319
- errors.push("invalid keystone.prevData.n is undefined or null.");
18394
+ errors.push("invalid keystone.prevData.n is undefined or null. (E: 6dc5aa9c87017db6080ed4268b07af26)");
18320
18395
  }
18321
18396
  ;
18322
18397
  if (currDataN !== prevDataN + 1) {
18323
- errors.push(`keystone data.n values are not sequential. prevData.n: ${prevDataN}, currData.n: ${currDataN}. `);
18398
+ errors.push(`keystone data.n values are not sequential. prevData.n: ${prevDataN}, currData.n: ${currDataN}. (E: 5ae12809f2c67216d38d8ba8d6c42826)`);
18324
18399
  }
18325
18400
  for (const proof of currData.proofs) {
18326
18401
  if (proof.solutions.length === 0) {
18327
- errors.push(`Proof ${proof.id || "unknown"} has no solutions.`);
18402
+ errors.push(`Proof ${proof.id || "unknown"} has no solutions. (E: e2b4683ce0ce30f798ec77841e88c826)`);
18328
18403
  continue;
18329
18404
  }
18330
18405
  const poolId = proof.solutions[0].poolId;
@@ -18432,6 +18507,9 @@ async function evolvePersistAndRegisterKeystone({ prevIbGib, newData, metaspace,
18432
18507
  if (prevData.checkpointDetails) {
18433
18508
  dataToRemove.checkpointDetails = {};
18434
18509
  }
18510
+ if (prevData.delegates) {
18511
+ dataToRemove.delegates = "remove";
18512
+ }
18435
18513
  if (Object.keys(dataToRemove).length === 0) {
18436
18514
  dataToRemove = void 0;
18437
18515
  }
@@ -18694,7 +18772,7 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
18694
18772
  *
18695
18773
  * todo: wrap this and other entire keystone sign/method implementations in locks on the keystone's tjpGib.
18696
18774
  */
18697
- async sign({ latestKeystone, masterSecret, claim, poolId, poolFilter, requiredChallengeIds = [], frameDetails, metaspace, space }) {
18775
+ async sign({ latestKeystone, masterSecret, claim, poolId, poolFilter, requiredChallengeIds = [], frameDetails, metaspace, space, dataToPatch }) {
18698
18776
  const lc2 = `${this.lc}[${this.sign.name}]`;
18699
18777
  try {
18700
18778
  if (logalot41) {
@@ -18743,7 +18821,9 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
18743
18821
  challengePools: nextPools,
18744
18822
  proofs: [proof],
18745
18823
  frameDetails,
18746
- checkpointDetails
18824
+ checkpointDetails,
18825
+ ...prevData.delegates ? { delegates: prevData.delegates } : {},
18826
+ ...dataToPatch
18747
18827
  };
18748
18828
  const resKeystone = await evolvePersistAndRegisterKeystone({
18749
18829
  prevIbGib: latestKeystone,
@@ -18776,6 +18856,155 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
18776
18856
  const errors = await validateKeystoneTransition({ currentIbGib, prevIbGib });
18777
18857
  return errors;
18778
18858
  }
18859
+ /**
18860
+ * Registers a delegate keystone on the parent keystone by appending its information
18861
+ * to the parent's `delegates` map. This operation is signed using the parent's `manage` pool.
18862
+ * Validates the delegate keystone's entire graph/timeline before registering.
18863
+ */
18864
+ async registerDelegate({ parentKeystone, delegateKeystone, masterSecret, frameDetails, metaspace, space }) {
18865
+ const lc2 = `${this.lc}[${this.registerDelegate.name}]`;
18866
+ try {
18867
+ if (logalot41) {
18868
+ console.log(`${lc2} starting...`);
18869
+ }
18870
+ const validationErrors = await validateKeystoneGraph({
18871
+ keystoneIbGib: delegateKeystone,
18872
+ getLatest: true,
18873
+ invalidIfMoreRecentKeystoneFoundInSpace: false,
18874
+ space
18875
+ });
18876
+ if (validationErrors.length > 0) {
18877
+ throw new Error(`Delegate keystone validation failed: ${validationErrors.join(", ")} (E: 88fa8ab28c9b60e68994511a5825)`);
18878
+ }
18879
+ const prevData = parentKeystone.data;
18880
+ const hasManagePool = prevData.challengePools.some((p) => p.id === POOL_ID_MANAGE);
18881
+ if (!hasManagePool) {
18882
+ throw new Error(`Parent keystone does not support delegation. Manage pool is required. (E: 818fa8ab28c9b60e68994511a5825)`);
18883
+ }
18884
+ const delegateTjpAddr = getTjpAddr({ ibGib: delegateKeystone });
18885
+ if (!delegateTjpAddr) {
18886
+ throw new Error(`(UNEXPECTED) delegateTjpAddr falsy? (E: d4d6e8ad03c8925d4838b9a87b8f2826)`);
18887
+ }
18888
+ const claim = {
18889
+ target: delegateTjpAddr,
18890
+ verb: KEYSTONE_VERB_MANAGE
18891
+ };
18892
+ const currentDelegates = prevData.delegates ? { ...prevData.delegates } : {};
18893
+ currentDelegates[delegateTjpAddr] = {
18894
+ delegateTjpAddr,
18895
+ delegateAddr: getIbGibAddr({ ibGib: delegateKeystone }),
18896
+ thisAddr: getIbGibAddr({ ibGib: parentKeystone })
18897
+ };
18898
+ const evolved = await this.sign({
18899
+ latestKeystone: parentKeystone,
18900
+ masterSecret,
18901
+ claim,
18902
+ poolId: POOL_ID_MANAGE,
18903
+ frameDetails,
18904
+ metaspace,
18905
+ space,
18906
+ dataToPatch: {
18907
+ delegates: currentDelegates
18908
+ }
18909
+ });
18910
+ return evolved;
18911
+ } catch (error) {
18912
+ console.error(`${lc2} ${extractErrorMsg(error)}`);
18913
+ throw error;
18914
+ } finally {
18915
+ if (logalot41) {
18916
+ console.log(`${lc2} complete.`);
18917
+ }
18918
+ }
18919
+ }
18920
+ /**
18921
+ * Unregisters a delegate keystone from the parent keystone by removing its entry
18922
+ * from the parent's `delegates` map. This operation is signed using the parent's `manage` pool.
18923
+ */
18924
+ async unregisterDelegate({ parentKeystone, delegateTjpAddr, masterSecret, frameDetails, metaspace, space }) {
18925
+ const lc2 = `${this.lc}[${this.unregisterDelegate.name}]`;
18926
+ try {
18927
+ if (logalot41) {
18928
+ console.log(`${lc2} starting...`);
18929
+ }
18930
+ const prevData = parentKeystone.data;
18931
+ const hasManagePool = prevData.challengePools.some((p) => p.id === POOL_ID_MANAGE);
18932
+ if (!hasManagePool) {
18933
+ throw new Error(`Parent keystone does not support delegation. Manage pool is required. (E: 3889f8ab28c9b60e68994511a5825)`);
18934
+ }
18935
+ const claim = {
18936
+ target: delegateTjpAddr,
18937
+ verb: KEYSTONE_VERB_MANAGE
18938
+ };
18939
+ const currentDelegates = prevData.delegates ? { ...prevData.delegates } : {};
18940
+ if (!currentDelegates[delegateTjpAddr]) {
18941
+ throw new Error(`Delegate ${delegateTjpAddr} is not registered on this parent. (E: 81d9f8ab28c9b60e68994511a5825)`);
18942
+ }
18943
+ delete currentDelegates[delegateTjpAddr];
18944
+ const evolved = await this.sign({
18945
+ latestKeystone: parentKeystone,
18946
+ masterSecret,
18947
+ claim,
18948
+ poolId: POOL_ID_MANAGE,
18949
+ frameDetails,
18950
+ metaspace,
18951
+ space,
18952
+ dataToPatch: {
18953
+ delegates: currentDelegates
18954
+ }
18955
+ });
18956
+ return evolved;
18957
+ } catch (error) {
18958
+ console.error(`${lc2} ${extractErrorMsg(error)}`);
18959
+ throw error;
18960
+ } finally {
18961
+ if (logalot41) {
18962
+ console.log(`${lc2} complete.`);
18963
+ }
18964
+ }
18965
+ }
18966
+ /**
18967
+ * Gets the registration status of a delegate keystone from the parent's latest tip frame.
18968
+ */
18969
+ async getDelegateStatus({ parentTjpAddr, delegateTjpAddr, metaspace, space }) {
18970
+ const lc2 = `${this.lc}[${this.getDelegateStatus.name}]`;
18971
+ try {
18972
+ if (logalot41) {
18973
+ console.log(`${lc2} starting...`);
18974
+ }
18975
+ const { ib, gib } = getIbAndGib({ ibGibAddr: parentTjpAddr });
18976
+ const parentIbGib = { ib, gib };
18977
+ const resGetLatest = await getLatestAddrs({
18978
+ ibGibs: [parentIbGib],
18979
+ space
18980
+ });
18981
+ if (!resGetLatest.data?.latestAddrsMap) {
18982
+ return { registered: false };
18983
+ }
18984
+ const latestAddr = resGetLatest.data.latestAddrsMap[parentTjpAddr];
18985
+ if (!latestAddr) {
18986
+ return { registered: false };
18987
+ }
18988
+ const resGet = await metaspace.get({ addr: latestAddr, space });
18989
+ const latestParent = resGet.ibGibs?.at(0);
18990
+ if (!latestParent || !latestParent.data) {
18991
+ return { registered: false };
18992
+ }
18993
+ const delegates = latestParent.data.delegates || {};
18994
+ const delegateInfo = delegates[delegateTjpAddr];
18995
+ return {
18996
+ registered: !!delegateInfo,
18997
+ delegateInfo
18998
+ };
18999
+ } catch (error) {
19000
+ console.error(`${lc2} ${extractErrorMsg(error)}`);
19001
+ throw error;
19002
+ } finally {
19003
+ if (logalot41) {
19004
+ console.log(`${lc2} complete.`);
19005
+ }
19006
+ }
19007
+ }
18779
19008
  /**
18780
19009
  * Validates a genesis keystone.
18781
19010
  *
@@ -18909,7 +19138,8 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
18909
19138
  proofs: [proof],
18910
19139
  revocationInfo,
18911
19140
  frameDetails,
18912
- checkpointDetails
19141
+ checkpointDetails,
19142
+ ...prevData.delegates ? { delegates: prevData.delegates } : {}
18913
19143
  };
18914
19144
  const newKeystone = await evolvePersistAndRegisterKeystone({
18915
19145
  prevIbGib: latestKeystone,
@@ -19002,7 +19232,8 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
19002
19232
  challengePools: finalPools,
19003
19233
  proofs: [proof],
19004
19234
  // The proof authorizes the structure change
19005
- checkpointDetails
19235
+ checkpointDetails,
19236
+ ...prevData.delegates ? { delegates: prevData.delegates } : {}
19006
19237
  };
19007
19238
  const newKeystone = await evolvePersistAndRegisterKeystone({
19008
19239
  prevIbGib: latestKeystone,