@ibgib/core-gib 0.1.23 → 0.1.25
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.
- package/dist/common/other/graph-helper.d.mts +17 -0
- package/dist/common/other/graph-helper.d.mts.map +1 -1
- package/dist/common/other/graph-helper.mjs +44 -0
- package/dist/common/other/graph-helper.mjs.map +1 -1
- package/dist/sync/graft-info/graft-info-helpers.mjs +2 -2
- package/dist/sync/graft-info/graft-info-helpers.mjs.map +1 -1
- package/dist/sync/sync-conflict.respec.mjs +10 -15
- package/dist/sync/sync-conflict.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-constants.respec.mjs +10 -12
- package/dist/sync/sync-innerspace-constants.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-deep-updates.respec.mjs +10 -12
- package/dist/sync/sync-innerspace-deep-updates.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-dest-ahead.respec.mjs +10 -12
- package/dist/sync/sync-innerspace-dest-ahead.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs +9 -12
- package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-partial-update.respec.mjs +9 -14
- package/dist/sync/sync-innerspace-partial-update.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace.respec.mjs +9 -12
- package/dist/sync/sync-innerspace.respec.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.d.mts +2 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs +4 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts +24 -11
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs +58 -44
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-types.d.mts +29 -6
- package/dist/sync/sync-peer/sync-peer-types.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-v1.d.mts +29 -30
- package/dist/sync/sync-peer/sync-peer-v1.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-v1.mjs +105 -198
- package/dist/sync/sync-peer/sync-peer-v1.mjs.map +1 -1
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts +19 -2
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts.map +1 -1
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs +37 -4
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs.map +1 -1
- package/dist/sync/sync-saga-coordinator.d.mts +12 -12
- package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
- package/dist/sync/sync-saga-coordinator.mjs +281 -218
- package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts +51 -6
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts.map +1 -1
- package/dist/sync/sync-types.d.mts +36 -9
- package/dist/sync/sync-types.d.mts.map +1 -1
- package/dist/sync/sync-types.mjs +1 -2
- package/dist/sync/sync-types.mjs.map +1 -1
- package/package.json +1 -1
- package/src/common/other/graph-helper.mts +53 -0
- package/src/sync/graft-info/graft-info-helpers.mts +3 -3
- package/src/sync/sync-conflict.respec.mts +10 -17
- package/src/sync/sync-helpers.mts +6 -6
- package/src/sync/sync-innerspace-constants.respec.mts +10 -12
- package/src/sync/sync-innerspace-deep-updates.respec.mts +10 -12
- package/src/sync/sync-innerspace-dest-ahead.respec.mts +10 -12
- package/src/sync/sync-innerspace-multiple-timelines.respec.mts +9 -12
- package/src/sync/sync-innerspace-partial-update.respec.mts +9 -14
- package/src/sync/sync-innerspace.respec.mts +9 -12
- package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mts +7 -0
- package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mts +75 -50
- package/src/sync/sync-peer/sync-peer-types.mts +35 -11
- package/src/sync/sync-peer/sync-peer-v1.mts +136 -196
- package/src/sync/sync-saga-context/sync-saga-context-helpers.mts +37 -8
- package/src/sync/sync-saga-coordinator.mts +318 -260
- package/src/sync/sync-saga-message/sync-saga-message-types.mts +56 -4
- package/src/sync/sync-types.mts +46 -13
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @module SyncPeer_V1 witness class
|
|
2
|
+
* @module SyncPeer_V1 witness class for base class plumbing of sync peers.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* NOTE: All push/pulls in this were done to get to compile. These should mostly
|
|
6
|
-
* not be single push/pull calls but should be batched with multiple addresses
|
|
7
|
-
* NOTE: All push/pulls in this were done to get to compile. These should mostly
|
|
8
|
-
* not be single push/pull calls but should be batched with multiple addresses
|
|
9
|
-
* NOTE: All push/pulls in this were done to get to compile. These should mostly
|
|
10
|
-
* not be single push/pull calls but should be batched with multiple addresses
|
|
11
|
-
* NOTE: All push/pulls in this were done to get to compile. These should mostly
|
|
12
|
-
* not be single push/pull calls but should be batched with multiple addresses
|
|
13
|
-
* NOTE: All push/pulls in this were done to get to compile. These should mostly
|
|
14
|
-
* not be single push/pull calls but should be batched with multiple addresses
|
|
4
|
+
* You are expected to implement concrete peer classes for concrete architecture.
|
|
15
5
|
*/
|
|
16
6
|
import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
17
7
|
import { IbGibAddr } from '@ibgib/ts-gib/dist/types.mjs';
|
|
18
8
|
import { SubjectWitness } from '../../common/pubsub/subject/subject-types.mjs';
|
|
19
9
|
import { SyncSagaContextIbGib_V1 } from '../sync-saga-context/sync-saga-context-types.mjs';
|
|
20
|
-
import { SyncPeerData_V1, SyncPeerRel8ns_V1, SyncPeerWitness } from './sync-peer-types.mjs';
|
|
10
|
+
import { InitializeSyncPeerOpts, SyncPeerData_V1, SyncPeerRel8ns_V1, SyncPeerWitness } from './sync-peer-types.mjs';
|
|
21
11
|
import { LightWitnessBase_V1 } from '../../witness/light-witness-base-v1.mjs';
|
|
22
12
|
import { IbGibSpaceAny } from '../../witness/space/space-base-v1.mjs';
|
|
23
13
|
/**
|
|
@@ -30,14 +20,23 @@ import { IbGibSpaceAny } from '../../witness/space/space-base-v1.mjs';
|
|
|
30
20
|
* 2. Send Request (RPC)
|
|
31
21
|
* 3. Pull Response & Dependencies (Receiver -> Sender)
|
|
32
22
|
*/
|
|
33
|
-
export declare abstract class SyncPeer_V1 extends LightWitnessBase_V1<SyncPeerData_V1, SyncPeerRel8ns_V1> implements SyncPeerWitness {
|
|
23
|
+
export declare abstract class SyncPeer_V1<TInitializeOpts extends InitializeSyncPeerOpts = InitializeSyncPeerOpts> extends LightWitnessBase_V1<SyncPeerData_V1, SyncPeerRel8ns_V1> implements SyncPeerWitness<TInitializeOpts> {
|
|
34
24
|
protected lc: string;
|
|
35
|
-
|
|
36
|
-
senderTempSpace: IbGibSpaceAny;
|
|
25
|
+
opts: TInitializeOpts | undefined;
|
|
37
26
|
payloadIbGibsDomainReceived$: SubjectWitness<IbGib_V1>;
|
|
38
27
|
get classname(): string;
|
|
39
|
-
constructor(
|
|
28
|
+
constructor(initialData: SyncPeerData_V1, initialRel8ns?: SyncPeerRel8ns_V1);
|
|
40
29
|
initialize(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* base implementation just sets the opts property.
|
|
32
|
+
*
|
|
33
|
+
* override this in concrete classes for further initialization code
|
|
34
|
+
* specific to the sender.
|
|
35
|
+
*
|
|
36
|
+
* @see {@link SyncPeerWitness.opts}
|
|
37
|
+
*/
|
|
38
|
+
initializeSender(opts: TInitializeOpts): Promise<void>;
|
|
39
|
+
setOptionalOpts(arg: Partial<TInitializeOpts>): void;
|
|
41
40
|
protected abstract ensureReceiverTempSpace(): Promise<IbGibSpaceAny>;
|
|
42
41
|
/**
|
|
43
42
|
* Witness the synchronization context (Send/Receive).
|
|
@@ -50,7 +49,19 @@ export declare abstract class SyncPeer_V1 extends LightWitnessBase_V1<SyncPeerDa
|
|
|
50
49
|
*/
|
|
51
50
|
witness(context: SyncSagaContextIbGib_V1): Promise<SyncSagaContextIbGib_V1 | undefined>;
|
|
52
51
|
/**
|
|
53
|
-
*
|
|
52
|
+
* This is responsible for:
|
|
53
|
+
*
|
|
54
|
+
* * sending outgoing {@link context}, the sync saga frame and msg stone(s),
|
|
55
|
+
* and identities...
|
|
56
|
+
* * AND sending OUTGOING domain ibgibs
|
|
57
|
+
* {@link SyncSagaContextIbGib_V1.payloadIbGibsDomain}
|
|
58
|
+
* * getting back the other end's resultant context ibgib, sync saga frame
|
|
59
|
+
* and msg stone(s), and identities in their entirety...
|
|
60
|
+
* * AND stream/receiving the RESPONSE payload domain ibgibs, publishing
|
|
61
|
+
* these to this.payloadIbGibsDomainReceived$.
|
|
62
|
+
*
|
|
63
|
+
* So this returns the RESPONSE context, possibly BEFORE the RESPONSE domain
|
|
64
|
+
* ibgibs have been completely received/streamed. The coordinator is responsible
|
|
54
65
|
*/
|
|
55
66
|
protected abstract sendContextRequest(context: SyncSagaContextIbGib_V1): Promise<SyncSagaContextIbGib_V1 | undefined>;
|
|
56
67
|
/**
|
|
@@ -77,18 +88,6 @@ export declare abstract class SyncPeer_V1 extends LightWitnessBase_V1<SyncPeerDa
|
|
|
77
88
|
protected authorizeContext({ context }: {
|
|
78
89
|
context: SyncSagaContextIbGib_V1;
|
|
79
90
|
}): Promise<string[]>;
|
|
80
|
-
/**
|
|
81
|
-
* Helper to orchestrate the PUSH of a Context's dependency graph.
|
|
82
|
-
*/
|
|
83
|
-
protected pushContextGraph({ context }: {
|
|
84
|
-
context: SyncSagaContextIbGib_V1;
|
|
85
|
-
}): Promise<void>;
|
|
86
|
-
/**
|
|
87
|
-
* Helper to orchestrate the PULL of a Context's dependency graph.
|
|
88
|
-
*/
|
|
89
|
-
protected pullContextGraph({ context }: {
|
|
90
|
-
context: SyncSagaContextIbGib_V1;
|
|
91
|
-
}): Promise<void>;
|
|
92
91
|
/**
|
|
93
92
|
* Abstract accessor to get an IbGib from the Local space/store.
|
|
94
93
|
* Needed for inspecting rela8ns during the graph walk.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-peer-v1.d.mts","sourceRoot":"","sources":["../../../src/sync/sync-peer/sync-peer-v1.mts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sync-peer-v1.d.mts","sourceRoot":"","sources":["../../../src/sync/sync-peer/sync-peer-v1.mts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAKzD,OAAO,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,kDAAkD,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACpH,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAStE;;;;;;;;;GASG;AACH,8BAAsB,WAAW,CAAC,eAAe,SAAS,sBAAsB,GAAG,sBAAsB,CACrG,SAAQ,mBAAmB,CAAC,eAAe,EAAE,iBAAiB,CAC9D,YAAW,eAAe,CAAC,eAAe,CAAC;IAE3C,SAAS,CAAC,EAAE,EAAE,MAAM,CAA2B;IAExC,IAAI,EAAE,eAAe,GAAG,SAAS,CAAC;IAClC,4BAA4B,EAAG,cAAc,CAA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|
@@ -1,25 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @module SyncPeer_V1 witness class
|
|
2
|
+
* @module SyncPeer_V1 witness class for base class plumbing of sync peers.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* NOTE: All push/pulls in this were done to get to compile. These should mostly
|
|
6
|
-
* not be single push/pull calls but should be batched with multiple addresses
|
|
7
|
-
* NOTE: All push/pulls in this were done to get to compile. These should mostly
|
|
8
|
-
* not be single push/pull calls but should be batched with multiple addresses
|
|
9
|
-
* NOTE: All push/pulls in this were done to get to compile. These should mostly
|
|
10
|
-
* not be single push/pull calls but should be batched with multiple addresses
|
|
11
|
-
* NOTE: All push/pulls in this were done to get to compile. These should mostly
|
|
12
|
-
* not be single push/pull calls but should be batched with multiple addresses
|
|
13
|
-
* NOTE: All push/pulls in this were done to get to compile. These should mostly
|
|
14
|
-
* not be single push/pull calls but should be batched with multiple addresses
|
|
4
|
+
* You are expected to implement concrete peer classes for concrete architecture.
|
|
15
5
|
*/
|
|
16
6
|
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
17
|
-
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
18
7
|
import { GLOBAL_LOG_A_LOT } from '../../core-constants.mjs';
|
|
19
|
-
import { SYNC_MSG_REL8N_NAME, SYNC_SAGA_PAYLOAD_ADDRS_DOMAIN } from '../sync-constants.mjs';
|
|
20
8
|
import { LightWitnessBase_V1 } from '../../witness/light-witness-base-v1.mjs';
|
|
21
9
|
import { newupSubject } from '../../common/pubsub/subject/subject-helper.mjs';
|
|
22
|
-
import {
|
|
10
|
+
import { validateContextAndSagaFrame } from '../sync-saga-context/sync-saga-context-helpers.mjs';
|
|
23
11
|
import { getFromSpace } from '../../witness/space/space-helper.mjs';
|
|
24
12
|
const logalot = GLOBAL_LOG_A_LOT || true;
|
|
25
13
|
const logalotControlDomain = true;
|
|
@@ -36,8 +24,7 @@ const lcControlDomain = '[ControlDomain]';
|
|
|
36
24
|
*/
|
|
37
25
|
export class SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
38
26
|
lc = `[${SyncPeer_V1.name}]`;
|
|
39
|
-
|
|
40
|
-
senderTempSpace;
|
|
27
|
+
opts;
|
|
41
28
|
payloadIbGibsDomainReceived$;
|
|
42
29
|
get classname() {
|
|
43
30
|
if (!this.data) {
|
|
@@ -48,14 +35,62 @@ export class SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
48
35
|
}
|
|
49
36
|
return this.data.classname;
|
|
50
37
|
}
|
|
51
|
-
constructor(
|
|
38
|
+
constructor(initialData, initialRel8ns) {
|
|
52
39
|
super(initialData, initialRel8ns);
|
|
53
|
-
this.senderSpace = senderSpace;
|
|
54
|
-
this.senderTempSpace = senderTempSpace;
|
|
55
40
|
}
|
|
56
41
|
async initialize() {
|
|
57
42
|
this.payloadIbGibsDomainReceived$ = await newupSubject();
|
|
58
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* base implementation just sets the opts property.
|
|
46
|
+
*
|
|
47
|
+
* override this in concrete classes for further initialization code
|
|
48
|
+
* specific to the sender.
|
|
49
|
+
*
|
|
50
|
+
* @see {@link SyncPeerWitness.opts}
|
|
51
|
+
*/
|
|
52
|
+
async initializeSender(opts) {
|
|
53
|
+
const lc = `${this.lc}[${this.initializeSender.name}]`;
|
|
54
|
+
try {
|
|
55
|
+
if (logalot) {
|
|
56
|
+
console.log(`${lc} starting... (I: 31bd5fda37c89fa37fbaf14daf5fe726)`);
|
|
57
|
+
}
|
|
58
|
+
this.opts = opts;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
if (logalot) {
|
|
66
|
+
console.log(`${lc} complete.`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
setOptionalOpts(arg) {
|
|
71
|
+
const lc = `${this.lc}[${this.setOptionalOpts.name}]`;
|
|
72
|
+
try {
|
|
73
|
+
if (logalot) {
|
|
74
|
+
console.log(`${lc} starting... (I: ae5ddbd3577db267f84743175a736626)`);
|
|
75
|
+
}
|
|
76
|
+
if (!this.opts) {
|
|
77
|
+
throw new Error(`(UNEXPECTED) this.opts falsy? (E: 0dd4d6080a6e2f31d86cf4d86e11b826)`);
|
|
78
|
+
}
|
|
79
|
+
if (logalot) {
|
|
80
|
+
console.log(`${lc} updating opts. arg keys: ${Object.keys(arg)} (I: 452d78a558f8fc3468c8e2e68c70b226)`);
|
|
81
|
+
}
|
|
82
|
+
this.opts = { ...this.opts, ...arg };
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
if (logalot) {
|
|
90
|
+
console.log(`${lc} complete.`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
59
94
|
/**
|
|
60
95
|
* Witness the synchronization context (Send/Receive).
|
|
61
96
|
*
|
|
@@ -71,26 +106,34 @@ export class SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
71
106
|
if (logalot) {
|
|
72
107
|
console.log(`${lc} starting...`);
|
|
73
108
|
}
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
// validate, authenticate, and authorize the context, sagaFrame, and identity(s)
|
|
78
|
-
const validationErrors = await validateContext({ context });
|
|
79
|
-
if (validationErrors.length > 0) {
|
|
80
|
-
throw new Error(`invalid context received. validationErrors: ${validationErrors} (E: 8b34c875c968af29bc433138e57a7826)`);
|
|
109
|
+
if (!this.opts) {
|
|
110
|
+
throw new Error(`(UNEXPECTED) this.opts falsy? Concrete class should have initialized sender opts by now. (E: 0b9e28287318fdf8bf9f5a6886a24826)`);
|
|
81
111
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
//
|
|
112
|
+
// NOTE: There are two basic types of peers:
|
|
113
|
+
// * local-only (peer)
|
|
114
|
+
// * this peer is both sender/receiver peer
|
|
115
|
+
// * for local merges and relatively fast spaces
|
|
116
|
+
// * proxy to remote space
|
|
117
|
+
// * this peer is both sender/receiver peer
|
|
118
|
+
// * works directly with remote/outerspaces
|
|
119
|
+
// * Less efficient over-the-wire xfer due to chatiness
|
|
120
|
+
// * symmetric node sender/receiver peers
|
|
121
|
+
// * separate sender/receiver classes
|
|
122
|
+
// * e.g., SyncPeerClient[Substrate]Sender_V1,
|
|
123
|
+
// SyncPeerClient[Substrate]Receiver_V1
|
|
124
|
+
// * More efficient over-the-wire xfer
|
|
125
|
+
// * Most difficult to mentally model
|
|
126
|
+
// * sender.witness does the pushing out
|
|
127
|
+
// * what the sender/initiator's coordinator has a reference to
|
|
128
|
+
// * receiver.witness does the coming in
|
|
129
|
+
// * lives on a server/remote instance with its own coordinator
|
|
130
|
+
// instance
|
|
131
|
+
// * must do its own validation/authn/authz for possible MITM
|
|
132
|
+
// issues
|
|
133
|
+
// The following is a sketch where some of these may be blurred
|
|
91
134
|
// persist the context, sagaframe, identity(s) ONLY in the receiver's durable space
|
|
92
135
|
// if sending domain ibgibs...
|
|
93
|
-
// verify the domain ibgibs intrinsically.
|
|
136
|
+
// verify the domain ibgibs intrinsically.
|
|
94
137
|
// persist the domain ibgibs in the receiver's temp space (push all addrs?)
|
|
95
138
|
// await until all domain ibgibs are in receiver's temp space
|
|
96
139
|
// process the context with the receiver's coordinator to get a new response context
|
|
@@ -98,14 +141,26 @@ export class SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
98
141
|
// validate context intrinsically
|
|
99
142
|
// validate return identity if present
|
|
100
143
|
// persist the response context's dependency graph (context, saga frame and msg(s), identities)
|
|
101
|
-
// if response has payload domain ibgibs,
|
|
144
|
+
// if response has payload domain ibgibs,
|
|
102
145
|
// spin off...
|
|
103
146
|
// pull domain ibgibs to local temp space
|
|
104
147
|
// publish domain ibgibs to observable
|
|
105
148
|
// when all domain ibgibs are pulled, publish complete to the observable
|
|
106
149
|
// return resulting context ibgib (which the caller should get BEFORE the domain ibgibs observable completes)
|
|
107
|
-
//
|
|
108
|
-
await
|
|
150
|
+
// validate, authenticate, and authorize the context, sagaFrame, and identity(s)
|
|
151
|
+
const validationErrors = await validateContextAndSagaFrame({ context });
|
|
152
|
+
if (validationErrors.length > 0) {
|
|
153
|
+
throw new Error(`invalid context received. validationErrors: ${validationErrors} (E: 8b34c875c968af29bc433138e57a7826)`);
|
|
154
|
+
}
|
|
155
|
+
const authenticationErrors = await this.authenticateContext({ context });
|
|
156
|
+
if (authenticationErrors.length > 0) {
|
|
157
|
+
throw new Error(`invalid context authentication. authenticationErrors: ${authenticationErrors} (E: da89da5ee1269aeb78952d475d607526)`);
|
|
158
|
+
}
|
|
159
|
+
const authorizationErrors = await this.authorizeContext({ context });
|
|
160
|
+
if (authorizationErrors.length > 0) {
|
|
161
|
+
throw new Error(`invalid context authorization. authorizationErrors: ${authorizationErrors} (E: 8ddc284a758cf10ba829334c1babb826)`);
|
|
162
|
+
}
|
|
163
|
+
// at this point, we have a valid, authenticated, authorized context
|
|
109
164
|
// 2. EXECUTE: Trigger Remote Processing
|
|
110
165
|
const response = await this.sendContextRequest(context);
|
|
111
166
|
if (!response) {
|
|
@@ -114,13 +169,12 @@ export class SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
114
169
|
}
|
|
115
170
|
return undefined;
|
|
116
171
|
}
|
|
117
|
-
// at this point,
|
|
118
|
-
//
|
|
172
|
+
// at this point, all outgoing payload domain ibgibs have been sent.
|
|
173
|
+
// we have received the response context, wherein the sync saga
|
|
174
|
+
// frame/msg stone(s) and any keystones should be evolved. Depending
|
|
119
175
|
// on the concrete implementation, if there are domain ibgibs to
|
|
120
|
-
// receive, they may
|
|
121
|
-
//
|
|
122
|
-
// 3. PULL: Ensure Response Data is available on Sender (Local)
|
|
123
|
-
await this.pullContextGraph({ context: response });
|
|
176
|
+
// receive, they may still be transferring. These will be published
|
|
177
|
+
// to this.payloadIbGibsDomainReceived$
|
|
124
178
|
return response;
|
|
125
179
|
}
|
|
126
180
|
catch (error) {
|
|
@@ -177,156 +231,6 @@ export class SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
177
231
|
}
|
|
178
232
|
}
|
|
179
233
|
}
|
|
180
|
-
/**
|
|
181
|
-
* Helper to orchestrate the PUSH of a Context's dependency graph.
|
|
182
|
-
*/
|
|
183
|
-
async pushContextGraph({ context }) {
|
|
184
|
-
const lc = `[${SyncPeer_V1.name}][pushContextGraph]`;
|
|
185
|
-
// A. Push Context Envelope
|
|
186
|
-
const contextAddr = getIbGibAddr({ ibGib: context });
|
|
187
|
-
if (logalotControlDomain) {
|
|
188
|
-
console.log(`${lc}${lcControlDomain} PUSH Context Envelope -> ${contextAddr} (I: 3f4e5a6b7c8d9e0f)`);
|
|
189
|
-
}
|
|
190
|
-
await this.push([contextAddr]);
|
|
191
|
-
// B. Push Saga Frame & Immediate Deps (Msg, Identity)
|
|
192
|
-
const frameAddr = context.rel8ns?.sagaFrame?.[0];
|
|
193
|
-
if (frameAddr) {
|
|
194
|
-
if (logalotControlDomain) {
|
|
195
|
-
console.log(`${lc}${lcControlDomain} PUSH CONTROL: Saga Frame -> ${frameAddr} (I: 4a5b6c7d8e9f0a1b)`);
|
|
196
|
-
}
|
|
197
|
-
await this.push([frameAddr]);
|
|
198
|
-
// We inspect the local frame to find its immediate deps
|
|
199
|
-
const frame = await this.getLocalIbGib(frameAddr);
|
|
200
|
-
if (frame) {
|
|
201
|
-
// Msg Stone
|
|
202
|
-
const msgAddrs = frame.rel8ns?.[SYNC_MSG_REL8N_NAME];
|
|
203
|
-
if (msgAddrs) {
|
|
204
|
-
for (const addr of msgAddrs) {
|
|
205
|
-
if (logalotControlDomain) {
|
|
206
|
-
console.log(`${lc}${lcControlDomain} PUSH CONTROL: Msg Stone -> ${addr} (I: 5b6c7d8e9f0a1b2c)`);
|
|
207
|
-
}
|
|
208
|
-
await this.push([addr]);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
// Identity
|
|
212
|
-
const idAddrs = frame.rel8ns?.identity;
|
|
213
|
-
if (idAddrs) {
|
|
214
|
-
for (const addr of idAddrs) {
|
|
215
|
-
if (logalotControlDomain) {
|
|
216
|
-
console.log(`${lc}${lcControlDomain} PUSH CONTROL: Identity -> ${addr} (I: 6c7d8e9f0a1b2c3d)`);
|
|
217
|
-
}
|
|
218
|
-
await this.push([addr]);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
// C. Push Session Identity
|
|
224
|
-
const sessionKeystoneAddr = context.rel8ns?.sessionKeystone?.[0];
|
|
225
|
-
if (sessionKeystoneAddr) {
|
|
226
|
-
if (logalotControlDomain) {
|
|
227
|
-
console.log(`${lc}${lcControlDomain} PUSH CONTROL: Session Keystone -> ${sessionKeystoneAddr} (I: 7d8e9f0a1b2c3d4e)`);
|
|
228
|
-
}
|
|
229
|
-
await this.push([sessionKeystoneAddr]);
|
|
230
|
-
}
|
|
231
|
-
// D. Push Payloads (Deep/Soft)
|
|
232
|
-
// For payloads, the Peer is just a transport. It doesn't know the structure.
|
|
233
|
-
// It relies on "push" handling the "deep" transfer if needed, or we explicitly iterate if we had a graph.
|
|
234
|
-
// But since we are "Witnessing", we usually assume "push(addr)" acts like "copy(addr, recursive=true)"?
|
|
235
|
-
// Or do we need to be explicit?
|
|
236
|
-
// User said: "payloads should be flat... sync coordinator is the one doing the heavy lifting".
|
|
237
|
-
// So we just push the addrs listed.
|
|
238
|
-
// 1. Control Payloads
|
|
239
|
-
// const controlAddrs = context.data?.[SYNC_SAGA_PAYLOAD_ADDRS_CONTROL];
|
|
240
|
-
// if (controlAddrs && controlAddrs.length > 0) {
|
|
241
|
-
// if (logalotControlDomain) { console.log(`${lc}${lcControlDomain} PUSH CONTROL PAYLOADS (${controlAddrs.length}): ${controlAddrs.join(', ')} (I: 8e9f0a1b2c3d4e5f)`); }
|
|
242
|
-
// for (const addr of controlAddrs) {
|
|
243
|
-
// await this.push(addr);
|
|
244
|
-
// }
|
|
245
|
-
// }
|
|
246
|
-
// 2. Domain Payloads
|
|
247
|
-
const domainAddrs = context.data?.[SYNC_SAGA_PAYLOAD_ADDRS_DOMAIN];
|
|
248
|
-
if (domainAddrs && domainAddrs.length > 0) {
|
|
249
|
-
if (logalotControlDomain) {
|
|
250
|
-
console.log(`${lc}${lcControlDomain} PUSH DOMAIN PAYLOADS (${domainAddrs.length}): ${domainAddrs.join(', ')} (I: 9f0a1b2c3d4e5f6a)`);
|
|
251
|
-
}
|
|
252
|
-
for (const addr of domainAddrs) {
|
|
253
|
-
await this.push([addr]);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
if (logalotControlDomain) {
|
|
257
|
-
console.log(`${lc}${lcControlDomain} PUSH COMPLETE for context ${contextAddr} (I: a0b1c2d3e4f5a6b7)`);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Helper to orchestrate the PULL of a Context's dependency graph.
|
|
262
|
-
*/
|
|
263
|
-
async pullContextGraph({ context }) {
|
|
264
|
-
const lc = `[${SyncPeer_V1.name}][pullContextGraph]`;
|
|
265
|
-
// A. Pull Context Envelope
|
|
266
|
-
const contextAddr = getIbGibAddr({ ibGib: context });
|
|
267
|
-
if (logalotControlDomain) {
|
|
268
|
-
console.log(`${lc}${lcControlDomain} PULL Context Envelope <- ${contextAddr} (I: b1c2d3e4f5a6b7c8)`);
|
|
269
|
-
}
|
|
270
|
-
await this.pull([contextAddr]);
|
|
271
|
-
// B. Pull Saga Frame & Immediate Deps
|
|
272
|
-
const frameAddr = context.rel8ns?.sagaFrame?.[0];
|
|
273
|
-
if (frameAddr) {
|
|
274
|
-
if (logalotControlDomain) {
|
|
275
|
-
console.log(`${lc}${lcControlDomain} PULL CONTROL: Saga Frame <- ${frameAddr} (I: c2d3e4f5a6b7c8d9)`);
|
|
276
|
-
}
|
|
277
|
-
await this.pull([frameAddr]);
|
|
278
|
-
// Inspect REMOTE frame? We need to have pulled it first.
|
|
279
|
-
const frame = await this.getLocalIbGib(frameAddr); // Should be local now
|
|
280
|
-
if (frame) {
|
|
281
|
-
const msgAddrs = frame.rel8ns?.[SYNC_MSG_REL8N_NAME];
|
|
282
|
-
if (msgAddrs) {
|
|
283
|
-
for (const addr of msgAddrs) {
|
|
284
|
-
if (logalotControlDomain) {
|
|
285
|
-
console.log(`${lc}${lcControlDomain} PULL CONTROL: Msg Stone <- ${addr} (I: d3e4f5a6b7c8d9e0)`);
|
|
286
|
-
}
|
|
287
|
-
await this.pull([addr]);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
const idAddrs = frame.rel8ns?.identity;
|
|
291
|
-
if (idAddrs) {
|
|
292
|
-
for (const addr of idAddrs) {
|
|
293
|
-
if (logalotControlDomain) {
|
|
294
|
-
console.log(`${lc}${lcControlDomain} PULL CONTROL: Identity <- ${addr} (I: e4f5a6b7c8d9e0f1)`);
|
|
295
|
-
}
|
|
296
|
-
await this.pull([addr]);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
// C. Pull Session Identity
|
|
302
|
-
const sessionKeystoneAddr = context.rel8ns?.sessionKeystone?.[0];
|
|
303
|
-
if (sessionKeystoneAddr) {
|
|
304
|
-
if (logalotControlDomain) {
|
|
305
|
-
console.log(`${lc}${lcControlDomain} PULL CONTROL: Session Keystone <- ${sessionKeystoneAddr} (I: f5a6b7c8d9e0f1a2)`);
|
|
306
|
-
}
|
|
307
|
-
await this.pull([sessionKeystoneAddr]);
|
|
308
|
-
}
|
|
309
|
-
// D. Pull Payloads
|
|
310
|
-
// const controlAddrs = context.data?.[SYNC_SAGA_PAYLOAD_ADDRS_CONTROL];
|
|
311
|
-
// if (controlAddrs && controlAddrs.length > 0) {
|
|
312
|
-
// if (logalotControlDomain) { console.log(`${lc}${lcControlDomain} PULL CONTROL PAYLOADS (${controlAddrs.length}): ${controlAddrs.join(', ')} (I: a6b7c8d9e0f1a2b3)`); }
|
|
313
|
-
// for (const addr of controlAddrs) {
|
|
314
|
-
// await this.pull(addr);
|
|
315
|
-
// }
|
|
316
|
-
// }
|
|
317
|
-
const domainAddrs = context.data?.[SYNC_SAGA_PAYLOAD_ADDRS_DOMAIN];
|
|
318
|
-
if (domainAddrs && domainAddrs.length > 0) {
|
|
319
|
-
if (logalotControlDomain) {
|
|
320
|
-
console.log(`${lc}${lcControlDomain} PULL DOMAIN PAYLOADS (${domainAddrs.length}): ${domainAddrs.join(', ')} (I: b7c8d9e0f1a2b3c4)`);
|
|
321
|
-
}
|
|
322
|
-
for (const addr of domainAddrs) {
|
|
323
|
-
await this.pull([addr]);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
if (logalotControlDomain) {
|
|
327
|
-
console.log(`${lc}${lcControlDomain} PULL COMPLETE for context ${contextAddr} (I: c8d9e0f1a2b3c4d5)`);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
234
|
/**
|
|
331
235
|
* Abstract accessor to get an IbGib from the Local space/store.
|
|
332
236
|
* Needed for inspecting rela8ns during the graph walk.
|
|
@@ -340,13 +244,16 @@ export class SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
340
244
|
console.log(`${lc} starting... (I: 27b248cb9801eeb2386b71485389a826)`);
|
|
341
245
|
}
|
|
342
246
|
console.warn(`${lc} possibly a bottleneck here, getLocalIbGib only gets a single ibgib... (W: 2fd448a435480e6b128f6b8bcbef4826)`);
|
|
343
|
-
|
|
247
|
+
if (!this.opts) {
|
|
248
|
+
throw new Error(`(UNEXPECTED) this.opts falsy? (E: cfb9431f2fb851f24a6c88e80c3b3326)`);
|
|
249
|
+
}
|
|
250
|
+
const resGet = await getFromSpace({ space: this.opts.senderSpace, addr });
|
|
344
251
|
if (resGet.success && resGet.ibGibs && resGet.ibGibs.length === 1) {
|
|
345
252
|
const ibGib = resGet.ibGibs[0];
|
|
346
253
|
return ibGib;
|
|
347
254
|
}
|
|
348
255
|
else {
|
|
349
|
-
throw new Error(`couldn't get addr (${addr}) from local space ${this.senderSpace}. reason: ${resGet.errorMsg ?? 'unknown error (E: 926ef8bf4fcc299ab89dba34ea691a26)'} (E: d8a89807e471d3f8b938ab21df44cb26)`);
|
|
256
|
+
throw new Error(`couldn't get addr (${addr}) from local space ${this.opts.senderSpace}. reason: ${resGet.errorMsg ?? 'unknown error (E: 926ef8bf4fcc299ab89dba34ea691a26)'} (E: d8a89807e471d3f8b938ab21df44cb26)`);
|
|
350
257
|
}
|
|
351
258
|
}
|
|
352
259
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-peer-v1.mjs","sourceRoot":"","sources":["../../../src/sync/sync-peer/sync-peer-v1.mts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sync-peer-v1.mjs","sourceRoot":"","sources":["../../../src/sync/sync-peer/sync-peer-v1.mts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAMlF,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAK5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAC9E,OAAO,EAAE,2BAA2B,EAAE,MAAM,oDAAoD,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEpE,MAAM,OAAO,GAAG,gBAAgB,IAAI,IAAI,CAAC;AACzC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAE1C;;;;;;;;;GASG;AACH,MAAM,OAAg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EAAE,8GAA8G,CAAC,CAAC;YAClI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;gBAAC,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;YAAC,CAAC;YAE3G,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;YAE1E,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAChE,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAC/B,OAAO,KAAK,CAAC;YACjB,CAAC;iBAAM,CAAC;gBACJ,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,sBAAsB,IAAI,CAAC,IAAI,CAAC,WAAW,aAAa,MAAM,CAAC,QAAQ,IAAI,qDAAqD,wCAAwC,CAAC,CAAC;YACxN,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACjD,MAAM,KAAK,CAAC;QAChB,CAAC;gBAAS,CAAC;YACP,IAAI,OAAO,EAAE,CAAC;gBAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;YAAC,CAAC;QACpD,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -54,9 +54,26 @@ export declare function parseSyncSagaContextIb({ ib, }: {
|
|
|
54
54
|
*/
|
|
55
55
|
export declare function createSyncSagaContext({ sagaFrame, sessionKeystones, payloadIbGibsDomain, localSpace, }: CreateSyncSagaContextOptions): Promise<SyncSagaContextIbGib_V1>;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* Validates ONLY the {@link context} ibgib itself and saga frame/msg stone(s)
|
|
58
|
+
* ({@link SyncSagaContextIbGib_V1.sagaFrame}).
|
|
59
|
+
*
|
|
60
|
+
* Does NOT...
|
|
61
|
+
* * validate keystones (authn or authz)
|
|
62
|
+
* * validate domain payload ibgibs...
|
|
63
|
+
* * intrinsically
|
|
64
|
+
* * in relation to this context (addrs match up)
|
|
65
|
+
*
|
|
66
|
+
* @returns empty array if valid, else validation errors
|
|
67
|
+
*/
|
|
68
|
+
export declare function validateContextAndSagaFrame({ context }: {
|
|
69
|
+
context: SyncSagaContextIbGib_V1;
|
|
70
|
+
}): Promise<string[]>;
|
|
71
|
+
/**
|
|
72
|
+
* validates the payload ibgibs ({@link SyncSagaContextIbGib_V1.payloadIbGibsDomain}) intrinsically
|
|
73
|
+
*
|
|
74
|
+
* @returns empty array if valid, else validation errors
|
|
58
75
|
*/
|
|
59
|
-
export declare function
|
|
76
|
+
export declare function validateContextDomainPayloadIbGibs({ context }: {
|
|
60
77
|
context: SyncSagaContextIbGib_V1;
|
|
61
78
|
}): Promise<string[]>;
|
|
62
79
|
//# sourceMappingURL=sync-saga-context-helpers.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-saga-context-helpers.d.mts","sourceRoot":"","sources":["../../../src/sync/sync-saga-context/sync-saga-context-helpers.mts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAAE,QAAQ,EAAG,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,8BAA8B,CAAC;AAMlD,OAAO,EACH,sBAAsB,EAAE,uBAAuB,EAAE,oBAAoB,EAExE,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAEtE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD;;GAEG;AACH,MAAM,WAAW,4BAA4B;IACzC;;OAEG;IACH,SAAS,EAAE,YAAY,CAAC;IACxB;;OAEG;IACH,gBAAgB,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC9B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,QAAQ,EAAE,CAAC;IACjC;;;OAGG;IACH,UAAU,EAAE,aAAa,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,EACvC,IAAI,GACP,EAAE;IACC,IAAI,EAAE,sBAAsB,CAAC;CAChC,GAAG,OAAO,CAAC,EAAE,CAAC,CAiBd;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,EACzC,EAAE,GACL,EAAE;IACC,EAAE,EAAE,EAAE,CAAC;CACV,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA2BhC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,qBAAqB,CAAC,EACxC,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,UAAU,GACb,EAAE,4BAA4B,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA8DjE;AAED
|
|
1
|
+
{"version":3,"file":"sync-saga-context-helpers.d.mts","sourceRoot":"","sources":["../../../src/sync/sync-saga-context/sync-saga-context-helpers.mts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAAE,QAAQ,EAAG,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,8BAA8B,CAAC;AAMlD,OAAO,EACH,sBAAsB,EAAE,uBAAuB,EAAE,oBAAoB,EAExE,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAEtE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD;;GAEG;AACH,MAAM,WAAW,4BAA4B;IACzC;;OAEG;IACH,SAAS,EAAE,YAAY,CAAC;IACxB;;OAEG;IACH,gBAAgB,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC9B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,QAAQ,EAAE,CAAC;IACjC;;;OAGG;IACH,UAAU,EAAE,aAAa,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,EACvC,IAAI,GACP,EAAE;IACC,IAAI,EAAE,sBAAsB,CAAC;CAChC,GAAG,OAAO,CAAC,EAAE,CAAC,CAiBd;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,EACzC,EAAE,GACL,EAAE;IACC,EAAE,EAAE,EAAE,CAAC;CACV,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA2BhC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,qBAAqB,CAAC,EACxC,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,UAAU,GACb,EAAE,4BAA4B,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA8DjE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,2BAA2B,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,uBAAuB,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAmCtH;AAGD;;;;GAIG;AACH,wBAAsB,kCAAkC,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,uBAAuB,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAY7H"}
|
|
@@ -84,7 +84,7 @@ export async function createSyncSagaContext({ sagaFrame, sessionKeystones, paylo
|
|
|
84
84
|
timestamp,
|
|
85
85
|
timestampMs,
|
|
86
86
|
};
|
|
87
|
-
// Domain Payloads
|
|
87
|
+
// Domain Payloads
|
|
88
88
|
const payloadAddrsDomain = payloadIbGibsDomain ?
|
|
89
89
|
payloadIbGibsDomain?.map(x => getIbGibAddr({ ibGib: x })) :
|
|
90
90
|
undefined;
|
|
@@ -132,10 +132,19 @@ export async function createSyncSagaContext({ sagaFrame, sessionKeystones, paylo
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
135
|
-
*
|
|
135
|
+
* Validates ONLY the {@link context} ibgib itself and saga frame/msg stone(s)
|
|
136
|
+
* ({@link SyncSagaContextIbGib_V1.sagaFrame}).
|
|
137
|
+
*
|
|
138
|
+
* Does NOT...
|
|
139
|
+
* * validate keystones (authn or authz)
|
|
140
|
+
* * validate domain payload ibgibs...
|
|
141
|
+
* * intrinsically
|
|
142
|
+
* * in relation to this context (addrs match up)
|
|
143
|
+
*
|
|
144
|
+
* @returns empty array if valid, else validation errors
|
|
136
145
|
*/
|
|
137
|
-
export async function
|
|
138
|
-
const lc = `[${
|
|
146
|
+
export async function validateContextAndSagaFrame({ context }) {
|
|
147
|
+
const lc = `[${validateContextAndSagaFrame.name}]`;
|
|
139
148
|
try {
|
|
140
149
|
if (logalot) {
|
|
141
150
|
console.log(`${lc} starting... (I: 7797f8294bd8f7e5089cb722ad468226)`);
|
|
@@ -168,4 +177,28 @@ export async function validateContext({ context }) {
|
|
|
168
177
|
}
|
|
169
178
|
}
|
|
170
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* validates the payload ibgibs ({@link SyncSagaContextIbGib_V1.payloadIbGibsDomain}) intrinsically
|
|
182
|
+
*
|
|
183
|
+
* @returns empty array if valid, else validation errors
|
|
184
|
+
*/
|
|
185
|
+
export async function validateContextDomainPayloadIbGibs({ context }) {
|
|
186
|
+
const lc = `[${validateContextDomainPayloadIbGibs.name}]`;
|
|
187
|
+
try {
|
|
188
|
+
if (logalot) {
|
|
189
|
+
console.log(`${lc} starting... (I: 9f9fe835bcc80c75aa7fd6d887fc0826)`);
|
|
190
|
+
}
|
|
191
|
+
console.error(`${lc} NAG MESSAGE (NOT THROWN). not implemented (E: bfe02ab36a227291a8f17ffc08f2ef26)`);
|
|
192
|
+
return [];
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
finally {
|
|
199
|
+
if (logalot) {
|
|
200
|
+
console.log(`${lc} complete.`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
171
204
|
//# sourceMappingURL=sync-saga-context-helpers.mjs.map
|