@ibgib/core-gib 0.1.54 → 0.1.55

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 (189) hide show
  1. package/CHANGELOG.md +10 -3
  2. package/README.md +12 -15
  3. package/dist/keystone/aggregate-details.respec.d.mts +2 -0
  4. package/dist/keystone/aggregate-details.respec.d.mts.map +1 -0
  5. package/dist/keystone/aggregate-details.respec.mjs +118 -0
  6. package/dist/keystone/aggregate-details.respec.mjs.map +1 -0
  7. package/dist/keystone/keystone-constants.d.mts +5 -0
  8. package/dist/keystone/keystone-constants.d.mts.map +1 -1
  9. package/dist/keystone/keystone-constants.mjs +6 -1
  10. package/dist/keystone/keystone-constants.mjs.map +1 -1
  11. package/dist/keystone/keystone-helpers.d.mts +7 -1
  12. package/dist/keystone/keystone-helpers.d.mts.map +1 -1
  13. package/dist/keystone/keystone-helpers.mjs +5 -2
  14. package/dist/keystone/keystone-helpers.mjs.map +1 -1
  15. package/dist/keystone/keystone-service-v1.d.mts +51 -0
  16. package/dist/keystone/keystone-service-v1.d.mts.map +1 -1
  17. package/dist/keystone/keystone-service-v1.mjs +176 -9
  18. package/dist/keystone/keystone-service-v1.mjs.map +1 -1
  19. package/dist/keystone/keystone-service-v1.respec.mjs +40 -98
  20. package/dist/keystone/keystone-service-v1.respec.mjs.map +1 -1
  21. package/dist/keystone/keystone-types.d.mts +5 -0
  22. package/dist/keystone/keystone-types.d.mts.map +1 -1
  23. package/dist/sync/graft-info/graft-info-helpers.respec.mjs +8 -8
  24. package/dist/sync/graft-info/graft-info-helpers.respec.mjs.map +1 -1
  25. package/dist/sync/sync-conflict-adv-multitimelines.respec.mjs +26 -30
  26. package/dist/sync/sync-conflict-adv-multitimelines.respec.mjs.map +1 -1
  27. package/dist/sync/sync-conflict-basic-divergence.respec.mjs +7 -8
  28. package/dist/sync/sync-conflict-basic-divergence.respec.mjs.map +1 -1
  29. package/dist/sync/sync-conflict-basic-multitimelines.respec.mjs +10 -11
  30. package/dist/sync/sync-conflict-basic-multitimelines.respec.mjs.map +1 -1
  31. package/dist/sync/sync-conflict-text-merge.respec.mjs +30 -33
  32. package/dist/sync/sync-conflict-text-merge.respec.mjs.map +1 -1
  33. package/dist/sync/sync-constants.d.mts +1 -56
  34. package/dist/sync/sync-constants.d.mts.map +1 -1
  35. package/dist/sync/sync-constants.mjs +2 -59
  36. package/dist/sync/sync-constants.mjs.map +1 -1
  37. package/dist/sync/sync-helpers.d.mts +0 -1
  38. package/dist/sync/sync-helpers.d.mts.map +1 -1
  39. package/dist/sync/sync-helpers.mjs +1 -6
  40. package/dist/sync/sync-helpers.mjs.map +1 -1
  41. package/dist/sync/sync-innerspace-constants.respec.mjs +5 -9
  42. package/dist/sync/sync-innerspace-constants.respec.mjs.map +1 -1
  43. package/dist/sync/sync-innerspace-deep-updates.respec.mjs +6 -7
  44. package/dist/sync/sync-innerspace-deep-updates.respec.mjs.map +1 -1
  45. package/dist/sync/sync-innerspace-dest-ahead-withid.respec.mjs +22 -22
  46. package/dist/sync/sync-innerspace-dest-ahead-withid.respec.mjs.map +1 -1
  47. package/dist/sync/sync-innerspace-dest-ahead.respec.mjs +8 -9
  48. package/dist/sync/sync-innerspace-dest-ahead.respec.mjs.map +1 -1
  49. package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs +6 -7
  50. package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs.map +1 -1
  51. package/dist/sync/sync-innerspace-partial-update.respec.mjs +7 -8
  52. package/dist/sync/sync-innerspace-partial-update.respec.mjs.map +1 -1
  53. package/dist/sync/sync-innerspace.respec.mjs +8 -11
  54. package/dist/sync/sync-innerspace.respec.mjs.map +1 -1
  55. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-http-node-adapter.mjs +10 -5
  56. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-http-node-adapter.mjs.map +1 -1
  57. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-types.d.mts +3 -1
  58. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-types.d.mts.map +1 -1
  59. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-v1.d.mts +4 -2
  60. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-v1.d.mts.map +1 -1
  61. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-v1.mjs +37 -6
  62. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-v1.mjs.map +1 -1
  63. package/dist/sync/sync-peer/sync-peer-http-sender/sync-peer-http-sender-types.d.mts +3 -1
  64. package/dist/sync/sync-peer/sync-peer-http-sender/sync-peer-http-sender-types.d.mts.map +1 -1
  65. package/dist/sync/sync-peer/sync-peer-http-sender/sync-peer-http-sender-v1.d.mts +4 -2
  66. package/dist/sync/sync-peer/sync-peer-http-sender/sync-peer-http-sender-v1.d.mts.map +1 -1
  67. package/dist/sync/sync-peer/sync-peer-http-sender/sync-peer-http-sender-v1.mjs +37 -0
  68. package/dist/sync/sync-peer/sync-peer-http-sender/sync-peer-http-sender-v1.mjs.map +1 -1
  69. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-types.d.mts +7 -1
  70. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-types.d.mts.map +1 -1
  71. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts +10 -2
  72. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts.map +1 -1
  73. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs +50 -38
  74. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs.map +1 -1
  75. package/dist/sync/sync-peer/sync-peer-types.d.mts +21 -5
  76. package/dist/sync/sync-peer/sync-peer-types.d.mts.map +1 -1
  77. package/dist/sync/sync-peer/sync-peer-v1.d.mts +30 -5
  78. package/dist/sync/sync-peer/sync-peer-v1.d.mts.map +1 -1
  79. package/dist/sync/sync-peer/sync-peer-v1.mjs +41 -25
  80. package/dist/sync/sync-peer/sync-peer-v1.mjs.map +1 -1
  81. package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts +2 -11
  82. package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts.map +1 -1
  83. package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs +7 -51
  84. package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs.map +1 -1
  85. package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts +1 -47
  86. package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts.map +1 -1
  87. package/dist/sync/sync-saga-coordinator.d.mts +6 -58
  88. package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
  89. package/dist/sync/sync-saga-coordinator.mjs +23 -425
  90. package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
  91. package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts +2 -2
  92. package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts.map +1 -1
  93. package/dist/sync/sync-types.d.mts +2 -19
  94. package/dist/sync/sync-types.d.mts.map +1 -1
  95. package/dist/sync/sync-types.mjs.map +1 -1
  96. package/dist/test/mock-space.mjs +1 -1
  97. package/dist/test/mock-space.mjs.map +1 -1
  98. package/dist/test-helpers.d.mts +0 -6
  99. package/dist/test-helpers.d.mts.map +1 -1
  100. package/dist/test-helpers.mjs +2 -25
  101. package/dist/test-helpers.mjs.map +1 -1
  102. package/package.json +7 -31
  103. package/src/keystone/aggregate-details.respec.mts +137 -0
  104. package/src/keystone/docs/architecture.md +16 -0
  105. package/src/keystone/keystone-constants.mts +6 -1
  106. package/src/keystone/keystone-helpers.mts +9 -1
  107. package/src/keystone/keystone-service-v1.mts +216 -8
  108. package/src/keystone/keystone-service-v1.respec.mts +39 -103
  109. package/src/keystone/keystone-types.mts +6 -0
  110. package/src/sync/README.md +18 -0
  111. package/src/sync/docs/architecture.md +21 -0
  112. package/src/sync/graft-info/graft-info-helpers.respec.mts +7 -7
  113. package/src/sync/sync-conflict-adv-multitimelines.respec.mts +25 -29
  114. package/src/sync/sync-conflict-basic-divergence.respec.mts +6 -7
  115. package/src/sync/sync-conflict-basic-multitimelines.respec.mts +9 -10
  116. package/src/sync/sync-conflict-text-merge.respec.mts +29 -32
  117. package/src/sync/sync-constants.mts +2 -62
  118. package/src/sync/sync-helpers.mts +1 -8
  119. package/src/sync/sync-id-testlog.txt +421 -0
  120. package/src/sync/sync-innerspace-constants.respec.mts +4 -8
  121. package/src/sync/sync-innerspace-deep-updates.respec.mts +5 -6
  122. package/src/sync/sync-innerspace-dest-ahead-withid.respec.mts +23 -25
  123. package/src/sync/sync-innerspace-dest-ahead.respec.mts +7 -8
  124. package/src/sync/sync-innerspace-multiple-timelines.respec.mts +5 -6
  125. package/src/sync/sync-innerspace-partial-update.respec.mts +6 -7
  126. package/src/sync/sync-innerspace.respec.mts +7 -10
  127. package/src/sync/sync-peer/sync-peer-http-receiver/sync-http-node-adapter.mts +5 -5
  128. package/src/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-types.mts +5 -1
  129. package/src/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-v1.mts +30 -9
  130. package/src/sync/sync-peer/sync-peer-http-sender/sync-peer-http-sender-types.mts +3 -1
  131. package/src/sync/sync-peer/sync-peer-http-sender/sync-peer-http-sender-v1.mts +29 -2
  132. package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-types.mts +7 -1
  133. package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mts +51 -38
  134. package/src/sync/sync-peer/sync-peer-types.mts +23 -6
  135. package/src/sync/sync-peer/sync-peer-v1.mts +68 -28
  136. package/src/sync/sync-saga-context/sync-saga-context-helpers.mts +6 -66
  137. package/src/sync/sync-saga-context/sync-saga-context-types.mts +1 -48
  138. package/src/sync/sync-saga-coordinator.mts +12 -552
  139. package/src/sync/sync-saga-message/sync-saga-message-types.mts +2 -3
  140. package/src/sync/sync-types.mts +2 -22
  141. package/src/sync/unused-identity-backup.mts.md +311 -0
  142. package/src/test/mock-space.mts +1 -1
  143. package/src/test-helpers.mts +1 -26
  144. package/test_output.log +0 -0
  145. package/test_output_utf8.txt +398 -0
  146. package/.vscode/core-gib-snippets.code-snippets +0 -293
  147. package/.vscode/launch.json +0 -40
  148. package/.vscode/settings.json +0 -58
  149. package/.vscode/tasks.json +0 -37
  150. package/dist/sync/sync-peer/sync-peer-http.respec.d.mts +0 -2
  151. package/dist/sync/sync-peer/sync-peer-http.respec.d.mts.map +0 -1
  152. package/dist/sync/sync-peer/sync-peer-http.respec.mjs +0 -340
  153. package/dist/sync/sync-peer/sync-peer-http.respec.mjs.map +0 -1
  154. package/dist/witness/space/filesystem-space/node-filesystem-space/node-filesystem-space-helper.d.mts +0 -42
  155. package/dist/witness/space/filesystem-space/node-filesystem-space/node-filesystem-space-helper.d.mts.map +0 -1
  156. package/dist/witness/space/filesystem-space/node-filesystem-space/node-filesystem-space-helper.mjs +0 -312
  157. package/dist/witness/space/filesystem-space/node-filesystem-space/node-filesystem-space-helper.mjs.map +0 -1
  158. package/dist/witness/space/filesystem-space/node-filesystem-space/node-filesystem-space-types.d.mts +0 -84
  159. package/dist/witness/space/filesystem-space/node-filesystem-space/node-filesystem-space-types.d.mts.map +0 -1
  160. package/dist/witness/space/filesystem-space/node-filesystem-space/node-filesystem-space-types.mjs +0 -65
  161. package/dist/witness/space/filesystem-space/node-filesystem-space/node-filesystem-space-types.mjs.map +0 -1
  162. package/dist/witness/space/filesystem-space/node-filesystem-space/node-filesystem-space-v1.d.mts +0 -73
  163. package/dist/witness/space/filesystem-space/node-filesystem-space/node-filesystem-space-v1.d.mts.map +0 -1
  164. package/dist/witness/space/filesystem-space/node-filesystem-space/node-filesystem-space-v1.mjs +0 -667
  165. package/dist/witness/space/filesystem-space/node-filesystem-space/node-filesystem-space-v1.mjs.map +0 -1
  166. package/dist/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_createAndInit.node-filesystem-space-v1.respec.d.mts +0 -2
  167. package/dist/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_createAndInit.node-filesystem-space-v1.respec.d.mts.map +0 -1
  168. package/dist/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_createAndInit.node-filesystem-space-v1.respec.mjs +0 -67
  169. package/dist/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_createAndInit.node-filesystem-space-v1.respec.mjs.map +0 -1
  170. package/dist/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_persistTransformResult.node-filesystem-space-v1.respec.d.mts +0 -2
  171. package/dist/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_persistTransformResult.node-filesystem-space-v1.respec.d.mts.map +0 -1
  172. package/dist/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_persistTransformResult.node-filesystem-space-v1.respec.mjs +0 -67
  173. package/dist/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_persistTransformResult.node-filesystem-space-v1.respec.mjs.map +0 -1
  174. package/dist/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_putGetDelete.node-filesystem-space-v1.respec.d.mts +0 -2
  175. package/dist/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_putGetDelete.node-filesystem-space-v1.respec.d.mts.map +0 -1
  176. package/dist/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_putGetDelete.node-filesystem-space-v1.respec.mjs +0 -68
  177. package/dist/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_putGetDelete.node-filesystem-space-v1.respec.mjs.map +0 -1
  178. package/dist/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_registerNewIbGib_GetLatest.node-filesystem-space-v1.respec.d.mts +0 -2
  179. package/dist/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_registerNewIbGib_GetLatest.node-filesystem-space-v1.respec.d.mts.map +0 -1
  180. package/dist/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_registerNewIbGib_GetLatest.node-filesystem-space-v1.respec.mjs +0 -69
  181. package/dist/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_registerNewIbGib_GetLatest.node-filesystem-space-v1.respec.mjs.map +0 -1
  182. package/src/sync/sync-peer/sync-peer-http.respec.mts +0 -396
  183. package/src/witness/space/filesystem-space/node-filesystem-space/node-filesystem-space-helper.mts +0 -298
  184. package/src/witness/space/filesystem-space/node-filesystem-space/node-filesystem-space-types.mts +0 -150
  185. package/src/witness/space/filesystem-space/node-filesystem-space/node-filesystem-space-v1.mts +0 -666
  186. package/src/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_createAndInit.node-filesystem-space-v1.respec.mts +0 -87
  187. package/src/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_persistTransformResult.node-filesystem-space-v1.respec.mts +0 -88
  188. package/src/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_putGetDelete.node-filesystem-space-v1.respec.mts +0 -88
  189. package/src/witness/space/filesystem-space/node-filesystem-space/respec/testSpace_registerNewIbGib_GetLatest.node-filesystem-space-v1.respec.mts +0 -90
