@ibgib/core-gib 0.1.47 → 0.1.49

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 (136) 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 +2 -2
  28. package/dist/sync/sync-conflict-adv-multitimelines.respec.mjs.map +1 -1
  29. package/dist/sync/sync-conflict-basic-divergence.respec.mjs +2 -2
  30. package/dist/sync/sync-conflict-basic-divergence.respec.mjs.map +1 -1
  31. package/dist/sync/sync-conflict-basic-multitimelines.respec.mjs +2 -2
  32. package/dist/sync/sync-conflict-basic-multitimelines.respec.mjs.map +1 -1
  33. package/dist/sync/sync-conflict-text-merge.respec.mjs +2 -2
  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 +2 -2
  40. package/dist/sync/sync-innerspace-constants.respec.mjs.map +1 -1
  41. package/dist/sync/sync-innerspace-deep-updates.respec.mjs +2 -2
  42. package/dist/sync/sync-innerspace-deep-updates.respec.mjs.map +1 -1
  43. package/dist/sync/sync-innerspace-dest-ahead-withid.respec.mjs +22 -8
  44. package/dist/sync/sync-innerspace-dest-ahead-withid.respec.mjs.map +1 -1
  45. package/dist/sync/sync-innerspace-dest-ahead.respec.mjs +2 -2
  46. package/dist/sync/sync-innerspace-dest-ahead.respec.mjs.map +1 -1
  47. package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs +2 -2
  48. package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs.map +1 -1
  49. package/dist/sync/sync-innerspace-partial-update.respec.mjs +2 -2
  50. package/dist/sync/sync-innerspace-partial-update.respec.mjs.map +1 -1
  51. package/dist/sync/sync-innerspace.respec.mjs +2 -2
  52. package/dist/sync/sync-innerspace.respec.mjs.map +1 -1
  53. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-http-node-adapter.d.mts +57 -0
  54. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-http-node-adapter.d.mts.map +1 -0
  55. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-http-node-adapter.mjs +310 -0
  56. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-http-node-adapter.mjs.map +1 -0
  57. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-types.d.mts +27 -0
  58. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-types.d.mts.map +1 -0
  59. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-types.mjs +2 -0
  60. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-types.mjs.map +1 -0
  61. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-v1.d.mts +29 -0
  62. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-v1.d.mts.map +1 -0
  63. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-v1.mjs +122 -0
  64. package/dist/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-v1.mjs.map +1 -0
  65. package/dist/sync/sync-peer/sync-peer-http-sender/sync-peer-http-sender-types.d.mts +27 -0
  66. package/dist/sync/sync-peer/sync-peer-http-sender/sync-peer-http-sender-types.d.mts.map +1 -0
  67. package/dist/sync/sync-peer/sync-peer-http-sender/sync-peer-http-sender-types.mjs +2 -0
  68. package/dist/sync/sync-peer/sync-peer-http-sender/sync-peer-http-sender-types.mjs.map +1 -0
  69. package/dist/sync/sync-peer/sync-peer-http-sender/sync-peer-http-sender-v1.d.mts +24 -0
  70. package/dist/sync/sync-peer/sync-peer-http-sender/sync-peer-http-sender-v1.d.mts.map +1 -0
  71. package/dist/sync/sync-peer/sync-peer-http-sender/sync-peer-http-sender-v1.mjs +111 -0
  72. package/dist/sync/sync-peer/sync-peer-http-sender/sync-peer-http-sender-v1.mjs.map +1 -0
  73. package/dist/sync/sync-peer/sync-peer-http.respec.d.mts +8 -0
  74. package/dist/sync/sync-peer/sync-peer-http.respec.d.mts.map +1 -0
  75. package/dist/sync/sync-peer/sync-peer-http.respec.mjs +333 -0
  76. package/dist/sync/sync-peer/sync-peer-http.respec.mjs.map +1 -0
  77. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts.map +1 -1
  78. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs +13 -7
  79. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs.map +1 -1
  80. package/dist/sync/sync-peer/sync-peer-types.d.mts +5 -5
  81. package/dist/sync/sync-peer/sync-peer-types.d.mts.map +1 -1
  82. package/dist/sync/sync-peer/sync-peer-v1.d.mts +6 -3
  83. package/dist/sync/sync-peer/sync-peer-v1.d.mts.map +1 -1
  84. package/dist/sync/sync-peer/sync-peer-v1.mjs +75 -26
  85. package/dist/sync/sync-peer/sync-peer-v1.mjs.map +1 -1
  86. package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts +7 -3
  87. package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts.map +1 -1
  88. package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs +32 -3
  89. package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs.map +1 -1
  90. package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts +16 -0
  91. package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts.map +1 -1
  92. package/dist/sync/sync-saga-coordinator.d.mts +18 -3
  93. package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
  94. package/dist/sync/sync-saga-coordinator.mjs +241 -56
  95. package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
  96. package/dist/sync/sync-types.d.mts +1 -1
  97. package/dist/sync/sync-types.d.mts.map +1 -1
  98. package/ibgib-foundations.md +109 -89
  99. package/package.json +1 -1
  100. package/src/common/other/ibgib-helper.mts +39 -0
  101. package/src/keystone/kdf/kdf-helpers.mts +2 -2
  102. package/src/keystone/keystone-config-builder.mts +13 -2
  103. package/src/keystone/keystone-constants.mts +24 -2
  104. package/src/keystone/keystone-helpers.mts +5 -10
  105. package/src/keystone/keystone-service-v1.mts +5 -0
  106. package/src/keystone/keystone-service-v1.respec.mts +25 -25
  107. package/src/keystone/keystone-types.mts +27 -7
  108. package/src/sync/sync-conflict-adv-multitimelines.respec.mts +2 -2
  109. package/src/sync/sync-conflict-basic-divergence.respec.mts +2 -2
  110. package/src/sync/sync-conflict-basic-multitimelines.respec.mts +2 -2
  111. package/src/sync/sync-conflict-text-merge.respec.mts +2 -2
  112. package/src/sync/sync-constants.mts +51 -1
  113. package/src/sync/sync-innerspace-constants.respec.mts +2 -2
  114. package/src/sync/sync-innerspace-deep-updates.respec.mts +2 -2
  115. package/src/sync/sync-innerspace-dest-ahead-withid.respec.mts +26 -9
  116. package/src/sync/sync-innerspace-dest-ahead.respec.mts +2 -2
  117. package/src/sync/sync-innerspace-multiple-timelines.respec.mts +2 -2
  118. package/src/sync/sync-innerspace-partial-update.respec.mts +2 -2
  119. package/src/sync/sync-innerspace.respec.mts +2 -2
  120. package/src/sync/sync-peer/sync-peer-http-receiver/sync-http-node-adapter.mts +319 -0
  121. package/src/sync/sync-peer/sync-peer-http-receiver/sync-http-node-adapter.mts.metadata.md +72 -0
  122. package/src/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-types.mts +30 -0
  123. package/src/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-v1.mts +146 -0
  124. package/src/sync/sync-peer/sync-peer-http-receiver/sync-peer-http-receiver-v1.mts.metadata.md +71 -0
  125. package/src/sync/sync-peer/sync-peer-http-sender/sync-peer-http-sender-types.mts +32 -0
  126. package/src/sync/sync-peer/sync-peer-http-sender/sync-peer-http-sender-v1.mts +129 -0
  127. package/src/sync/sync-peer/sync-peer-http.respec.mts +364 -0
  128. package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-types.mts +8 -8
  129. package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mts +15 -7
  130. package/src/sync/sync-peer/sync-peer-types.mts +11 -11
  131. package/src/sync/sync-peer/sync-peer-v1.mts +66 -30
  132. package/src/sync/sync-saga-context/sync-saga-context-helpers.mts +52 -4
  133. package/src/sync/sync-saga-context/sync-saga-context-types.mts +17 -0
  134. package/src/sync/sync-saga-coordinator.mts +296 -63
  135. package/src/sync/sync-types.mts +1 -1
  136. package/tmp-certs/server.pfx +0 -0
