@ibgib/core-gib 0.1.47 → 0.1.48

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 (98) hide show
  1. package/dist/common/other/ibgib-helper.d.mts +12 -0
  2. package/dist/common/other/ibgib-helper.d.mts.map +1 -1
  3. package/dist/common/other/ibgib-helper.mjs +39 -0
  4. package/dist/common/other/ibgib-helper.mjs.map +1 -1
  5. package/dist/keystone/kdf/kdf-helpers.mjs +2 -2
  6. package/dist/keystone/kdf/kdf-helpers.mjs.map +1 -1
  7. package/dist/keystone/keystone-config-builder.d.mts +2 -1
  8. package/dist/keystone/keystone-config-builder.d.mts.map +1 -1
  9. package/dist/keystone/keystone-config-builder.mjs +8 -2
  10. package/dist/keystone/keystone-config-builder.mjs.map +1 -1
  11. package/dist/keystone/keystone-constants.d.mts +24 -3
  12. package/dist/keystone/keystone-constants.d.mts.map +1 -1
  13. package/dist/keystone/keystone-constants.mjs +22 -1
  14. package/dist/keystone/keystone-constants.mjs.map +1 -1
  15. package/dist/keystone/keystone-helpers.d.mts.map +1 -1
  16. package/dist/keystone/keystone-helpers.mjs +7 -9
  17. package/dist/keystone/keystone-helpers.mjs.map +1 -1
  18. package/dist/keystone/keystone-service-v1.d.mts +4 -1
  19. package/dist/keystone/keystone-service-v1.d.mts.map +1 -1
  20. package/dist/keystone/keystone-service-v1.mjs +6 -1
  21. package/dist/keystone/keystone-service-v1.mjs.map +1 -1
  22. package/dist/keystone/keystone-service-v1.respec.mjs +26 -26
  23. package/dist/keystone/keystone-service-v1.respec.mjs.map +1 -1
  24. package/dist/keystone/keystone-types.d.mts +24 -5
  25. package/dist/keystone/keystone-types.d.mts.map +1 -1
  26. package/dist/keystone/keystone-types.mjs.map +1 -1
  27. package/dist/sync/sync-conflict-adv-multitimelines.respec.mjs +1 -1
  28. package/dist/sync/sync-conflict-adv-multitimelines.respec.mjs.map +1 -1
  29. package/dist/sync/sync-conflict-basic-divergence.respec.mjs +1 -1
  30. package/dist/sync/sync-conflict-basic-divergence.respec.mjs.map +1 -1
  31. package/dist/sync/sync-conflict-basic-multitimelines.respec.mjs +1 -1
  32. package/dist/sync/sync-conflict-basic-multitimelines.respec.mjs.map +1 -1
  33. package/dist/sync/sync-conflict-text-merge.respec.mjs +1 -1
  34. package/dist/sync/sync-conflict-text-merge.respec.mjs.map +1 -1
  35. package/dist/sync/sync-constants.d.mts +47 -1
  36. package/dist/sync/sync-constants.d.mts.map +1 -1
  37. package/dist/sync/sync-constants.mjs +49 -1
  38. package/dist/sync/sync-constants.mjs.map +1 -1
  39. package/dist/sync/sync-innerspace-constants.respec.mjs +1 -1
  40. package/dist/sync/sync-innerspace-constants.respec.mjs.map +1 -1
  41. package/dist/sync/sync-innerspace-deep-updates.respec.mjs +1 -1
  42. package/dist/sync/sync-innerspace-deep-updates.respec.mjs.map +1 -1
  43. package/dist/sync/sync-innerspace-dest-ahead-withid.respec.mjs +33 -19
  44. package/dist/sync/sync-innerspace-dest-ahead-withid.respec.mjs.map +1 -1
  45. package/dist/sync/sync-innerspace-dest-ahead.respec.mjs +1 -1
  46. package/dist/sync/sync-innerspace-dest-ahead.respec.mjs.map +1 -1
  47. package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs +1 -1
  48. package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs.map +1 -1
  49. package/dist/sync/sync-innerspace-partial-update.respec.mjs +1 -1
  50. package/dist/sync/sync-innerspace-partial-update.respec.mjs.map +1 -1
  51. package/dist/sync/sync-innerspace.respec.mjs +1 -1
  52. package/dist/sync/sync-innerspace.respec.mjs.map +1 -1
  53. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts.map +1 -1
  54. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs +5 -0
  55. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs.map +1 -1
  56. package/dist/sync/sync-peer/sync-peer-v1.d.mts +6 -1
  57. package/dist/sync/sync-peer/sync-peer-v1.d.mts.map +1 -1
  58. package/dist/sync/sync-peer/sync-peer-v1.mjs +56 -23
  59. package/dist/sync/sync-peer/sync-peer-v1.mjs.map +1 -1
  60. package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts +7 -3
  61. package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts.map +1 -1
  62. package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs +32 -3
  63. package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs.map +1 -1
  64. package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts +16 -0
  65. package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts.map +1 -1
  66. package/dist/sync/sync-saga-coordinator.d.mts +18 -3
  67. package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
  68. package/dist/sync/sync-saga-coordinator.mjs +240 -55
  69. package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
  70. package/dist/sync/sync-types.d.mts +1 -1
  71. package/dist/sync/sync-types.d.mts.map +1 -1
  72. package/package.json +1 -1
  73. package/src/common/other/ibgib-helper.mts +39 -0
  74. package/src/keystone/kdf/kdf-helpers.mts +2 -2
  75. package/src/keystone/keystone-config-builder.mts +13 -2
  76. package/src/keystone/keystone-constants.mts +24 -2
  77. package/src/keystone/keystone-helpers.mts +5 -10
  78. package/src/keystone/keystone-service-v1.mts +5 -0
  79. package/src/keystone/keystone-service-v1.respec.mts +25 -25
  80. package/src/keystone/keystone-types.mts +27 -7
  81. package/src/sync/sync-conflict-adv-multitimelines.respec.mts +1 -1
  82. package/src/sync/sync-conflict-basic-divergence.respec.mts +1 -1
  83. package/src/sync/sync-conflict-basic-multitimelines.respec.mts +1 -1
  84. package/src/sync/sync-conflict-text-merge.respec.mts +1 -1
  85. package/src/sync/sync-constants.mts +51 -1
  86. package/src/sync/sync-innerspace-constants.respec.mts +1 -1
  87. package/src/sync/sync-innerspace-deep-updates.respec.mts +1 -1
  88. package/src/sync/sync-innerspace-dest-ahead-withid.respec.mts +36 -19
  89. package/src/sync/sync-innerspace-dest-ahead.respec.mts +1 -1
  90. package/src/sync/sync-innerspace-multiple-timelines.respec.mts +1 -1
  91. package/src/sync/sync-innerspace-partial-update.respec.mts +1 -1
  92. package/src/sync/sync-innerspace.respec.mts +1 -1
  93. package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mts +5 -0
  94. package/src/sync/sync-peer/sync-peer-v1.mts +63 -25
  95. package/src/sync/sync-saga-context/sync-saga-context-helpers.mts +52 -4
  96. package/src/sync/sync-saga-context/sync-saga-context-types.mts +17 -0
  97. package/src/sync/sync-saga-coordinator.mts +295 -62
  98. package/src/sync/sync-types.mts +1 -1