@@ -17,35 +17,11 @@ import { IbGibAddr } from "@ibgib/ts-gib/dist/types.mjs";
17
17
  import { GLOBAL_LOG_A_LOT } from "../core-constants.mjs";
18
18
  import { IbGibSpaceAny } from "../witness/space/space-base-v1.mjs";
19
19
  import { putInSpace, getLatestAddrs, getFromSpace, registerNewIbGib } from "../witness/space/space-helper.mjs";
20
- import { KeystoneChallengePool, KeystoneChallengeType, KeystoneIbGib_V1, KeystonePoolConfig_HashV1, KeystoneReplenishStrategy } from "../keystone/keystone-types.mjs";
21
- import { KeystoneService_V1 } from "../keystone/keystone-service-v1.mjs";
22
- import { deriveKey } from "../keystone/kdf/kdf-helpers.mjs";
23
- import { KdfStrategy } from "../keystone/kdf/kdf-constants.mjs";
24
20
  import { MetaspaceService } from "../witness/space/metaspace/metaspace-types.mjs";
25
21
  import {
26
22
  SyncStage, SYNC_ATOM, SYNC_MSG_REL8N_NAME, SYNC_SAGA_PAYLOAD_ADDRS_DOMAIN,
27
- SyncConflictStrategy,
28
- SYNC_CONFLICT_STRATEGY_VALID_VALUES,
29
- SESSION_IDENTITY_KEYSTONE_SECRET_TRANSITIONPOOL,
30
- SESSION_IDENTITY_KEYSTONE_CONFIG_ALGO,
31
- SESSION_IDENTITY_KEYSTONE_CONFIG_ROUNDS,
32
- SESSION_IDENTITY_KEYSTONE_CONFIG_RANDOM,
33
- SESSION_IDENTITY_KEYSTONE_CONFIG_REPLENISH_STRATEGY,
34
- SESSION_IDENTITY_KEYSTONE_CONFIG_SEQUENTIAL,
35
- SESSION_IDENTITY_KEYSTONE_CONFIG_TARGET_BINDING,
36
- SESSION_IDENTITY_KEYSTONE_CONFIG_SIZE,
37
- SESSION_IDENTITY_KEYSTONE_TRANSITION_POOL_ID,
38
- SESSION_IDENTITY_KEYSTONE_CONFIG_SIZE_TRANSITIONPOOL,
39
- SESSION_IDENTITY_KEYSTONE_CONFIG_REPLENISH_STRATEGY_TRANSITIONPOOL,
40
- SESSION_IDENTITY_KEYSTONE_CONFIG_RANDOM_TRANSITIONPOOL,
41
- SESSION_IDENTITY_KEYSTONE_CONFIG_SEQUENTIAL_TRANSITIONPOOL,
42
- SESSION_IDENTITY_KEYSTONE_CONFIG_TARGET_BINDING_TRANSITIONPOOL,
43
- SESSION_IDENTITY_KEYSTONE_CONFIG_ALGO_TRANSITIONPOOL,
44
- SESSION_IDENTITY_KEYSTONE_CONFIG_ROUNDS_TRANSITIONPOOL,
45
- SESSION_IDENTITY_KEYSTONE_CONFIG_VERBS_TRANSITIONPOOL,
46
- SESSION_IDENTITY_KEYSTONE_CONFIG_VERBS_DELEGATE,
47
- SESSION_IDENTITY_KEYSTONE_DELEGATE_POOL_ID,
48
- SESSION_IDENTITY_KEYSTONE_PRIMARY_POOL_ID,
23
+ SyncConflictStrategy, SYNC_CONFLICT_STRATEGY_VALID_VALUES,
24
+
49
25
  } from "./sync-constants.mjs";