@@ -20,11 +20,14 @@ import { IbGibSpaceAny } from '../../witness/space/space-base-v1.mjs';
20
20
  import { newupSubject } from '../../common/pubsub/subject/subject-helper.mjs';
21
21
  import { authenticateContext, authorizeContext, validateContextAndSagaFrame } from '../sync-saga-context/sync-saga-context-helpers.mjs';
22
22
  import { getFromSpace } from '../../witness/space/space-helper.mjs';
23
+ import { getFullSyncSagaHistory } from '../sync-helpers.mjs';
24
+ import { SyncSagaFrameDependencyGraph } from '../sync-types.mjs';
23
25
 
24
26
  const logalot = GLOBAL_LOG_A_LOT;
25
27
  const logalotControlDomain = false;
26
28
  const lcControlDomain = '[ControlDomain]';
27
29
 
30
+
28
31
  /**
29
32
  * Abstract witness for talking to a Sync Peer (e.g. Remote Node or Local Simulator).
30
33
  *
@@ -66,8 +69,8 @@ export abstract class SyncPeer_V1<TInitializeOpts extends InitializeSyncPeerOpts
66
69
  *
67
70
  * @see {@link SyncPeerWitness.opts}
68
71
  */
69
- public async initializeSender(opts: TInitializeOpts): Promise<void> {
70
- const lc = `${this.lc}[${this.initializeSender.name}]`;
72
+ public async initializeOpts(opts: TInitializeOpts): Promise<void> {
73
+ const lc = `${this.lc}[${this.initializeOpts.name}]`;
71
74
  try {
72
75
  if (logalot) { console.log(`${lc} starting... (I: 31bd5fda37c89fa37fbaf14daf5fe726)`); }
73
76
  this.opts = opts;
@@ -115,8 +118,44 @@ export abstract class SyncPeer_V1<TInitializeOpts extends InitializeSyncPeerOpts
115
118
  // }
116
119
  // }
117
120
 
118
- protected abstract ensureReceiverTempSpace(): Promise<IbGibSpaceAny>;
119
121
 
122
+
123
+ protected async authenticateValidateAuthorize({
124
+ context,
125
+ fullSagaHistory,
126
+ }: {
127
+ context: SyncSagaContextIbGib_V1,
128
+ fullSagaHistory: SyncSagaFrameDependencyGraph[],
129
+ }): Promise<void> {
130
+ const lc = `${this.lc}[${this.authenticateValidateAuthorize.name}]`;
131
+ try {
132
+ if (logalot) { console.log(`${lc} starting... (I: add238055cd84a222c5b8c89913af526)`); }
133
+
134
+ // first authenticate, because invalid identity is a non-starter
135
+ const authenticationErrors = await authenticateContext({ context, fullSagaHistory });
136
+ if (authenticationErrors.length > 0) {
137
+ throw new Error(`invalid context authentication. authenticationErrors: ${authenticationErrors} (E: da89da5ee1269aeb78952d475d607526)`);
138
+ }
139
+ // next, we have a valid keystone, which should point to the
140
+ // context. But is that context and the saga data it contains valid?
141
+ // Does the keystone actually point to this context?
142
+ const validationErrors = await validateContextAndSagaFrame({ context, });
143
+ if (validationErrors.length > 0) {
144
+ throw new Error(`invalid context received. validationErrors: ${validationErrors} (E: 8b34c875c968af29bc433138e57a7826)`);
145
+ }
146
+ // we have a valid keystone that points to a valid context, but what
147
+ // exactly does the keystone authorize?
148
+ const authorizationErrors = await authorizeContext({ context, fullSagaHistory });
149
+ if (authorizationErrors.length > 0) {
150
+ throw new Error(`invalid context authorization. authorizationErrors: ${authorizationErrors} (E: 8ddc284a758cf10ba829334c1babb826)`);
151
+ }
152
+ } catch (error) {
153
+ console.error(`${lc} ${extractErrorMsg(error)}`);
154
+ throw error;
155
+ } finally {
156
+ if (logalot) { console.log(`${lc} complete.`); }
157
+ }
158
+ }
120
159
  /**
121
160
  * Witness the synchronization context (Send/Receive).
122
161
  *
@@ -133,16 +172,6 @@ export abstract class SyncPeer_V1<TInitializeOpts extends InitializeSyncPeerOpts
133
172
 
134
173
  if (!this.opts) { throw new Error(`(UNEXPECTED) this.opts falsy? Concrete class should have initialized sender opts by now. (E: 0b9e28287318fdf8bf9f5a6886a24826)`); }
135
174
 
136
- // #region leaving off here
137
- // NOTES: the context ibgib now has a reference to the signed
138
- // keystone. the signed keystone targets the context ibgib, and the
139
- // context ibgib itself points to the previous frame of the
140
- // keystone. I've started on creating a validateKeystone function,
141
- // whcih I need to at least add the validate transitions to. I
142
- // _think_ I need to also fill in some authentication here in this
143
- // peer at the very least, then I can move on to other layers.
144
- // #endregion leaving off here
145
-
146
175
  // NOTE: There are three basic types of peers:
147
176
  // * local-only
148
177
  // * this peer is both sender/receiver peer
@@ -183,23 +212,21 @@ export abstract class SyncPeer_V1<TInitializeOpts extends InitializeSyncPeerOpts
183
212
  // when all domain ibgibs are pulled, publish complete to the observable
184
213
  // return resulting context ibgib (which the caller should get BEFORE the domain ibgibs observable completes)
185
214
 
186
- // validate, authenticate, and authorize the context, sagaFrame, and identity(s)
187
- const validationErrors = await validateContextAndSagaFrame({ context });
188
- if (validationErrors.length > 0) {
189
- throw new Error(`invalid context received. validationErrors: ${validationErrors} (E: 8b34c875c968af29bc433138e57a7826)`);
190
- }
191
- const authenticationErrors = await authenticateContext({ context });
192
- if (authenticationErrors.length > 0) {
193
- throw new Error(`invalid context authentication. authenticationErrors: ${authenticationErrors} (E: da89da5ee1269aeb78952d475d607526)`);
194
- }
195
- const authorizationErrors = await authorizeContext({ context });
196
- if (authorizationErrors.length > 0) {
197
- throw new Error(`invalid context authorization. authorizationErrors: ${authorizationErrors} (E: 8ddc284a758cf10ba829334c1babb826)`);
198
- }
215
+ if (!context.sagaFrame) { throw new Error(`context.sagaFrame falsy. (E: a33dd88aa108e2bad9e885885731ce26)`); }
199
216
 
200
- // at this point, we have a valid, authenticated, authorized context
217
+ // this is not just happening on the client, but this peer may be
218
+ // the one receiving the context as well.
219
+
220
+ const sagaHistory_beforeSend = await getFullSyncSagaHistory({
221
+ sagaIbGib: context.sagaFrame,
222
+ space: this.opts.localSpace
223
+ });
201
224
 
202
- await this.ensureReceiverTempSpace();
225
+ await this.authenticateValidateAuthorize({
226
+ context, fullSagaHistory: sagaHistory_beforeSend,
227
+ });
228
+
229
+ // at this point, we have a valid, authenticated, authorized context
203
230
 
204
231
  // execute the transfer of control domain ibgibs & outgoing payload
205
232
  // ibgibs...
@@ -213,6 +240,15 @@ export abstract class SyncPeer_V1<TInitializeOpts extends InitializeSyncPeerOpts
213
240
  // receive, they may still be transferring. These will be published
214
241
  // to this.payloadIbGibsDomainReceived$
215
242
 
243
+ const sagaHistory_afterSend = await getFullSyncSagaHistory({
244
+ sagaIbGib: context.sagaFrame,
245
+ space: this.opts.localSpace
246
+ });
247
+
248
+ await this.authenticateValidateAuthorize({
249
+ context, fullSagaHistory: sagaHistory_afterSend,
250
+ });
251
+
216
252
  return response;
217
253
  } else {
218
254
  // response falsy. we could be done, or this could be an error.
@@ -268,13 +304,13 @@ export abstract class SyncPeer_V1<TInitializeOpts extends InitializeSyncPeerOpts
268
304
  console.warn(`${lc} possibly a bottleneck here, getLocalIbGib only gets a single ibgib... (W: 2fd448a435480e6b128f6b8bcbef4826)`);
269
305
  if (!this.opts) { throw new Error(`(UNEXPECTED) this.opts falsy? (E: cfb9431f2fb851f24a6c88e80c3b3326)`); }
270
306
 
271
- const resGet = await getFromSpace({ space: this.opts.senderSpace, addr });
307
+ const resGet = await getFromSpace({ space: this.opts.localSpace, addr });
272
308
 
273
309
  if (resGet.success && resGet.ibGibs && resGet.ibGibs.length === 1) {
274
310
  const ibGib = resGet.ibGibs[0];
275
311
  return ibGib;
276
312
  } else {
277
- throw new Error(`couldn't get addr (${addr}) from local space ${this.opts.senderSpace}. reason: ${resGet.errorMsg ?? 'unknown error (E: 926ef8bf4fcc299ab89dba34ea691a26)'} (E: d8a89807e471d3f8b938ab21df44cb26)`);
313
+ throw new Error(`couldn't get addr (${addr}) from local space ${this.opts.localSpace}. reason: ${resGet.errorMsg ?? 'unknown error (E: 926ef8bf4fcc299ab89dba34ea691a26)'} (E: d8a89807e471d3f8b938ab21df44cb26)`);
278
314
  }
279
315
  } catch (error) {
280
316
  console.error(`${lc} ${extractErrorMsg(error)}`);
@@ -18,11 +18,12 @@ import {
18
18
  } from './sync-saga-context-types.mjs';
19
19
  import { IbGibSpaceAny } from '../../witness/space/space-base-v1.mjs';
20
20
  import { putInSpace, registerNewIbGib } from '../../witness/space/space-helper.mjs';
21
- import { SyncIbGib_V1 } from '../sync-types.mjs';
21
+ import { SyncIbGib_V1, SyncSagaFrameDependencyGraph } from '../sync-types.mjs';
22
22
  import { validateSyncSagaFrame } from '../sync-helpers.mjs';
23
23
  import { validateKeystoneGraph, validateKeystoneTransition } from '../../keystone/keystone-helpers.mjs';
24
24
  import { KeystoneService_V1 } from '../../keystone/keystone-service-v1.mjs';
25
25
  import { KeystoneIbGib_V1 } from '../../keystone/keystone-types.mjs';
26
+ import { isIbGibWithAtom } from '../../common/other/ibgib-helper.mjs';
26
27
 
27
28
  const logalot = GLOBAL_LOG_A_LOT;
28
29
 
@@ -96,6 +97,24 @@ export async function parseSyncSagaContextIb({
96
97
  }
97
98
  }
98
99
 
100
+ export function isSyncSagaContextIbGib(x: any): x is SyncSagaContextIbGib_V1 {
101
+ const lc = `[${isSyncSagaContextIbGib.name}]`;
102
+ try {
103
+ if (logalot) { console.log(`${lc} starting... (I: 2bfa7f3cf5984b0c78aced881ce95226)`); }
104
+
105
+ const hasAtom = isIbGibWithAtom<SyncSagaContextIbGib_V1>(x, SYNC_SAGA_CONTEXT_ATOM);
106
+
107
+ // should be good enough in V1
108
+
109
+ return hasAtom;
110
+ } catch (error) {
111
+ console.error(`${lc} ${extractErrorMsg(error)}`);
112
+ throw error;
113
+ } finally {
114
+ if (logalot) { console.log(`${lc} complete.`); }
115
+ }
116
+ }
117
+
99
118
 
100
119
  /**
101
120
  * Validates ONLY the {@link context} ibgib itself and saga frame/msg stone(s)
@@ -109,7 +128,11 @@ export async function parseSyncSagaContextIb({
109
128
  *
110
129
  * @returns empty array if valid, else validation errors
111
130
  */
112
- export async function validateContextAndSagaFrame({ context }: { context: SyncSagaContextIbGib_V1 }): Promise<string[]> {
131
+ export async function validateContextAndSagaFrame({
132
+ context,
133
+ }: {
134
+ context: SyncSagaContextIbGib_V1,
135
+ }): Promise<string[]> {
113
136
  const lc = `[${validateContextAndSagaFrame.name}]`;
114
137
  try {
115
138
  if (logalot) { console.log(`${lc} starting... (I: 7797f8294bd8f7e5089cb722ad468226)`); }
@@ -178,13 +201,32 @@ export async function validateContextDomainPayloadIbGibs({ context }: { context:
178
201
  /**
179
202
  * move to sync-peer-helpers.mts as a pure function?
180
203
  */
181
- export async function authenticateContext({ context }: { context: SyncSagaContextIbGib_V1 }): Promise<string[]> {
204
+ export async function authenticateContext({
205
+ context,
206
+ fullSagaHistory
207
+ }: {
208
+ context: SyncSagaContextIbGib_V1,
209
+ fullSagaHistory: SyncSagaFrameDependencyGraph[],
210
+ }): Promise<string[]> {
182
211
  const lc = `[${authenticateContext.name}]`;
183
212
  try {
184
213
  if (logalot) { console.log(`${lc} starting... (I: 2677a482dfa873dcd1aa04a3031ff826)`); }
185
214
 
186
215
  console.error(`${lc} NAG ERROR (NOT THROWN): not implemented. // todo: authenticate (v1 must have this after we get merge logic workflow going) (E: bc3a78f2dab18ab64c36d055a4b50526)`);
187
216
 
217
+ // ensure the same identity rel8n timeline is in the first saga ibgib.
218
+
219
+ for (const sagaFrameDepGraph of fullSagaHistory) {
220
+ sagaFrameDepGraph.identities
221
+ }
222
+
223
+
224
+ // each saga ibgib should be updated with a new identity rel8n. each
225
+ // rel8n should correspond to each evolution of the keystone.
226
+
227
+ // if (context.sagaFrame.rel8ns?.sessionKeystone)
228
+ // context.signedSessionKeystone
229
+
188
230
  return [];
189
231
  } catch (error) {
190
232
  console.error(`${lc} ${extractErrorMsg(error)}`);
@@ -197,7 +239,13 @@ export async function authenticateContext({ context }: { context: SyncSagaContex
197
239
  /**
198
240
  * move to sync-peer-helpers.mts as a pure function?
199
241
  */
200
- export async function authorizeContext({ context }: { context: SyncSagaContextIbGib_V1 }): Promise<string[]> {
242
+ export async function authorizeContext({
243
+ context,
244
+ fullSagaHistory
245
+ }: {
246
+ context: SyncSagaContextIbGib_V1,
247
+ fullSagaHistory: SyncSagaFrameDependencyGraph[],
248
+ }): Promise<string[]> {
201
249
  const lc = `[${authorizeContext.name}]`;
202
250
  try {
203
251
  if (logalot) { console.log(`${lc} starting... (I: 48c918b41ceec0cd489ca3b8819e6826)`); }
@@ -100,4 +100,21 @@ export interface SyncSagaContextIbGib_V1 extends IbGib_V1<SyncSagaContextData_V1
100
100
  * previous frame of the keystone.
101
101
  */
102
102
  signedSessionKeystone?: KeystoneIbGib_V1;
103
+
104
+ /**
105
+ * If identity is used in the sync transaction, this should be provided. It
106
+ * will drive both primary identity keystone evolution (to create session
107
+ * keystone), as well as signing the session keystone itself.
108
+ *
109
+ * when a peer transmits the context ibgib, this does not need to be
110
+ * transmitted. Note, however, that if sync is occuring between two remote
111
+ * peers and the peer design is not a proxy-based one, then the receiver
112
+ * should assign this with their own provider function.
113
+ *
114
+ * @returns the identity secret when needed to sign/evolve keystone
115
+ *
116
+ * NOTE: Not 100% sure where I'm putting this so this may end up being
117
+ * unused and should thus be removed. Right now, I think this will work.
118
+ */
119
+ fnIdentitySecret?: () => Promise<string>;
103
120
  }