@@ -31,11 +31,13 @@ export class KeystoneService_V1 {
31
31
  */
32
32
  async genesis({
33
33
  masterSecret,
34
+ frameDetails,
34
35
  configs,
35
36
  metaspace,
36
37
  space,
37
38
  }: {
38
39
  masterSecret: string;
40
+ frameDetails?: any;
39
41
  configs: KeystonePoolConfig[];
40
42
  metaspace: MetaspaceService;
41
43
  space: IbGibSpaceAny;
@@ -81,6 +83,7 @@ export class KeystoneService_V1 {
81
83
  if (challengePools.length === 0) { throw new Error(`No challenge pools created. (E: 38e538530996940e1f16a8b199995825)`); }
82
84
 
83
85
  const data: KeystoneData_V1 = { challengePools, proofs: [] };
86
+ if (frameDetails) { data.frameDetails = frameDetails; }
84
87
  const keystoneIbGib = await createKeystoneIbGibImpl({ data, metaspace, space });
85
88
  return keystoneIbGib;
86
89
  } catch (error) {
@@ -97,6 +100,8 @@ export class KeystoneService_V1 {
97
100
  * Uses a hybrid selection strategy: Mandatory IDs (Alice) + Sequential (FIFO) + Random (Stochastic).
98
101
  *
99
102
  * Supports Delegation via `poolFilter` to find specific foreign pools.
103
+ *
104
+ * todo: wrap this and other entire keystone sign/method implementations in locks on the keystone's tjpGib.
100
105
  */
101
106
  async sign({
102
107
  latestKeystone,
@@ -203,7 +203,7 @@ await respecfully(sir, 'Suite A: Strategy Vectors (HashRevealV1)', async () => {
203
203
 
204
204
  await respecfully(sir, 'Derivation Logic', async () => {
205
205
 
206
- await ifWeMight(sir, 'derivePoolSecret with same inputs returns same output', async () => {
206
+ await ifWe(sir, 'derivePoolSecret with same inputs returns same output', async () => {
207
207
  const strategy = KeystoneStrategyFactory.create({ config });
208
208
 
209
209
  const secretA = await strategy.derivePoolSecret({ masterSecret });
@@ -213,7 +213,7 @@ await respecfully(sir, 'Suite A: Strategy Vectors (HashRevealV1)', async () => {
213
213
  iReckon(sir, secretA).asTo('secret length').isGonnaBeTruthy();
214
214
  });
215
215
 
216
- await ifWeMight(sir, 'derivePoolSecret with different master secret returns different output', async () => {
216
+ await ifWe(sir, 'derivePoolSecret with different master secret returns different output', async () => {
217
217
  const strategy = KeystoneStrategyFactory.create({ config });
218
218
 
219
219
  const secretA = await strategy.derivePoolSecret({ masterSecret });
@@ -222,7 +222,7 @@ await respecfully(sir, 'Suite A: Strategy Vectors (HashRevealV1)', async () => {
222
222
  iReckon(sir, secretA).asTo('secrets differ').not.willEqual(secretB);
223
223
  });
224
224
 
225
- await ifWeMight(sir, 'derivePoolSecret with different salt returns different output', async () => {
225
+ await ifWe(sir, 'derivePoolSecret with different salt returns different output', async () => {
226
226
  // Modify salt in a copy of config
227
227
  const configB = { ...config, salt: "OtherPool" };
228
228
  const strategyA = KeystoneStrategyFactory.create({ config });
@@ -237,7 +237,7 @@ await respecfully(sir, 'Suite A: Strategy Vectors (HashRevealV1)', async () => {
237
237
 
238
238
  await respecfully(sir, 'Challenge/Solution Logic', async () => {
239
239
 
240
- await ifWeMight(sir, 'generateSolution -> generateChallenge -> validateSolution loop works', async () => {
240
+ await ifWe(sir, 'generateSolution -> generateChallenge -> validateSolution loop works', async () => {
241
241
  const strategy = KeystoneStrategyFactory.create({ config });
242
242
  const poolSecret = await strategy.derivePoolSecret({ masterSecret });
243
243
  const challengeId = "a3ff7843552870fc28bef2b"; // arbitrary random challengeId
@@ -256,7 +256,7 @@ await respecfully(sir, 'Suite A: Strategy Vectors (HashRevealV1)', async () => {
256
256
  iReckon(sir, isValid).asTo('valid pair should pass').isGonnaBeTrue();
257
257
  });
258
258
 
259
- await ifWeMight(sir, 'validateSolution fails for mismatched values', async () => {
259
+ await ifWe(sir, 'validateSolution fails for mismatched values', async () => {
260
260
  const strategy = KeystoneStrategyFactory.create({ config });
261
261
  const poolSecret = await strategy.derivePoolSecret({ masterSecret });
262
262
  const challengeId = "8c994f3ed598f150e25513"; // arbitrary random challengeId
@@ -272,7 +272,7 @@ await respecfully(sir, 'Suite A: Strategy Vectors (HashRevealV1)', async () => {
272
272
  iReckon(sir, isValid).asTo('tampered solution should fail').isGonnaBeFalse();
273
273
  });
274
274
 
275
- await ifWeMight(sir, 'validateSolution fails for mismatched challenge hashes', async () => {
275
+ await ifWe(sir, 'validateSolution fails for mismatched challenge hashes', async () => {
276
276
  const strategy = KeystoneStrategyFactory.create({ config });
277
277
  const poolSecret = await strategy.derivePoolSecret({ masterSecret });
278
278
 
@@ -313,7 +313,7 @@ await respecfully(sir, 'Suite B: Service Lifecycle', async () => {
313
313
  });
314
314
 
315
315
  await respecfully(sir, 'Genesis', async () => {
316
- await ifWeMight(sir, 'creates a valid genesis frame and persists it', async () => {
316
+ await ifWe(sir, 'creates a valid genesis frame and persists it', async () => {
317
317
  const config = createStandardPoolConfig({
318
318
  id: POOL_ID_DEFAULT,
319
319
  salt: POOL_ID_DEFAULT,
@@ -344,7 +344,7 @@ await respecfully(sir, 'Suite B: Service Lifecycle', async () => {
344
344
  });
345
345
 
346
346
  await respecfully(sir, 'Signing (Evolution)', async () => {
347
- await ifWeMight(sir, 'evolves the keystone with a valid proof', async () => {
347
+ await ifWe(sir, 'evolves the keystone with a valid proof', async () => {
348
348
  const claim: Partial<KeystoneClaim> = {
349
349
  target: "comment 123^gib",
350
350
  verb: "post"
@@ -374,7 +374,7 @@ await respecfully(sir, 'Suite B: Service Lifecycle', async () => {
374
374
  });
375
375
 
376
376
  await respecfully(sir, 'Validation', async () => {
377
- await ifWeMight(sir, 'validates the genesis->signed transition', async () => {
377
+ await ifWe(sir, 'validates the genesis->signed transition', async () => {
378
378
  const errors = await service.validate({
379
379
  prevIbGib: genesisKeystone,
380
380
  currentIbGib: signedKeystone,
@@ -422,7 +422,7 @@ await respecfully(sir, 'Suite C: Security Vectors', async () => {
422
422
  });
423
423
 
424
424
  await respecfully(sir, 'Wrong Secret (Forgery)', async () => {
425
- await ifWeMight(sir, 'prevents creation of forged frames', async () => {
425
+ await ifWe(sir, 'prevents creation of forged frames', async () => {
426
426
  const claim: Partial<KeystoneClaim> = { target: "comment 123^gib", verb: "post" };
427
427
 
428
428
  let errorCaught = false;
@@ -451,7 +451,7 @@ await respecfully(sir, 'Suite C: Security Vectors', async () => {
451
451
  });
452
452
 
453
453
  await respecfully(sir, 'Policy Violation (Restricted Verbs)', async () => {
454
- await ifWeMight(sir, 'throws error if signing forbidden verb with restricted pool', async () => {
454
+ await ifWe(sir, 'throws error if signing forbidden verb with restricted pool', async () => {
455
455
  // Create a specific restricted pool config manually
456
456
  const restrictedPoolId = "read_only_pool";
457
457
  const restrictedConfig = createStandardPoolConfig({
@@ -529,7 +529,7 @@ await respecfully(sir, 'Suite D: Revocation', async () => {
529
529
  await respecfully(sir, 'Revoke Lifecycle', async () => {
530
530
  let revokedKeystone: KeystoneIbGib_V1;
531
531
 
532
- await ifWeMight(sir, 'successfully creates a revocation frame', async () => {
532
+ await ifWe(sir, 'successfully creates a revocation frame', async () => {
533
533
  revokedKeystone = await service.revoke({
534
534
  latestKeystone: genesisKeystone,
535
535
  masterSecret,
@@ -547,7 +547,7 @@ await respecfully(sir, 'Suite D: Revocation', async () => {
547
547
  iReckon(sir, data.revocationInfo!.proof.claim.verb).willEqual(KEYSTONE_VERB_REVOKE);
548
548
  });
549
549
 
550
- await ifWeMight(sir, 'validates the revocation frame', async () => {
550
+ await ifWe(sir, 'validates the revocation frame', async () => {
551
551
  const errors = await service.validate({
552
552
  prevIbGib: genesisKeystone,
553
553
  currentIbGib: revokedKeystone!,
@@ -558,7 +558,7 @@ await respecfully(sir, 'Suite D: Revocation', async () => {
558
558
  iReckon(sir, errors.length).asTo('no validation errors').willEqual(0);
559
559
  });
560
560
 
561
- await ifWeMight(sir, 'consumed the revocation pool (Scorched Earth)', async () => {
561
+ await ifWe(sir, 'consumed the revocation pool (Scorched Earth)', async () => {
562
562
  const data = revokedKeystone!.data!;
563
563
  const revokePool = data.challengePools.find(p => p.id === POOL_ID_REVOKE);
564
564
 
@@ -635,7 +635,7 @@ await respecfully(sir, 'Suite E: Structural Evolution (addPools)', async () => {
635
635
  });
636
636
 
637
637
  await respecfully(sir, 'Happy Path', async () => {
638
- await ifWeMight(sir, 'authorizes and adds a foreign pool', async () => {
638
+ await ifWe(sir, 'authorizes and adds a foreign pool', async () => {
639
639
  const bobPool = await createForeignPool("pool_bob", ["post"]);
640
640
 
641
641
  const updatedKeystone = await service.addPools({
@@ -674,7 +674,7 @@ await respecfully(sir, 'Suite E: Structural Evolution (addPools)', async () => {
674
674
  });
675
675
 
676
676
  await respecfully(sir, 'Permissions & Logic', async () => {
677
- await ifWeMight(sir, 'fails if no pool allows "manage" verb', async () => {
677
+ await ifWe(sir, 'fails if no pool allows "manage" verb', async () => {
678
678
  // 1. Create a restricted keystone
679
679
  let id = "read_only";
680
680
  const restrictedConfig = createStandardPoolConfig({ id, salt: id });
@@ -707,7 +707,7 @@ await respecfully(sir, 'Suite E: Structural Evolution (addPools)', async () => {
707
707
  iReckon(sir, errorCaught).asTo('permission denied').isGonnaBeTrue();
708
708
  });
709
709
 
710
- await ifWeMight(sir, 'fails on ID collision', async () => {
710
+ await ifWe(sir, 'fails on ID collision', async () => {
711
711
  // Try to add "pool_bob" again (it was added in Happy Path)
712
712
  const duplicatePool = await createForeignPool("pool_bob");
713
713
 
@@ -796,7 +796,7 @@ await respecfully(sir, 'Suite E: Structural Evolution (addPools)', async () => {
796
796
  });
797
797
 
798
798
  await respecfully(sir, 'Happy Path', async () => {
799
- await ifWeMight(sir, 'authorizes and adds a foreign pool', async () => {
799
+ await ifWe(sir, 'authorizes and adds a foreign pool', async () => {
800
800
  const bobPool = await createForeignPool("pool_bob", ["post"]);
801
801
 
802
802
  const updatedKeystone = await service.addPools({
@@ -835,7 +835,7 @@ await respecfully(sir, 'Suite E: Structural Evolution (addPools)', async () => {
835
835
  });
836
836
 
837
837
  await respecfully(sir, 'Permissions & Logic', async () => {
838
- await ifWeMight(sir, 'fails if no pool allows "manage" verb', async () => {
838
+ await ifWe(sir, 'fails if no pool allows "manage" verb', async () => {
839
839
  // 1. Create a restricted keystone (read-only)
840
840
  let id = "read_only";
841
841
  const restrictedConfig = createStandardPoolConfig({ id, salt: id });
@@ -868,7 +868,7 @@ await respecfully(sir, 'Suite E: Structural Evolution (addPools)', async () => {
868
868
  iReckon(sir, errorCaught).asTo('permission denied').isGonnaBeTrue();
869
869
  });
870
870
 
871
- await ifWeMight(sir, 'fails on ID collision', async () => {
871
+ await ifWe(sir, 'fails on ID collision', async () => {
872
872
  // Try to add "pool_bob" again (it was added in Happy Path)
873
873
  const duplicatePool = await createForeignPool("pool_bob");
874
874
 
@@ -930,7 +930,7 @@ await respecfully(sir, 'Suite F: Deep Inspection', async () => {
930
930
 
931
931
  await respecfully(sir, 'Proof Granularity & Math', async () => {
932
932
 
933
- await ifWeMight(sir, 'generates exactly the expected number of solutions', async () => {
933
+ await ifWe(sir, 'generates exactly the expected number of solutions', async () => {
934
934
  signedKeystone = await service.sign({
935
935
  latestKeystone: genesisKeystone,
936
936
  masterSecret: aliceSecret,
@@ -947,7 +947,7 @@ await respecfully(sir, 'Suite F: Deep Inspection', async () => {
947
947
  iReckon(sir, solutions.length).asTo('solution count').willEqual(4);
948
948
  });
949
949
 
950
- await ifWeMight(sir, 'verifies the math manually (White-box Crypto Check)', async () => {
950
+ await ifWe(sir, 'verifies the math manually (White-box Crypto Check)', async () => {
951
951
  const proof = signedKeystone.data!.proofs[0];
952
952
  const poolSnapshot = genesisKeystone.data!.challengePools.find(p => p.id === salt)!;
953
953
 
@@ -976,7 +976,7 @@ await respecfully(sir, 'Suite F: Deep Inspection', async () => {
976
976
  }
977
977
  });
978
978
 
979
- await ifWeMight(sir, 'verifies FIFO logic (Deterministic Selection)', async () => {
979
+ await ifWe(sir, 'verifies FIFO logic (Deterministic Selection)', async () => {
980
980
  const proof = signedKeystone.data!.proofs[0];
981
981
  const poolSnapshot = genesisKeystone.data!.challengePools.find(p => p.id === salt)!;
982
982
 
@@ -998,7 +998,7 @@ await respecfully(sir, 'Suite F: Deep Inspection', async () => {
998
998
 
999
999
  await respecfully(sir, 'DTO & Serialization', async () => {
1000
1000
 
1001
- await ifWeMight(sir, 'survives a clone/JSON-cycle without corruption', async () => {
1001
+ await ifWe(sir, 'survives a clone/JSON-cycle without corruption', async () => {
1002
1002
  // 1. Create a DTO (simulate network transmission/storage)
1003
1003
  // 'clone' does a JSON stringify/parse under the hood (usually) or structured clone.
1004
1004
  const dto = clone(signedKeystone);
@@ -1018,7 +1018,7 @@ await respecfully(sir, 'Suite F: Deep Inspection', async () => {
1018
1018
  iReckon(sir, errors.length).asTo('DTO validation errors').willEqual(0);
1019
1019
  });
1020
1020
 
1021
- await ifWeMight(sir, 'ensures data contains no functions or circular refs', async () => {
1021
+ await ifWe(sir, 'ensures data contains no functions or circular refs', async () => {
1022
1022
  // A crude but effective test: ensure JSON.stringify doesn't throw
1023
1023
  // and the result is equal to the object (if we parsed it back).
1024
1024
 
@@ -1,6 +1,9 @@
1
+ import { HashAlgorithm } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
2
+ import { IbGibAddr } from "@ibgib/ts-gib/dist/types.mjs";
1
3
  import { IbGib_V1, IbGibData_V1, IbGibRel8ns_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
2
4
 
3
5
  import { KEYSTONE_ATOM } from "./keystone-constants.mjs";
6
+ import type { KeystoneVerb } from "./keystone-constants.mjs";
4
7
 
5
8
  // #region KeystoneChallengeType
6
9
  export const KEYSTONE_CHALLENGE_TYPE_HASH_REVEAL_V1 = 'hash-reveal-v1';
@@ -140,8 +143,8 @@ export interface KeystonePoolConfigBase {
140
143
  }
141
144
 
142
145
  export interface KeystonePoolConfig_HashV1 extends KeystonePoolConfigBase {
143
- type: 'hash-reveal-v1';
144
- algo: 'SHA-256' | 'SHA-512';
146
+ type: typeof KeystoneChallengeType.hash_reveal_v1;
147
+ algo: HashAlgorithm;
145
148
  rounds: number;
146
149
  }
147
150
 
@@ -157,7 +160,7 @@ export interface KeystoneChallengeBase {
157
160
 
158
161
  export interface KeystoneChallenge_HashV1 extends KeystoneChallengeBase {
159
162
  id: string;
160
- type: 'hash-reveal-v1';
163
+ type: typeof KeystoneChallengeType.hash_reveal_v1;
161
164
  /**
162
165
  * The hash that must be matched by the solution.
163
166
  */
@@ -258,12 +261,29 @@ export interface KeystoneChallengePool {
258
261
  }
259
262
 
260
263
  /**
261
- * Semantic intent.
264
+ * Describes the specific privilege that the evolution of the keystone
265
+ * authorizes.
262
266
  */
263
267
  export interface KeystoneClaim {
264
- target: string; // ibGib address
265
- verb: string; // ibGib address (primitive)
266
- scope?: string; // ibGib address (primitive)
268
+ /**
269
+ * what action/ability does the claim make?
270
+ *
271
+ * @see {@link KeystoneVerb} and all of its members for just a list of some
272
+ * common verbs. But really, this can be any string.
273
+ */
274
+ verb: string;
275
+ /**
276
+ * What specific ibgib does this claim relate to?
277
+ *
278
+ * For example, if we are signing a keystone to witness some specific ibgib
279
+ * itself, similar to the most conventional use of digital signatures, then
280
+ * this will be the address of that ibgib.
281
+ */
282
+ target: IbGibAddr;
283
+ /**
284
+ * What limitations are narrowed down to beyond just target + verb?
285
+ */
286
+ scope?: string;
267
287
  }
268
288
 
269
289
  /**
@@ -85,7 +85,7 @@ await respecfully(sir, `Multi-round/timeline permutations`, async () => {
85
85
  async function newTestPeer(): Promise<SyncPeerInnerspace_V1> {
86
86
  const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
87
87
  await peer.initialized;
88
- await peer.initializeSender({
88
+ await peer.initializeOpts({
89
89
  senderSpace: sourceSpace,
90
90
  receiverSpace: destSpace,
91
91
  receiverCoordinator: receiverCoordinator,
@@ -221,7 +221,7 @@ await respecfully(sir, `Two different fields`, async () => {
221
221
 
222
222
  const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
223
223
  await peer.initialized;
224
- await peer.initializeSender({
224
+ await peer.initializeOpts({
225
225
  senderSpace: sourceSpace, // "Client"
226
226
  receiverSpace: destSpace, // "Server"
227
227
  receiverCoordinator,
@@ -207,7 +207,7 @@ await respecfully(sir, `Two different fields and rel8d`, async () => {
207
207
 
208
208
  const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
209
209
  await peer.initialized;
210
- await peer.initializeSender({
210
+ await peer.initializeOpts({
211
211
  senderSpace: sourceSpace, // "Client"
212
212
  receiverSpace: destSpace, // "Server"
213
213
  receiverCoordinator,
@@ -87,7 +87,7 @@ await respecfully(sir, `Text merge (LCS) conflict resolution`, async () => {
87
87
  async function newTestPeer(): Promise<SyncPeerInnerspace_V1> {
88
88
  const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
89
89
  await peer.initialized;
90
- await peer.initializeSender({
90
+ await peer.initializeOpts({
91
91
  senderSpace: sourceSpace,
92
92
  receiverSpace: destSpace,
93
93
  receiverCoordinator: receiverCoordinator,
@@ -1,4 +1,7 @@
1
+ import { HashAlgorithm } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
1
2
  import { ROOT_ADDR } from "@ibgib/ts-gib/dist/V1/constants.mjs";
3
+ import { KeystoneReplenishStrategy } from "../keystone/keystone-types.mjs";
4
+ import { KEYSTONE_VERB_MANAGE, KEYSTONE_VERB_SIGN, POOL_ID_DEFAULT, POOL_ID_DELEGATE, POOL_ID_TRANSITION } from "../keystone/keystone-constants.mjs";
2
5
 
3
6
  export const SYNC_ATOM = "sync";
4
7
 
@@ -78,6 +81,18 @@ export function isValidSyncConflictStrategy(strategy: string): strategy is SyncC
78
81
  }
79
82
  // #endregion SyncConflictStrategy
80
83
 
84
+ /**
85
+ * to be used by the sender
86
+ */
87
+ export const SESSION_IDENTITY_KEYSTONE_PRIMARY_POOL_ID = POOL_ID_DEFAULT;
88
+ /**
89
+ * single use pool
90
+ */
91
+ export const SESSION_IDENTITY_KEYSTONE_TRANSITION_POOL_ID = POOL_ID_TRANSITION;
92
+ /**
93
+ * to be used by the receiver, created via the single-use transition pool.
94
+ */
95
+ export const SESSION_IDENTITY_KEYSTONE_DELEGATE_POOL_ID = POOL_ID_DELEGATE;
81
96
  /**
82
97
  * When synchronizing, the plan for identity integration is to create a session
83
98
  * keystone. This keystone will have a primary pool, driven by the sender's
@@ -86,4 +101,39 @@ export function isValidSyncConflictStrategy(strategy: string): strategy is SyncC
86
101
  * use this to then change the keystone to use a secret chosen by the
87
102
  * receiver's end.
88
103
  */
89
- export const DEFAULT_SESSION_IDENTITY_INITIAL_DELEGATE_SECRET = ROOT_ADDR;
104
+ export const SESSION_IDENTITY_KEYSTONE_SECRET_TRANSITIONPOOL = ROOT_ADDR;
105
+
106
+ /**
107
+ * has to be big enough to avoid our currently poor (atow 02/24/2026)
108
+ * implementation of the binding target.
109
+ */
110
+ export const SESSION_IDENTITY_KEYSTONE_CONFIG_SIZE = 100;
111
+ export const SESSION_IDENTITY_KEYSTONE_CONFIG_ALGO = HashAlgorithm.sha_256;
112
+ export const SESSION_IDENTITY_KEYSTONE_CONFIG_ROUNDS = 3;
113
+ export const SESSION_IDENTITY_KEYSTONE_CONFIG_RANDOM = 2;
114
+ export const SESSION_IDENTITY_KEYSTONE_CONFIG_SEQUENTIAL = 2;
115
+ export const SESSION_IDENTITY_KEYSTONE_CONFIG_TARGET_BINDING = 4;
116
+ export const SESSION_IDENTITY_KEYSTONE_CONFIG_REPLENISH_STRATEGY = KeystoneReplenishStrategy.topUp;
117
+ /**
118
+ * verbs associated with primary/sender participant.
119
+ *
120
+ * todo: would be slightly cleaner to have the sender/primary genesis with two pools, one for signing and one being one-time manage use (to add the transition pool) just like the transition pool, but this is a finesse and not for V1. Still it is neat that this possibility/mechanism exists.
121
+ */
122
+ export const SESSION_IDENTITY_KEYSTONE_CONFIG_VERBS_PRIMARY = [KEYSTONE_VERB_MANAGE];
123
+ export const SESSION_IDENTITY_KEYSTONE_CONFIG_VERBS_DELEGATE = [KEYSTONE_VERB_SIGN];
124
+
125
+ /**
126
+ * transition pool is purposefully weak with a known password.
127
+ */
128
+ export const SESSION_IDENTITY_KEYSTONE_CONFIG_SIZE_TRANSITIONPOOL = 1;
129
+ export const SESSION_IDENTITY_KEYSTONE_CONFIG_ALGO_TRANSITIONPOOL = HashAlgorithm.sha_256;
130
+ export const SESSION_IDENTITY_KEYSTONE_CONFIG_ROUNDS_TRANSITIONPOOL = 1;
131
+ export const SESSION_IDENTITY_KEYSTONE_CONFIG_RANDOM_TRANSITIONPOOL = 0;
132
+ export const SESSION_IDENTITY_KEYSTONE_CONFIG_SEQUENTIAL_TRANSITIONPOOL = 1;
133
+ export const SESSION_IDENTITY_KEYSTONE_CONFIG_TARGET_BINDING_TRANSITIONPOOL = 0;
134
+ /**
135
+ * This pool is to be used only once, by the receiver, in order for the receiver
136
+ * to create their own pool.
137
+ */
138
+ export const SESSION_IDENTITY_KEYSTONE_CONFIG_REPLENISH_STRATEGY_TRANSITIONPOOL = KeystoneReplenishStrategy.deleteAll;
139
+ export const SESSION_IDENTITY_KEYSTONE_CONFIG_VERBS_TRANSITIONPOOL = [KEYSTONE_VERB_MANAGE];
@@ -72,7 +72,7 @@ await respecfully(sir, `Sync Constants (No TJP)`, async () => {
72
72
 
73
73
  const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
74
74
  await peer.initialized;
75
- await peer.initializeSender({
75
+ await peer.initializeOpts({
76
76
  senderSpace: sourceSpace, // "Client"
77
77
  receiverSpace: destSpace, // "Server"
78
78
  receiverCoordinator,
@@ -103,7 +103,7 @@ await respecfully(sir, `Sync InnerSpaces (Deep Updates)`, async () => {
103
103
 
104
104
  const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
105
105
  await peer.initialized;
106
- await peer.initializeSender({
106
+ await peer.initializeOpts({
107
107
  senderSpace: sourceSpace, // "Client"
108
108
  receiverSpace: destSpace, // "Server"
109
109
  receiverCoordinator,
@@ -29,6 +29,8 @@ import { ErrorIbGib_V1 } from '../common/error/error-types.mjs';
29
29
  import { SyncIbGib_V1 } from './sync-types.mjs';
30
30
  import { getFullSyncSagaHistory } from './sync-helpers.mjs';
31
31
  import { getIbGibsFromCache_fallbackToSpaces } from '../common/other/ibgib-helper.mjs';
32
+ import { SyncSagaContextIbGib_V1 } from './sync-saga-context/sync-saga-context-types.mjs';
33
+ import { isSyncSagaContextIbGib } from './sync-saga-context/sync-saga-context-helpers.mjs';
32
34
 
33
35
  const logalot = false;
34
36
  const lc = `[sync-innerspace-dest-ahead.respec]`;
@@ -38,6 +40,9 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
38
40
  let metaspace: Metaspace_Innerspace;
39
41
  let sourceSpace: InnerSpace_V1;
40
42
  let destSpace: InnerSpace_V1;
43
+ let secretSender = 'secret for sender';
44
+ let secretReceiver = 'secret for receiver';
45
+ let secretAdversary = 'secret for adversary';
41
46
 
42
47
  interface TestData {
43
48
  type: string;
@@ -119,7 +124,7 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
119
124
  return resGet.success && resGet.ibGibs && resGet.ibGibs.length === 1;
120
125
  }
121
126
 
122
- await ifWe(sir, 'verify setup', async () => {
127
+ await ifWeMight(sir, 'verify setup', async () => {
123
128
  // Ensure V2 is ONLY in Dest (it is, per `space: destSpace`)
124
129
  // Ensure Source does NOT have V2
125
130
  iReckon(sir, await fnAddrExistsInSpace(addrV0, sourceSpace)).asTo('source has V0').isGonnaBeTrue();
@@ -137,7 +142,7 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
137
142
 
138
143
  const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
139
144
  await peer.initialized;
140
- await peer.initializeSender({
145
+ await peer.initializeOpts({
141
146
  senderSpace: sourceSpace, // "Client"
142
147
  receiverSpace: destSpace, // "Server"
143
148
  receiverCoordinator,
@@ -152,8 +157,10 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
152
157
  metaspace: metaspace,
153
158
  domainIbGibs: [v1], // Source tries to push V1
154
159
  useSessionIdentity: true,
160
+ identitySecret: secretSender,
155
161
  });
156
162
 
163
+ const syncSagaContextIbGibs: SyncSagaContextIbGib_V1[] = [];
157
164
  const sublc = `${lc}[updates$]`;
158
165
  /**
159
166
  * I have added this so you can see how to subscribe to an ibgib
@@ -163,6 +170,11 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
163
170
  next: async (ctxIbGib) => {
164
171
  // console.log(`${sublc} next fired. ${JSON.stringify(ctxIbGib)}`);
165
172
  console.log(`${sublc} next fired. (I: e68d8894bac8800f9f3430e8a38d6626)`);
173
+ // each context ibgib
174
+ if (!isSyncSagaContextIbGib(ctxIbGib)) {
175
+ throw new Error(`(UNEXPECTED) ctxIbGib isn't a SyncSagaContextIbGib_V1? (E: ee116e6b6208e615dbcd3e715643e826)`);
176
+ }
177
+ syncSagaContextIbGibs.push(ctxIbGib);
166
178
  },
167
179
  error: async (e: ErrorIbGib_V1) => {
168
180
  if (e.data) {
@@ -178,17 +190,10 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
178
190
  }));
179
191
  await done;
180
192
 
181
- // TODO: Get saga IbGib to access session keystones
182
- // Bill suggested either:
183
- // 1. Subscribe to updates$ to inspect frames as sync progresses
184
- // 2. Change done from Promise<void> to Promise<IbGibAddr>, return saga addr,
185
- // then use getIbGibsFromCache_fallbackToSpaces and getFullSyncSagaHistory
186
- // For now, leaving implementation for next step.
187
-
188
193
  // 5. Verify Sync (v2 should be in both source and dest now)
189
194
  console.log(`${lc} Verifying Sync...`);
190
195
 
191
- await ifWe(sir, `verify v2 now also in source`, async () => {
196
+ await ifWeMight(sir, `verify v2 now also in source`, async () => {
192
197
  // Verify Tip (V2)
193
198
 
194
199
  iReckon(sir, await fnAddrExistsInSpace(addrV0, sourceSpace)).asTo('source has V0').isGonnaBeTrue();
@@ -200,7 +205,7 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
200
205
 
201
206
  });
202
207
 
203
- await ifWe(sir, `dependency graphs the same`, async () => {
208
+ await ifWeMight(sir, `dependency graphs the same`, async () => {
204
209
 
205
210
  const sourceDepGraph = await getDependencyGraph({
206
211
  ibGibAddr: addrV2,
@@ -229,11 +234,23 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
229
234
  // For now, we'll retrieve from spaces after sync completes
230
235
  let sessionKeystoneAddr: IbGibAddr | undefined;
231
236
 
232
- await ifWe(sir, 'IDENTITY: session keystone exists in sender space', async () => {
237
+ await ifWeMight(sir, 'IDENTITY: session keystone exists in sender space', async () => {
233
238
  // TODO: Get saga IbGib and access sessionKeystones rel8n
234
239
  // Once saga access is implemented (per Bill's guidance), retrieve keystone addr from:
235
240
  // const keystoneAddrs = sagaIbGib.rel8ns?.sessionKeystones;
236
241
  // Then verify keystone exists in space
242
+ debugger;
243
+
244
+ // #region leaving off here
245
+
246
+ // receiver is not putting the session keystone on the return
247
+ // context ibgib. need to ensure that peer's do the most recent
248
+ // session keystone manually, so session keystone should be
249
+ // transferred alongside context ibgib (which is signed but
250
+ // intrinsically points to the **previous** frame of the keystone)
251
+
252
+ // #endregion leaving off here
253
+ syncSagaContextIbGibs.forEach(x => console.log(pretty(x)));
237
254
 
238
255
  // Placeholder - test passes because keystone creation works
239
256
  iReckon(sir, true)
@@ -241,7 +258,7 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
241
258
  .isGonnaBeTrue();
242
259
  });
243
260
 
244
- await ifWe(sir, 'IDENTITY: session keystone exists in receiver space', async () => {
261
+ await ifWeMight(sir, 'IDENTITY: session keystone exists in receiver space', async () => {
245
262
  // Session keystone should be transferred to receiver's durable space
246
263
  iReckon(sir, sessionKeystoneAddr)
247
264
  .asTo('session keystone address was captured')
@@ -255,7 +272,7 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
255
272
  }
256
273
  });
257
274
 
258
- await ifWe(sir, 'IDENTITY: saga frames are signed', async () => {
275
+ await ifWeMight(sir, 'IDENTITY: saga frames are signed', async () => {
259
276
  // TODO: Get saga frames and check each has a proof
260
277
  // This will FAIL when we actually check - that's the point (TDD RED)
261
278
 
@@ -264,7 +281,7 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
264
281
  .isGonnaBeTrue();
265
282
  });
266
283
 
267
- await ifWe(sir, 'IDENTITY: frame signatures are valid', async () => {
284
+ await ifWeMight(sir, 'IDENTITY: frame signatures are valid', async () => {
268
285
  // TODO: For each saga frame, validate proof against session keystone
269
286
  // const isValid = await validateProofWithKeystone({
270
287
  // proof: frame.proof,
@@ -279,7 +296,7 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
279
296
  .isGonnaBeTrue();
280
297
  });
281
298
 
282
- await ifWe(sir, 'IDENTITY: session keystone challenges are depleted', async () => {
299
+ await ifWeMight(sir, 'IDENTITY: session keystone challenges are depleted', async () => {
283
300
  // TODO: Session keystone should evolve after signing frames
284
301
  // This will FAIL because keystone evolution not implemented yet
285
302
 
@@ -288,7 +305,7 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
288
305
  .isGonnaBeTrue();
289
306
  });
290
307
 
291
- await ifWe(sir, 'IDENTITY: frame timestamps are present and fresh', async () => {
308
+ await ifWeMight(sir, 'IDENTITY: frame timestamps are present and fresh', async () => {
292
309
  // TODO: Check each frame has timestamp in proof claim
293
310
  // const claim = JSON.parse(frame.proof.claim.scope);
294
311
  // iReckon(sir, claim.timestamp).asTo('has timestamp').isGonnaBeTruthy();
@@ -301,7 +318,7 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
301
318
  .isGonnaBeTrue();
302
319
  });
303
320
 
304
- await ifWe(sir, 'IDENTITY: keystone has no hard links to domain ibgibs', async () => {
321
+ await ifWeMight(sir, 'IDENTITY: keystone has no hard links to domain ibgibs', async () => {
305
322
  if (sessionKeystoneAddr) {
306
323
  const keystoneResult = await getFromSpace({
307
324
  addr: sessionKeystoneAddr,
@@ -326,7 +343,7 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
326
343
  }
327
344
  });
328
345
 
329
- await ifWe(sir, 'IDENTITY: saga frames have no hard links to domain ibgibs', async () => {
346
+ await ifWeMight(sir, 'IDENTITY: saga frames have no hard links to domain ibgibs', async () => {
330
347
  // Saga frames should NOT have hard links to domain ibgibs
331
348
  // This currently PASSES but will expose issues if hard links exist
332
349
 
@@ -134,7 +134,7 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
134
134
 
135
135
  const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
136
136
  await peer.initialized;
137
- await peer.initializeSender({
137
+ await peer.initializeOpts({
138
138
  senderSpace: sourceSpace, // "Client"
139
139
  receiverSpace: destSpace, // "Server"
140
140
  receiverCoordinator,
@@ -107,7 +107,7 @@ await respecfully(sir, `Sync InnerSpaces (Multiple Timelines)`, async () => {
107
107
 
108
108
  const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
109
109
  await peer.initialized;
110
- await peer.initializeSender({
110
+ await peer.initializeOpts({
111
111
  senderSpace: sourceSpace, // "Client"
112
112
  receiverSpace: destSpace, // "Server"
113
113
  receiverCoordinator,
@@ -115,7 +115,7 @@ await respecfully(sir, `Sync InnerSpaces (Partial Update)`, async () => {
115
115
 
116
116
  const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
117
117
  await peer.initialized;
118
- await peer.initializeSender({
118
+ await peer.initializeOpts({
119
119
  senderSpace: sourceSpace, // "Client"
120
120
  receiverSpace: destSpace, // "Server"
121
121
  receiverCoordinator,
@@ -107,7 +107,7 @@ await respecfully(sir, `Sync InnerSpaces`, async () => {
107
107
  // Peer (The "Network")
108
108
  const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
109
109
  await peer.initialized;
110
- await peer.initializeSender({
110
+ await peer.initializeOpts({
111
111
  senderSpace: sourceSpace, // "Client"
112
112
  receiverSpace: destSpace, // "Server"
113
113
  receiverCoordinator,