50
26
  import {
51
27
  appendToTimeline, createTimeline, getHistory, getHistoryAddrs, Rel8nInfo, Rel8nRemovalInfo
@@ -83,11 +59,7 @@ import { graftTimelines, } from "./graft-info/graft-info-helpers.mjs";
83
59
  import { GRAFT_INFO_REL8N_NAME } from "./graft-info/graft-info-constants.mjs";
84
60
  import { GraftInfoIbGib_V1 } from "./graft-info/graft-info-types.mjs";
85
61
  import { validateIbGibIntrinsically } from "@ibgib/ts-gib/dist/V1/validate-helper.mjs";
86
- import { KEYSTONE_VERB_MANAGE, KEYSTONE_VERB_SIGN } from "../keystone/keystone-constants.mjs";
87
- import { addToBindingMap, generateOpaqueChallengeId, validateGenesisKeystone, validateKeystoneGraph } from "../keystone/keystone-helpers.mjs";
88
62
  import { SYNC_SAGA_CONTEXT_ATOM } from "./sync-saga-context/sync-saga-context-constants.mjs";
89
- import { createStandardPoolConfig } from "../keystone/keystone-config-builder.mjs";
90
- import { KeystoneStrategyFactory } from "../keystone/strategy/keystone-strategy-factory.mjs";
91
63
 
92
64
 
93
65
  const logalot = GLOBAL_LOG_A_LOT;
@@ -104,15 +76,13 @@ const lcControlDomain = '[ControlDomain]';
104
76
  * * **Sender/Local Node**: The node *initiating* the sync (calling `sync()`).
105
77
  * * **Receiver/Remote Node**: The node *accepting* the sync request (the Peer).
106
78
  *
107
- * Note that in a peer-to-peer architecture, "Sender" and "Receiver" are roles relative
108
- * to a specific Saga session, not fixed node identities.
79
+ * Note that in a peer-to-peer architecture, "Sender" and "Receiver" are roles
80
+ * relative to a specific Saga, not fixed node ids.
109
81
  */
110
82
  export class SyncSagaCoordinator {
111
83
  private lc: string = `[${SyncSagaCoordinator.name}]`;
112
84
 
113
- constructor(
114
- public keystoneSvc: KeystoneService_V1
115
- ) {
85
+ constructor() {
116
86
 
117
87
  }
118
88
 
@@ -121,15 +91,12 @@ export class SyncSagaCoordinator {
121
91
  *
122
92
  * @remarks
123
93
  * **Execution Context**: **Sender (Local)**.
124
- * This method is the entry point for starting a sync session.
94
+ * This method is the entry point for starting a sync saga.
125
95
  */
126
96
  public async sync({
127
97
  peer,
128
98
  domainIbGibs,
129
99
  conflictStrategy = SyncConflictStrategy.abort,
130
- useSessionIdentity = true,
131
- identity,
132
- identitySecret,
133
100
  metaspace,
134
101
  localSpace,
135
102
  }: {
@@ -153,20 +120,6 @@ export class SyncSagaCoordinator {
153
120
  * The metaspace context (for registering sync sagas locally).
154
121
  */
155
122
  metaspace: MetaspaceService;
156
- /**
157
- * The primary (i.e. non-session) identity authorizing this sync.
158
- *
159
- * If this is truthy, then {@link identitySecret} must also be provided.
160
- */
161
- identity?: KeystoneIbGib_V1;
162
- /**
163
- * The secret for the identity (to sign the commit).
164
- *
165
- * If provided, this will drive both signing {@link identity} keystone
166
- * (if provided) AND session keystone (if {@link useSessionIdentity} is
167
- * true).
168
- */
169
- identitySecret?: string;
170
123
  /**
171
124
  * How to handle conflicts when both Source and Dest have diverged on the
172
125
  * same timeline.
@@ -174,15 +127,6 @@ export class SyncSagaCoordinator {
174
127
  * defaults to {@link SyncConflictStrategy.abort}
175
128
  */
176
129
  conflictStrategy?: SyncConflictStrategy;
177
- /**
178
- * If true, creates an ephemeral session identity for the sync process
179
- * to secure the sync transaction itself.
180
- *
181
- * If this is true, {@link identitySecret} must also be provided.
182
- *
183
- * @default true
184
- */
185
- useSessionIdentity?: boolean;
186
130
  }): Promise<SyncSagaInfo> {
187
131
  const lc = `${this.lc}[${this.sync.name}]`;
188
132
  if (logalot) { console.log(`${lc} starting...`); }
@@ -227,35 +171,12 @@ export class SyncSagaCoordinator {
227
171
  // Async execution wrapper
228
172
  (async () => {
229
173
  try {
230
-
231
- // BOOTSTRAP IDENTITY (Session Keystone)
232
- let sessionIdentity: KeystoneIbGib_V1 | undefined = undefined;
233
-
234
- if (useSessionIdentity) {
235
- if (!identitySecret) { throw new Error(`useSessionIdentity is true, but identitySecret is falsy. Must provide a secret if you want to use a session identity. (E: 81915860c4dd3ea4dfd81825fa74c126)`); }
236
- // creates the initial session identity (keystone). the flow
237
- // (i think) will go: evolve saga frame, then sign keystone,
238
- // then create/send context.
239
- const resCreateSessionIdentity = await this.createSessionIdentity({
240
- sagaId,
241
- primaryIdentity: identity,
242
- nonSessionSecret: identitySecret,
243
- metaspace,
244
- localSpace
245
- });
246
- sessionIdentity = resCreateSessionIdentity.sessionIdentity;
247
- if (identity) {
248
- if (!resCreateSessionIdentity.newPrimaryIdentity) { throw new Error(`(UNEXPECTED) identity truthy but resCreateSessionIdentity.newPrimaryIdentity falsy? (E: 4f82e88a3cc5bd7e58a40f8d77bda826)`); }
249
- identity = resCreateSessionIdentity.newPrimaryIdentity;
250
- }
251
- }
252
-
253
- // if (logalot) { console.log(`${lc} sessionIdentity: ${sessionIdentity ? pretty(sessionIdentity) : 'undefined'} (I: abc01872800b3a66b819a05898bba826)`); }
174
+ // CONNECT PEER (if needed)
175
+ await peer.connect({ sagaId });
254
176
 
255
177
  // CREATE INITIAL FRAME (Stage.init)
256
178
  const { initFrame, initDomainGraph } = await this.createInitFrame({
257
179
  sagaId,
258
- sessionIdentity,
259
180
  domainIbGibs,
260
181
  conflictStrategy,
261
182
  metaspace, localSpace, tempSpace,
@@ -265,8 +186,6 @@ export class SyncSagaCoordinator {
265
186
  await this.executeSagaLoop({
266
187
  initFrame, initDomainGraph,
267
188
  peer,
268
- identitySecret,
269
- sessionIdentity,
270
189
  updates$,
271
190
  localSpace,
272
191
  tempSpace,
@@ -305,8 +224,6 @@ export class SyncSagaCoordinator {
305
224
  sagaContext,
306
225
  mySpace,
307
226
  myTempSpace,
308
- identity,
309
- identitySecret,
310
227
  metaspace,
311
228
  }: {
312
229
  sagaContext: SyncSagaContextIbGib_V1,
@@ -318,14 +235,6 @@ export class SyncSagaCoordinator {
318
235
  * Local temp space relative to the execution context's POV
319
236
  */
320
237
  myTempSpace: IbGibSpaceAny,
321
- /**
322
- * @see {@link sync} `identity` param.
323
- */
324
- identity?: KeystoneIbGib_V1,
325
- /**
326
- * @see {@link sync} `identitySecret` param.
327
- */
328
- identitySecret?: string,
329
238
  metaspace: MetaspaceService,
330
239
  }): Promise<SyncSagaContextIbGib_V1 | null> {
331
240
  const lc = `${this.lc}[${this.continueSync.name}]`;
@@ -336,7 +245,6 @@ export class SyncSagaCoordinator {
336
245
  sagaContext,
337
246
  mySpace,
338
247
  myTempSpace,
339
- identity,
340
248
  metaspace,
341
249
  });
342
250
 
@@ -364,11 +272,10 @@ export class SyncSagaCoordinator {
364
272
  sagaFrame: frame,
365
273
  localSpace: mySpace,
366
274
  payloadIbGibsDomain,
367
- sessionKeystone: identity,
368
- sessionSecret: identitySecret,
369
275
  metaspace,
370
276
  });
371
277
 
278
+
372
279
  const immediateValidationErrors = await validateContextAndSagaFrame({
373
280
  context: responseCtx,
374
281
  });
@@ -383,341 +290,7 @@ export class SyncSagaCoordinator {
383
290
  }
384
291
  }
385
292
 
386
- /**
387
- * helper that KDFs the given identitySecret, using {@link sagaId} to do so.
388
- *
389
- * @returns deterministically derived session secret
390
- */
391
- private async deriveSessionSecret({
392
- sagaId,
393
- nonSessionSecret,
394
- }: {
395
- sagaId: string,
396
- /**
397
- * driving secret behind the sync operation. usually, this will be the
398
- * secret corresponding to a primary identity keystone. But this can
399
- * also just be a one-time secret just to have more security in the
400
- * transmission intrinsically.
401
- */
402
- nonSessionSecret: string,
403
- }): Promise<string> {
404
- const lc = `${this.lc}[${this.deriveSessionSecret.name}]`;
405
- try {
406
- if (logalot) { console.log(`${lc} starting... (I: 0de03f8dcd3e32f1fca244e8f2a8a826)`); }
407
-
408
- // Derive session-specific secret using KDF
409
- const sessionSecret = await deriveKey({
410
- masterSecret: nonSessionSecret,
411
- kdfOpts: {
412
- strategy: KdfStrategy.recursive_salt_wrap,
413
- salt: sagaId,
414
- rounds: 10000,
415
- algorithm: 'SHA-256'
416
- }
417
- });
418
293
 
419
- return sessionSecret;
420
- } catch (error) {
421
- console.error(`${lc} ${extractErrorMsg(error)}`);
422
- throw error;
423
- } finally {
424
- if (logalot) { console.log(`${lc} complete.`); }
425
- }
426
- }
427
-
428
- private async getInitialWeakTransitionSessionSecret({
429
- sagaId,
430
- }: {
431
- sagaId: string,
432
- }): Promise<string> {
433
- const lc = `${this.lc}[${this.getInitialWeakTransitionSessionSecret.name}]`;
434
- try {
435
- if (logalot) { console.log(`${lc} starting... (I: 872ab81a78827b9f2822b78459203226)`); }
436
-
437
- // Create delegate pool bootstrap secret (publicly derivable)
438
- const initialTransitionSecret = await deriveKey({
439
- masterSecret: SESSION_IDENTITY_KEYSTONE_SECRET_TRANSITIONPOOL, // Weak, publicly derivable secret
440
- kdfOpts: {
441
- strategy: KdfStrategy.recursive_salt_wrap,
442
- salt: sagaId,
443
- rounds: 1, // Minimal rounds - this is meant to be weak
444
- algorithm: 'SHA-256'
445
- }
446
- });
447
-
448
- return initialTransitionSecret;
449
- } catch (error) {
450
- console.error(`${lc} ${extractErrorMsg(error)}`);
451
- throw error;
452
- } finally {
453
- if (logalot) { console.log(`${lc} complete.`); }
454
- }
455
- }
456
-
457
- private async getTransitionKeystonePool({
458
- sagaId,
459
- }: {
460
- sagaId: string,
461
- }): Promise<KeystoneChallengePool> {
462
- const lc = `${this.lc}[${this.getTransitionKeystonePool.name}]`;
463
- try {
464
- if (logalot) { console.log(`${lc} starting... (I: 1ec1c8db7438938b08b96559fcee0826)`); }
465
-
466
- const config = createStandardPoolConfig({
467
- salt: sagaId,
468
- id: SESSION_IDENTITY_KEYSTONE_TRANSITION_POOL_ID,
469
- type: KeystoneChallengeType.hash_reveal_v1,
470
- size: SESSION_IDENTITY_KEYSTONE_CONFIG_SIZE_TRANSITIONPOOL,
471
- replenishStrategy: SESSION_IDENTITY_KEYSTONE_CONFIG_REPLENISH_STRATEGY_TRANSITIONPOOL,
472
- random: SESSION_IDENTITY_KEYSTONE_CONFIG_RANDOM_TRANSITIONPOOL,
473
- sequential: SESSION_IDENTITY_KEYSTONE_CONFIG_SEQUENTIAL_TRANSITIONPOOL,
474
- targetBinding: SESSION_IDENTITY_KEYSTONE_CONFIG_TARGET_BINDING_TRANSITIONPOOL,
475
- hashAlgorithm: SESSION_IDENTITY_KEYSTONE_CONFIG_ALGO_TRANSITIONPOOL,
476
- hashRounds: SESSION_IDENTITY_KEYSTONE_CONFIG_ROUNDS_TRANSITIONPOOL,
477
- verbs: SESSION_IDENTITY_KEYSTONE_CONFIG_VERBS_TRANSITIONPOOL,
478
- });
479
- const strategy = KeystoneStrategyFactory.create({ config });
480
- const poolSecret = await strategy.derivePoolSecret({
481
- masterSecret: await this.getInitialWeakTransitionSessionSecret({ sagaId }),
482
- });
483
- const challenges: { [id: string]: any } = {};
484
- const bindingMap: { [char: string]: string[] } = {};
485
-
486
- const targetSize = config.behavior.size;
487
- const timestamp = Date.now().toString();
488
- for (let i = 0; i < targetSize; i++) {
489
- const challengeId = await generateOpaqueChallengeId({
490
- salt: config.salt, timestamp, index: i
491
- });
492
- const solution = await strategy.generateSolution({
493
- poolSecret, poolId: config.salt, challengeId,
494
- });
495
- const challenge = await strategy.generateChallenge({ solution });
496
- challenges[challengeId] = challenge;
497
- // Populate Binding Map
498
- addToBindingMap(bindingMap, challengeId);
499
- }
500
-
501
- const transitionPool: KeystoneChallengePool = {
502
- id: SESSION_IDENTITY_KEYSTONE_TRANSITION_POOL_ID,
503
- config,
504
- challenges,
505
- bindingMap,
506
- isForeign: true,
507
- // metadata: { origin: 'receiver', role: 'delegate' } // don't need metadata since we have the pool id being 'delegate' (i think)
508
- };
509
-
510
- return transitionPool;
511
- } catch (error) {
512
- console.error(`${lc} ${extractErrorMsg(error)}`);
513
- throw error;
514
- } finally {
515
- if (logalot) { console.log(`${lc} complete.`); }
516
- }
517
- }
518
-
519
- private async getDelegateKeystonePool({
520
- sagaId,
521
- }: {
522
- sagaId: string,
523
- }): Promise<KeystoneChallengePool> {
524
- const lc = `${this.lc}[${this.getDelegateKeystonePool.name}]`;
525
- try {
526
- if (logalot) { console.log(`${lc} starting... (I: 6b1d338f8e988e68f8d77e72ed00d526)`); }
527
-
528
- // todo: change this to a helper function that does the delegated
529
- // functionality better. also the f***ing binding map needs better
530
- // implementation. f***ng glazed over by AI.
531
-
532
- const config = createStandardPoolConfig({
533
- salt: sagaId,
534
- id: SESSION_IDENTITY_KEYSTONE_DELEGATE_POOL_ID,
535
- type: KeystoneChallengeType.hash_reveal_v1,
536
- size: SESSION_IDENTITY_KEYSTONE_CONFIG_SIZE,
537
- replenishStrategy: SESSION_IDENTITY_KEYSTONE_CONFIG_REPLENISH_STRATEGY,
538
- random: SESSION_IDENTITY_KEYSTONE_CONFIG_RANDOM,
539
- sequential: SESSION_IDENTITY_KEYSTONE_CONFIG_SEQUENTIAL,
540
- targetBinding: SESSION_IDENTITY_KEYSTONE_CONFIG_TARGET_BINDING,
541
- hashAlgorithm: SESSION_IDENTITY_KEYSTONE_CONFIG_ALGO,
542
- hashRounds: SESSION_IDENTITY_KEYSTONE_CONFIG_ROUNDS,
543
- verbs: SESSION_IDENTITY_KEYSTONE_CONFIG_VERBS_DELEGATE,
544
- });
545
- const strategy = KeystoneStrategyFactory.create({ config });
546
- const poolSecret = await strategy.derivePoolSecret({
547
- masterSecret: SESSION_IDENTITY_KEYSTONE_SECRET_TRANSITIONPOOL
548
- });
549
- const challenges: { [id: string]: any } = {};
550
- const bindingMap: { [char: string]: string[] } = {};
551
-
552
- const targetSize = config.behavior.size;
553
- const timestamp = Date.now().toString();
554
- for (let i = 0; i < targetSize; i++) {
555
- const challengeId = await generateOpaqueChallengeId({
556
- salt: config.salt, timestamp, index: i
557
- });
558
- const solution = await strategy.generateSolution({
559
- poolSecret, poolId: config.salt, challengeId,
560
- });
561
- const challenge = await strategy.generateChallenge({ solution });
562
- challenges[challengeId] = challenge;
563
- // Populate Binding Map
564
- addToBindingMap(bindingMap, challengeId);
565
- }
566
-
567
- const delegatePool: KeystoneChallengePool = {
568
- id: SESSION_IDENTITY_KEYSTONE_DELEGATE_POOL_ID,
569
- config,
570
- challenges,
571
- bindingMap,
572
- isForeign: true,
573
- // metadata: { origin: 'receiver', role: 'delegate' } // don't need metadata since we have the pool id being 'delegate' (i think)
574
- };
575
-
576
- return delegatePool;
577
- } catch (error) {
578
- console.error(`${lc} ${extractErrorMsg(error)}`);
579
- throw error;
580
- } finally {
581
- if (logalot) { console.log(`${lc} complete.`); }
582
- }
583
- }
584
-
585
- /**
586
- * creates a session identity keystone based off of the given args.
587
- *
588
- * Then, if the {@link primaryIdentity} keystone is provided, this also
589
- * **signs** this keystone pointing to the address of the sess
590
- * @param param0
591
- * @returns
592
- */
593
- private async createSessionIdentity({
594
- sagaId,
595
- primaryIdentity,
596
- nonSessionSecret,
597
- metaspace,
598
- localSpace,
599
- }: {
600
- /**
601
- * unique to any one particular saga.
602
- */
603
- sagaId: string,
604
- /**
605
- * optional main identity, e.g., Alice's keystone
606
- */
607
- primaryIdentity: KeystoneIbGib_V1 | undefined,
608
- /**
609
- * driving secret behind the sync operation. usually, this will be the
610
- * secret corresponding to a primary identity keystone. But this can
611
- * also just be a one-time secret just to have more security in the
612
- * transmission intrinsically.
613
- */
614
- nonSessionSecret: string,
615
- metaspace: MetaspaceService,
616
- localSpace: IbGibSpaceAny,
617
- }): Promise<{
618
- sessionIdentity: KeystoneIbGib_V1,
619
- /**
620
- * if truthy, this evolved from the incoming {@link primaryIdentity} and
621
- * has already persisted/registered in the incoming {@link localSpace}.
622
- */
623
- newPrimaryIdentity: KeystoneIbGib_V1 | undefined
624
- }> {
625
- const lc = `${this.lc}[${this.createSessionIdentity.name}]`;
626
- try {
627
- if (logalot) { console.log(`${lc} starting... (I: 428392a4ee636b7bd8f7d5d89a87e826)`); }
628
-
629
- if (!nonSessionSecret) { throw new Error(`(UNEXPECTED) nonSessionSecret falsy? This is expected to be truthy by this point. (E: 8ce053fe59825a6678713128953b9d26)`); }
630
-
631
- const primarySessionSecret = await this.deriveSessionSecret({
632
- sagaId, nonSessionSecret
633
- });
634
-
635
- // Generate keystone with two initial pools in two steps.
636
- // 1. Create primary pool with genesis method to correspond to the
637
- // sender/sender's secret/identity.
638
- // 2. Create a separate pool and add separately because a
639
- // different pw + config is used for the transition pool.
640
-
641
- const primaryPoolConfig: KeystonePoolConfig_HashV1 = {
642
- allowedVerbs: [KEYSTONE_VERB_MANAGE],
643
- id: SESSION_IDENTITY_KEYSTONE_PRIMARY_POOL_ID,
644
- salt: sagaId,
645
- behavior: {
646
- size: SESSION_IDENTITY_KEYSTONE_CONFIG_SIZE, // Large pool for many signatures
647
- replenish: SESSION_IDENTITY_KEYSTONE_CONFIG_REPLENISH_STRATEGY,
648
- selectSequentially: SESSION_IDENTITY_KEYSTONE_CONFIG_SEQUENTIAL,
649
- selectRandomly: SESSION_IDENTITY_KEYSTONE_CONFIG_RANDOM,
650
- targetBindingChars: SESSION_IDENTITY_KEYSTONE_CONFIG_TARGET_BINDING,
651
- },
652
- type: KeystoneChallengeType.hash_reveal_v1,
653
- algo: SESSION_IDENTITY_KEYSTONE_CONFIG_ALGO,
654
- rounds: SESSION_IDENTITY_KEYSTONE_CONFIG_ROUNDS,
655
- };
656
- const sessionIdentity_genesis = await this.keystoneSvc.genesis({
657
- masterSecret: primarySessionSecret,
658
- configs: [primaryPoolConfig],
659
- metaspace,
660
- space: localSpace,
661
- });
662
-
663
- // #region sanity validation of genesis keystone
664
- /**
665
- * not necessary but since it's a new design, I'm putting in this
666
- * immediate validation just to put it through its paces. (worth the
667
- * slight perf hit).
668
- */
669
- const validationErrors = await validateGenesisKeystone({
670
- keystoneIbGib: sessionIdentity_genesis
671
- });
672
- if (validationErrors) { throw new Error(`(UNEXPECTED) the sessionIdentity_genesis that we just created already has validation errors just after creation? (E: e9ca08cf0f8858bb1ace8b9fa89f8726)`); }
673
- // #endregion sanity validation of genesis keystone
674
-
675
- const transitionPool = await this.getTransitionKeystonePool({ sagaId });
676
- /**
677
- * Note this actually **signs** the initial {@link sessionIdentity_genesis}
678
- * and requires the use of a pool with management priveleges.
679
- */
680
- const sessionIdentity_withTransitionPool = await this.keystoneSvc.addPools({
681
- latestKeystone: sessionIdentity_genesis,
682
- /**
683
- * this secret does not do the delegate pool challenges,
684
- * rather, this is the sessionSecret itself to evolve the
685
- * keystone **to add** the delegate pool in the first place.
686
- */
687
- masterSecret: primarySessionSecret,
688
- metaspace,
689
- space: localSpace,
690
- newPools: [transitionPool],
691
- });
692
-
693
- let newPrimaryIdentity: KeystoneIbGib_V1 | undefined = undefined;
694
- if (primaryIdentity) {
695
- newPrimaryIdentity = await this.keystoneSvc.sign({
696
- latestKeystone: primaryIdentity,
697
- poolId: primaryPoolConfig.id,
698
- claim: {
699
- verb: KEYSTONE_VERB_SIGN,
700
- target: getIbGibAddr({ ibGib: sessionIdentity_withTransitionPool }),
701
- },
702
- masterSecret: nonSessionSecret,
703
- metaspace,
704
- space: localSpace,
705
- // frameDetails: undefined, // anything to put here?
706
- // requiredChallengeIds: undefined, // not relevant I think
707
- });
708
- }
709
-
710
- return {
711
- sessionIdentity: sessionIdentity_withTransitionPool,
712
- newPrimaryIdentity,
713
- }
714
- } catch (error) {
715
- console.error(`${lc} ${extractErrorMsg(error)}`);
716
- throw error;
717
- } finally {
718
- if (logalot) { console.log(`${lc} complete.`); }
719
- }
720
- }
721
294
 
722
295
  /**
723
296
  * Drives the FSM loop of the Saga.
@@ -738,8 +311,6 @@ export class SyncSagaCoordinator {
738
311
  initFrame,
739
312
  initDomainGraph,
740
313
  peer,
741
- sessionIdentity,
742
- identitySecret,
743
314
  updates$,
744
315
  localSpace,
745
316
  tempSpace,
@@ -754,11 +325,6 @@ export class SyncSagaCoordinator {
754
325
  */
755
326
  initDomainGraph: FlatIbGibGraph,
756
327
  peer: SyncPeerWitness,
757
- sessionIdentity?: KeystoneIbGib_V1,
758
- /**
759
- * if {@link sessionIdentity} provided, this must also be truthy
760
- */
761
- identitySecret?: string,
762
328
  updates$: SubjectWitness<SyncSagaContextIbGib_V1>,
763
329
  metaspace: MetaspaceService
764
330
  localSpace: IbGibSpaceAny,
@@ -809,8 +375,6 @@ export class SyncSagaCoordinator {
809
375
  // ...create/compose the Request Context itself...
810
376
  const requestCtx = await this.createSyncSagaContext({
811
377
  sagaFrame: currentFrame,
812
- sessionKeystone: sessionIdentity,
813
- sessionSecret: identitySecret,
814
378
  /**
815
379
  * init frame: empty
816
380
  * ack frame: possible push offers
@@ -837,7 +401,7 @@ export class SyncSagaCoordinator {
837
401
  updates$.next(requestCtx); // spins off for saga UI updates
838
402
 
839
403
  // ...And send the context.
840
- peer.setOptionalOpts({ localSpace, localTempSpace: tempSpace, keystoneSvc: this.keystoneSvc });
404
+ peer.setOptionalOpts({ localSpace, localTempSpace: tempSpace, });
841
405
  const responseCtx = await peer.witness(requestCtx);
842
406
 
843
407
  // the send returned, but a peer can return a falsy responseCtx, if
@@ -936,11 +500,6 @@ export class SyncSagaCoordinator {
936
500
  currentFrame = frame;
937
501
  nextDomainIbGibs = [...(payloadIbGibsDomain || [])];
938
502
 
939
- // Track identity evolution
940
- if (responseCtx.signedSessionKeystone) {
941
- sessionIdentity = responseCtx.signedSessionKeystone;
942
- }
943
-
944
503
  // #region Log handler output for next iteration
945
504
  if (logalotControlDomain) {
946
505
  const handlerDomainAddrs = nextDomainIbGibs.map(p => getIbGibAddr({ ibGib: p }));
@@ -966,8 +525,6 @@ export class SyncSagaCoordinator {
966
525
  */
967
526
  private async createSyncSagaContext({
968
527
  sagaFrame,
969
- sessionKeystone,
970
- sessionSecret,
971
528
  payloadIbGibsDomain,
972
529
  metaspace,
973
530
  localSpace,
@@ -976,15 +533,6 @@ export class SyncSagaCoordinator {
976
533
  * The main saga frame (Init, Ack, etc.).
977
534
  */
978
535
  sagaFrame: SyncIbGib_V1;
979
- /**
980
- * Session identity keystone.
981
- */
982
- sessionKeystone: KeystoneIbGib_V1 | undefined;
983
- /**
984
- * If using session ({@link sessionKeystone} is truthy), this must be
985
- * provided in order to sign it.
986
- */
987
- sessionSecret: string | undefined;
988
536
  /**
989
537
  * Domain payload ibgibs when the sync saga frame includes actual domain
990
538
  * payloads to send, e.g., in a Delta frame.
@@ -1007,7 +555,6 @@ export class SyncSagaCoordinator {
1007
555
  // #region sanity/validation
1008
556
  if (!sagaFrame.data) { throw new Error(`(UNEXPECTED) sagaFrame.data falsy? (E: 04c49b4cccba6842a8b52e4c6f570726)`); }
1009
557
  if (!sagaFrame.data.n && sagaFrame.data.n !== 0) { throw new Error(`(UNEXPECTED) sagaFrame.data.n falsy and not 0? (E: 45b508da64a8b28428b11765d684b826)`); }
1010
- if (sessionKeystone && !sessionSecret) { throw new Error(`(UNEXPECTED) sessionKeystone truthy but sessionSecret falsy? (E: 705ecc25038b12df0e94c90c5561e426)`); }
1011
558
  // #endregion sanity/validation
1012
559
 
1013
560
  const date = new Date();
@@ -1028,25 +575,10 @@ export class SyncSagaCoordinator {
1028
575
  data[SYNC_SAGA_PAYLOAD_ADDRS_DOMAIN] = payloadAddrsDomain;
1029
576
  }
1030
577
 
1031
- // rel8ns should always have saga frame, sometimes have keystone
578
+ // rel8ns should always have saga frame
1032
579
  const rel8ns: SyncSagaContextRel8ns_V1 = {
1033
580
  sagaFrame: [getIbGibAddr({ ibGib: sagaFrame })],
1034
581
  };
1035
- if (sessionKeystone) {
1036
- const keystoneErrors = await validateKeystoneGraph({
1037
- keystoneIbGib: sessionKeystone,
1038
- space: localSpace,
1039
- getLatest: true,
1040
- invalidIfMoreRecentKeystoneFoundInSpace: true,
1041
- });
1042
- if (keystoneErrors.length > 0) {
1043
- throw new Error(`invalid sessionKeystone. errors: ${keystoneErrors} (E: 3881b8caf2d803767a331e1141e84826)`);
1044
- }
1045
- // this addr is BEFORE we sign. So each context ibgib itself will
1046
- // point to the frame of the keystone just before that keystone
1047
- // signs with this context as its target.
1048
- rel8ns.sessionKeystone = [getIbGibAddr({ ibGib: sessionKeystone })];
1049
- }
1050
582
 
1051
583
  // Generate standard ib
1052
584
  const ib = await getSyncSagaContextIb({ data });
@@ -1073,19 +605,6 @@ export class SyncSagaCoordinator {
1073
605
  contextIbGib.payloadIbGibsDomain = payloadIbGibsDomain;
1074
606
  }
1075
607
 
1076
- if (sessionKeystone) {
1077
- if (!sessionSecret) { throw new Error(`(UNEXPECTED) sessionKeystone truthy but sessionSecret falsy? we should have thrown before now (E: a2b0517a37b559543968b888f2067826)`); }
1078
- const contextAddr = getIbGibAddr({ ibGib: contextIbGib });
1079
- contextIbGib.signedSessionKeystone = await this.keystoneSvc.sign({
1080
- latestKeystone: sessionKeystone,
1081
- claim: { target: contextAddr, }, // verb?
1082
- space: localSpace,
1083
- masterSecret: sessionSecret,
1084
- metaspace,
1085
- });
1086
- contextIbGib.fnIdentitySecret = () => Promise.resolve(sessionSecret);
1087
- }
1088
-
1089
608
  return contextIbGib;
1090
609
  } catch (error) {
1091
610
  console.error(`${lc} ${extractErrorMsg(error)}`);
@@ -1209,7 +728,6 @@ export class SyncSagaCoordinator {
1209
728
  */
1210
729
  private async createInitFrame({
1211
730
  sagaId,
1212
- sessionIdentity,
1213
731
  domainIbGibs,
1214
732
  conflictStrategy,
1215
733
  metaspace,
@@ -1217,7 +735,6 @@ export class SyncSagaCoordinator {
1217
735
  tempSpace,
1218
736
  }: {
1219
737
  sagaId: string,
1220
- sessionIdentity?: KeystoneIbGib_V1,
1221
738
  domainIbGibs: IbGib_V1[],
1222
739
  conflictStrategy: SyncConflictStrategy,
1223
740
  metaspace: MetaspaceService,
@@ -1247,7 +764,6 @@ export class SyncSagaCoordinator {
1247
764
  sagaId,
1248
765
  stage: SyncStage.init,
1249
766
  knowledgeMap: knowledgeMap,
1250
- identity: sessionIdentity, // KeystoneIbGib is already public data
1251
767
  mode: SyncMode.sync,
1252
768
  stones: srcStones.map(s => getIbGibAddr({ ibGib: s })),
1253
769
  };
@@ -1268,7 +784,6 @@ export class SyncSagaCoordinator {
1268
784
  const sagaFrame = await this.evolveSyncSagaIbGib({
1269
785
  msgStones: [initStone],
1270
786
  conflictStrategy,
1271
- sessionIdentity,
1272
787
  metaspace,
1273
788
  localSpace,
1274
789
  });
@@ -1385,7 +900,6 @@ export class SyncSagaCoordinator {
1385
900
  initDomainGraph,
1386
901
  mySpace,
1387
902
  myTempSpace,
1388
- identity,
1389
903
  metaspace,
1390
904
  }: {
1391
905
  sagaContext: SyncSagaContextIbGib_V1,
@@ -1404,7 +918,6 @@ export class SyncSagaCoordinator {
1404
918
  * Local temp space relative to the execution context's POV
1405
919
  */
1406
920
  myTempSpace: IbGibSpaceAny,
1407
- identity?: KeystoneIbGib_V1,
1408
921
  metaspace: MetaspaceService,
1409
922
  }): Promise<HandleSagaResponseContextResult> {
1410
923
  const lc = `${this.lc}[${this.handleResponseSagaContext.name}]`;
@@ -1427,7 +940,6 @@ export class SyncSagaCoordinator {
1427
940
  sagaIbGib,
1428
941
  messageData: messageData as SyncSagaMessageInitData_V1,
1429
942
  metaspace, mySpace, myTempSpace,
1430
- identity,
1431
943
  });
1432
944
  break;
1433
945
 
@@ -1438,7 +950,6 @@ export class SyncSagaCoordinator {
1438
950
  sagaIbGib,
1439
951
  initDomainGraph,
1440
952
  metaspace, mySpace, myTempSpace,
1441
- identity,
1442
953
  });
1443
954
  break;
1444
955
 
@@ -1447,7 +958,6 @@ export class SyncSagaCoordinator {
1447
958
  sagaContext,
1448
959
  sagaIbGib,
1449
960
  metaspace, mySpace, myTempSpace,
1450
- identity,
1451
961
  });
1452
962
  break;
1453
963
 
@@ -1456,7 +966,6 @@ export class SyncSagaCoordinator {
1456
966
  nextFrameInfo = await this.handleCommitFrame({
1457
967
  sagaIbGib,
1458
968
  metaspace, mySpace, myTempSpace,
1459
- identity,
1460
969
  });
1461
970
  break;
1462
971
 
@@ -1497,7 +1006,6 @@ export class SyncSagaCoordinator {
1497
1006
  mySpace,
1498
1007
  myTempSpace,
1499
1008
  metaspace,
1500
- identity,
1501
1009
  }: {
1502
1010
  sagaIbGib: SyncIbGib_V1,
1503
1011
  messageData: SyncSagaMessageInitData_V1,
@@ -1513,7 +1021,6 @@ export class SyncSagaCoordinator {
1513
1021
  */
1514
1022
  myTempSpace: IbGibSpaceAny,
1515
1023
  metaspace: MetaspaceService,
1516
- identity?: KeystoneIbGib_V1,
1517
1024
  }): Promise<NextSagaFrameInfo> {
1518
1025
  const lc = `${this.lc}[${this.handleInitFrame.name}]`;
1519
1026
  try {
@@ -1762,7 +1269,6 @@ export class SyncSagaCoordinator {
1762
1269
  const ackFrame = await this.evolveSyncSagaIbGib({
1763
1270
  prevSagaIbGib: sagaIbGib,
1764
1271
  msgStones: [ackStone],
1765
- sessionIdentity: identity,
1766
1272
  localSpace: mySpace,
1767
1273
  metaspace,
1768
1274
  });
@@ -1857,7 +1363,6 @@ export class SyncSagaCoordinator {
1857
1363
  sagaIbGib,
1858
1364
  initDomainGraph,
1859
1365
  mySpace, myTempSpace, metaspace,
1860
- identity,
1861
1366
  }: {
1862
1367
  sagaContext: SyncSagaContextIbGib_V1,
1863
1368
  sagaIbGib: SyncIbGib_V1,
@@ -1871,7 +1376,6 @@ export class SyncSagaCoordinator {
1871
1376
  mySpace: IbGibSpaceAny,
1872
1377
  myTempSpace: IbGibSpaceAny,
1873
1378
  metaspace: MetaspaceService,
1874
- identity?: KeystoneIbGib_V1,
1875
1379
  }): Promise<NextSagaFrameInfo> {
1876
1380
  const lc = `${this.lc}[${this.handleAckFrame.name}]`;
1877
1381
  try {
@@ -2111,16 +1615,14 @@ export class SyncSagaCoordinator {
2111
1615
  const deltaFrame = await this.evolveSyncSagaIbGib({
2112
1616
  prevSagaIbGib: sagaIbGib,
2113
1617
  msgStones: [deltaStone],
2114
- sessionIdentity: identity,
2115
1618
  localSpace: mySpace,
2116
1619
  metaspace,
2117
1620
  });
2118
1621
 
2119
1622
  if (logalot) { console.log(`${lc} Delta Frame created. Rel8ns: ${JSON.stringify(deltaFrame.rel8ns)}`); }
2120
1623
 
2121
- // Build control payloads: frame + its dependencies (msg stone, identity)
1624
+ // Build control payloads: frame + its dependencies (msg stone)
2122
1625
  // const payloadIbGibsControl: IbGib_V1[] = [deltaFrame, deltaStone];
2123
- // if (identity) { payloadIbGibsControl.push(identity); }
2124
1626
 
2125
1627
  return { frame: deltaFrame, payloadIbGibsDomain: outgoingPayloadsDomain_all, };
2126
1628
  } catch (error) {
@@ -2150,14 +1652,12 @@ export class SyncSagaCoordinator {
2150
1652
  mySpace,
2151
1653
  myTempSpace,
2152
1654
  metaspace,
2153
- identity,
2154
1655
  }: {
2155
1656
  sagaContext: SyncSagaContextIbGib_V1,
2156
1657
  sagaIbGib: SyncIbGib_V1,
2157
1658
  mySpace: IbGibSpaceAny,
2158
1659
  myTempSpace: IbGibSpaceAny,
2159
1660
  metaspace: MetaspaceService,
2160
- identity?: KeystoneIbGib_V1,
2161
1661
  }): Promise<NextSagaFrameInfo> {
2162
1662
  const lc = `${this.lc}[${this.handleDeltaFrame.name}]`;
2163
1663
  try {
@@ -2398,7 +1898,6 @@ export class SyncSagaCoordinator {
2398
1898
  const deltaFrame = await this.evolveSyncSagaIbGib({
2399
1899
  prevSagaIbGib: sagaIbGib,
2400
1900
  msgStones: [deltaStone],
2401
- sessionIdentity: identity,
2402
1901
  localSpace: mySpace,
2403
1902
  metaspace,
2404
1903
  });
@@ -2422,7 +1921,6 @@ export class SyncSagaCoordinator {
2422
1921
  sagaIbGib,
2423
1922
  errors: validationErrors,
2424
1923
  metaspace, mySpace,
2425
- identity,
2426
1924
  });
2427
1925
  return { frame: errorCommitFrame, }; /* <<<< returns early */
2428
1926
  }
@@ -2440,7 +1938,6 @@ export class SyncSagaCoordinator {
2440
1938
  errors: undefined,
2441
1939
  metaspace,
2442
1940
  mySpace,
2443
- identity,
2444
1941
  });
2445
1942
 
2446
1943
  return { frame: commitFrame, };
@@ -2465,7 +1962,6 @@ export class SyncSagaCoordinator {
2465
1962
  const deltaFrame = await this.evolveSyncSagaIbGib({
2466
1963
  prevSagaIbGib: sagaIbGib,
2467
1964
  msgStones: [deltaStone],
2468
- sessionIdentity: identity,
2469
1965
  localSpace: mySpace,
2470
1966
  metaspace
2471
1967
  });
@@ -2491,22 +1987,13 @@ export class SyncSagaCoordinator {
2491
1987
  const commitFrame = await this.evolveSyncSagaIbGib({
2492
1988
  prevSagaIbGib: deltaFrame, // Build on top of the Delta we just created/persisted
2493
1989
  msgStones: [commitStone],
2494
- sessionIdentity: identity,
2495
1990
  localSpace: mySpace,
2496
1991
  metaspace
2497
1992
  });
2498
1993
 
2499
- // Build control payloads for commit
2500
- const commitCtrlPayloads2: IbGib_V1[] = [commitFrame, commitStone];
2501
- if (identity) { commitCtrlPayloads2.push(identity); }
2502
-
2503
1994
  return { frame: commitFrame, };
2504
1995
  }
2505
1996
 
2506
- // Build control payloads for delta propose
2507
- // const deltaCtrlPayloads: IbGib_V1[] = [deltaFrame, deltaStone];
2508
- // if (identity) { deltaCtrlPayloads.push(identity); }
2509
-
2510
1997
  return { frame: deltaFrame, payloadIbGibsDomain: outgoingPayload };
2511
1998
  }
2512
1999
  }
@@ -2526,7 +2013,6 @@ export class SyncSagaCoordinator {
2526
2013
  commitFrame,
2527
2014
  sagaHistory,
2528
2015
  metaspace, localSpace, localTempSpace,
2529
- identity,
2530
2016
  }: {
2531
2017
  deltaFrame?: SyncIbGib_V1;
2532
2018
  commitFrame?: SyncIbGib_V1;
@@ -2534,7 +2020,6 @@ export class SyncSagaCoordinator {
2534
2020
  metaspace: MetaspaceService;
2535
2021
  localSpace: IbGibSpaceAny;
2536
2022
  localTempSpace: IbGibSpaceAny;
2537
- identity?: KeystoneIbGib_V1;
2538
2023
  }): Promise<void> {
2539
2024
  const lc = `${this.lc}[${this.executeLocalCommit.name}]`;
2540
2025
  try {
@@ -2784,7 +2269,6 @@ export class SyncSagaCoordinator {
2784
2269
  errors,
2785
2270
  metaspace,
2786
2271
  mySpace,
2787
- identity,
2788
2272
  }: {
2789
2273
  sagaIbGib: SyncIbGib_V1,
2790
2274
  /**
@@ -2794,7 +2278,6 @@ export class SyncSagaCoordinator {
2794
2278
  errors?: string[],
2795
2279
  metaspace: MetaspaceService,
2796
2280
  mySpace: IbGibSpaceAny,
2797
- identity: KeystoneIbGib_V1 | undefined,
2798
2281
  }): Promise<SyncIbGib_V1> {
2799
2282
  const lc = `[${this.createCommitFrame.name}]`;
2800
2283
  try {
@@ -2822,7 +2305,6 @@ export class SyncSagaCoordinator {
2822
2305
  const commitFrame = await this.evolveSyncSagaIbGib({
2823
2306
  prevSagaIbGib: sagaIbGib,
2824
2307
  msgStones: [commitStone],
2825
- sessionIdentity: identity,
2826
2308
  localSpace: mySpace,
2827
2309
  metaspace,
2828
2310
  });
@@ -2840,13 +2322,11 @@ export class SyncSagaCoordinator {
2840
2322
  mySpace,
2841
2323
  myTempSpace,
2842
2324
  metaspace,
2843
- identity,
2844
2325
  }: {
2845
2326
  sagaIbGib: SyncIbGib_V1,
2846
2327
  mySpace: IbGibSpaceAny,
2847
2328
  myTempSpace: IbGibSpaceAny,
2848
2329
  metaspace: MetaspaceService,
2849
- identity?: KeystoneIbGib_V1,
2850
2330
  }): Promise<NextSagaFrameInfo> {
2851
2331
  const lc = `${this.lc}[${this.handleCommitFrame.name}]`;
2852
2332
  try {
@@ -2880,7 +2360,6 @@ export class SyncSagaCoordinator {
2880
2360
  sagaIbGib,
2881
2361
  metaspace,
2882
2362
  mySpace,
2883
- identity,
2884
2363
  errors: validationErrors,
2885
2364
  });
2886
2365
  return { frame: errorCommitFrame, }; /* <<<< returns early */
@@ -2911,7 +2390,6 @@ export class SyncSagaCoordinator {
2911
2390
  errors: [emsg],
2912
2391
  metaspace,
2913
2392
  mySpace,
2914
- identity,
2915
2393
  });
2916
2394
  return { frame: errorCommitFrame }
2917
2395
  } finally {
@@ -3029,7 +2507,6 @@ export class SyncSagaCoordinator {
3029
2507
  prevSagaIbGib,
3030
2508
  conflictStrategy,
3031
2509
  msgStones,
3032
- sessionIdentity,
3033
2510
  localSpace,
3034
2511
  metaspace,
3035
2512
  }: {
@@ -3038,10 +2515,6 @@ export class SyncSagaCoordinator {
3038
2515
  msgStones: IbGib_V1[],
3039
2516
  localSpace: IbGibSpaceAny,
3040
2517
  metaspace: MetaspaceService,
3041
- /**
3042
- * does NOT evolve the keystone.
3043
- */
3044
- sessionIdentity: KeystoneIbGib_V1 | undefined,
3045
2518
  }): Promise<SyncIbGib_V1> {
3046
2519
  const lc = `${this.lc}[${this.evolveSyncSagaIbGib.name}]`;
3047
2520
  try {
@@ -3067,8 +2540,6 @@ export class SyncSagaCoordinator {
3067
2540
  }
3068
2541
  }
3069
2542
 
3070
- const identityAddr = sessionIdentity ? getIbGibAddr({ ibGib: sessionIdentity }) : undefined;
3071
-
3072
2543
  if (prevSagaIbGib) {
3073
2544
  /**
3074
2545
  * rel8ns always include the new msg stone(s)
@@ -3080,11 +2551,6 @@ export class SyncSagaCoordinator {
3080
2551
  }
3081
2552
  ];
3082
2553
 
3083
- // if we're authenticating/signing, we'll have identity
3084
- if (sessionIdentity) {
3085
- rel8nInfos.push({ rel8nName: 'identity', ibGibs: [sessionIdentity], });
3086
- }
3087
-
3088
2554
  // remove the existing sync msg stones' addrs
3089
2555
  if (!prevSagaIbGib.rel8ns) { throw new Error(`(UNEXPECTED) prevSagaIbGib.rel8ns falsy? (E: 81375841aff85b1e48ea42ca218e6826)`); }
3090
2556
  if (!prevSagaIbGib.rel8ns[SYNC_MSG_REL8N_NAME] || prevSagaIbGib.rel8ns[SYNC_MSG_REL8N_NAME].length === 0) {
@@ -3123,12 +2589,6 @@ export class SyncSagaCoordinator {
3123
2589
  // rel8ns
3124
2590
  const stoneAddrs = msgStones.map(s => getIbGibAddr({ ibGib: s }));
3125
2591
  const rel8ns: SyncRel8ns_V1 = { [SYNC_MSG_REL8N_NAME]: stoneAddrs, };
3126
- if (identityAddr) { rel8ns.identity = [identityAddr]; }
3127
-
3128
- // Attach session keystone to saga frame via hard rel8n
3129
- if (sessionIdentity) {
3130
- rel8ns.sessionKeystone = [getIbGibAddr({ ibGib: sessionIdentity })];
3131
- }
3132
2592
 
3133
2593
  const resNew = await createTimeline({
3134
2594
  space: localSpace,