@rootintf/protocol-2phw 1.3.3-api.1 → 2.0.3-api.2
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/twoPhW.cjs.js +234 -127
- package/dist/twoPhW.d.ts +16 -16
- package/dist/twoPhW.es.mjs +234 -127
- package/package.json +5 -5
- package/schema/schema_2PhW.json +1 -1
- package/src/twoPhW.ts +51 -51
- package/src/validate-esm.mjs +1 -1
- package/tests/twoPhW-new.spec.mjs +26 -26
package/dist/twoPhW.es.mjs
CHANGED
|
@@ -75,8 +75,8 @@ function validate19(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
75
75
|
if (valid0) {
|
|
76
76
|
if (data["2PhW"] !== undefined) {
|
|
77
77
|
const _errs10 = errors;
|
|
78
|
-
if ("
|
|
79
|
-
validate19.errors = [{ instancePath: instancePath + "/2PhW", schemaPath: "definitions#/definitions/2PhW/const", keyword: "const", params: { allowedValue: "
|
|
78
|
+
if ("2" !== data["2PhW"]) {
|
|
79
|
+
validate19.errors = [{ instancePath: instancePath + "/2PhW", schemaPath: "definitions#/definitions/2PhW/const", keyword: "const", params: { allowedValue: "2" }, message: "must be equal to constant" }];
|
|
80
80
|
return false;
|
|
81
81
|
}
|
|
82
82
|
var valid0 = _errs10 === errors;
|
|
@@ -157,8 +157,8 @@ function validate20(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
157
157
|
if (valid0) {
|
|
158
158
|
if (data["2PhW"] !== undefined) {
|
|
159
159
|
const _errs7 = errors;
|
|
160
|
-
if ("
|
|
161
|
-
validate20.errors = [{ instancePath: instancePath + "/2PhW", schemaPath: "definitions#/definitions/2PhW/const", keyword: "const", params: { allowedValue: "
|
|
160
|
+
if ("2" !== data["2PhW"]) {
|
|
161
|
+
validate20.errors = [{ instancePath: instancePath + "/2PhW", schemaPath: "definitions#/definitions/2PhW/const", keyword: "const", params: { allowedValue: "2" }, message: "must be equal to constant" }];
|
|
162
162
|
return false;
|
|
163
163
|
}
|
|
164
164
|
var valid0 = _errs7 === errors;
|
|
@@ -368,7 +368,115 @@ function requireJsonMsg_cjs () {
|
|
|
368
368
|
if (hasRequiredJsonMsg_cjs) return jsonMsg_cjs;
|
|
369
369
|
hasRequiredJsonMsg_cjs = 1;
|
|
370
370
|
|
|
371
|
-
const schema_Msg = validate18;
|
|
371
|
+
const schema_Msg = validate18;
|
|
372
|
+
function validate18(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate18.evaluated; if (evaluated0.dynamicProps) {
|
|
373
|
+
evaluated0.props = undefined;
|
|
374
|
+
} if (evaluated0.dynamicItems) {
|
|
375
|
+
evaluated0.items = undefined;
|
|
376
|
+
} {
|
|
377
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
378
|
+
let missing0;
|
|
379
|
+
if ((((data.id === undefined) && (missing0 = "id")) || ((data.referer === undefined) && (missing0 = "referer"))) || ((data.dt === undefined) && (missing0 = "dt"))) {
|
|
380
|
+
validate18.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
if (data.id !== undefined) {
|
|
385
|
+
const _errs1 = errors;
|
|
386
|
+
if (typeof data.id !== "string") {
|
|
387
|
+
validate18.errors = [{ instancePath: instancePath + "/id", schemaPath: "#/properties/id/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
var valid0 = _errs1 === errors;
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
var valid0 = true;
|
|
394
|
+
}
|
|
395
|
+
if (valid0) {
|
|
396
|
+
if (data.dt !== undefined) {
|
|
397
|
+
const _errs3 = errors;
|
|
398
|
+
if (typeof data.dt !== "string") {
|
|
399
|
+
validate18.errors = [{ instancePath: instancePath + "/dt", schemaPath: "#/properties/dt/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
var valid0 = _errs3 === errors;
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
var valid0 = true;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
validate18.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
} validate18.errors = vErrors; return errors === 0; }
|
|
415
|
+
validate18.evaluated = { "props": { "id": true, "dt": true }, "dynamicProps": false, "dynamicItems": false };
|
|
416
|
+
const schema_MsgEffect = validate19;
|
|
417
|
+
function validate19(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate19.evaluated; if (evaluated0.dynamicProps) {
|
|
418
|
+
evaluated0.props = undefined;
|
|
419
|
+
} if (evaluated0.dynamicItems) {
|
|
420
|
+
evaluated0.items = undefined;
|
|
421
|
+
} {
|
|
422
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
423
|
+
let missing0;
|
|
424
|
+
if ((data._cause === undefined) && (missing0 = "_cause")) {
|
|
425
|
+
validate19.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
426
|
+
return false;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
validate19.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
} validate19.errors = vErrors; return errors === 0; }
|
|
434
|
+
validate19.evaluated = { "dynamicProps": false, "dynamicItems": false };
|
|
435
|
+
const schema_MsgAckEffect = validate20;
|
|
436
|
+
function validate20(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) { let vErrors = null; let errors = 0; const evaluated0 = validate20.evaluated; if (evaluated0.dynamicProps) {
|
|
437
|
+
evaluated0.props = undefined;
|
|
438
|
+
} if (evaluated0.dynamicItems) {
|
|
439
|
+
evaluated0.items = undefined;
|
|
440
|
+
} {
|
|
441
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
442
|
+
let missing0;
|
|
443
|
+
if ((data.ack === undefined) && (missing0 = "ack")) {
|
|
444
|
+
validate20.errors = [{ instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
else {
|
|
448
|
+
if (data.ack !== undefined) {
|
|
449
|
+
let data0 = data.ack;
|
|
450
|
+
{
|
|
451
|
+
if (data0 && typeof data0 == "object" && !Array.isArray(data0)) {
|
|
452
|
+
let missing1;
|
|
453
|
+
if ((data0.ok === undefined) && (missing1 = "ok")) {
|
|
454
|
+
validate20.errors = [{ instancePath: instancePath + "/ack", schemaPath: "#/properties/ack/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" }];
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
if (data0.ok !== undefined) {
|
|
459
|
+
if (typeof data0.ok !== "boolean") {
|
|
460
|
+
validate20.errors = [{ instancePath: instancePath + "/ack/ok", schemaPath: "#/properties/ack/properties/ok/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" }];
|
|
461
|
+
return false;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
validate20.errors = [{ instancePath: instancePath + "/ack", schemaPath: "#/properties/ack/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
468
|
+
return false;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
else {
|
|
475
|
+
validate20.errors = [{ instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
476
|
+
return false;
|
|
477
|
+
}
|
|
478
|
+
} validate20.errors = vErrors; return errors === 0; }
|
|
479
|
+
validate20.evaluated = { "props": { "ack": true }, "dynamicProps": false, "dynamicItems": false };
|
|
372
480
|
|
|
373
481
|
const byteToHex = [];
|
|
374
482
|
for (let i = 0; i < 256; ++i) {
|
|
@@ -412,10 +520,7 @@ function requireJsonMsg_cjs () {
|
|
|
412
520
|
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
413
521
|
var native = { randomUUID };
|
|
414
522
|
|
|
415
|
-
function
|
|
416
|
-
if (native.randomUUID && true && !options) {
|
|
417
|
-
return native.randomUUID();
|
|
418
|
-
}
|
|
523
|
+
function _v4(options, buf, offset) {
|
|
419
524
|
options = options || {};
|
|
420
525
|
const rnds = options.random ?? options.rng?.() ?? rng();
|
|
421
526
|
if (rnds.length < 16) {
|
|
@@ -425,6 +530,12 @@ function requireJsonMsg_cjs () {
|
|
|
425
530
|
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
|
426
531
|
return unsafeStringify(rnds);
|
|
427
532
|
}
|
|
533
|
+
function v4(options, buf, offset) {
|
|
534
|
+
if (native.randomUUID && true && !options) {
|
|
535
|
+
return native.randomUUID();
|
|
536
|
+
}
|
|
537
|
+
return _v4(options);
|
|
538
|
+
}
|
|
428
539
|
|
|
429
540
|
// console.log('OUT', __name({variableName}) );
|
|
430
541
|
|
|
@@ -519,88 +630,84 @@ function requireJsonMsg_cjs () {
|
|
|
519
630
|
|
|
520
631
|
})();
|
|
521
632
|
|
|
522
|
-
let LOGR_= LOGR.get_instance();
|
|
523
|
-
const log_= LOGR_.log;
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
VALIDATION : 0b1 << 0,
|
|
633
|
+
let LOGR_ = LOGR.get_instance();
|
|
634
|
+
const log_ = LOGR_.log;
|
|
635
|
+
const l_ = {
|
|
636
|
+
VALIDATION: 0b1 << 0,
|
|
527
637
|
};
|
|
528
|
-
LOGR_.labels= l_;
|
|
529
|
-
|
|
638
|
+
LOGR_.labels = l_;
|
|
530
639
|
// TODO: use RFC3339 "timestamp"? https://ajv.js.org/json-type-definition.html
|
|
531
|
-
|
|
532
640
|
// "module" pattern to avoid "static" and "#" private : https://stackoverflow.com/a/1479341/298545
|
|
533
|
-
var JSON_Msg = (function() {
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
641
|
+
var JSON_Msg = (function () {
|
|
642
|
+
return {
|
|
643
|
+
merge: function (json) {
|
|
644
|
+
return Object.assign({
|
|
645
|
+
id: v4(),
|
|
646
|
+
referer: null,
|
|
647
|
+
dt: new Date().toISOString()
|
|
648
|
+
}, json || {});
|
|
649
|
+
},
|
|
650
|
+
validate: function (json) {
|
|
651
|
+
const b_valid = schema_Msg(json);
|
|
652
|
+
if (!b_valid)
|
|
653
|
+
log_(l_.VALIDATION, () => ['JSON_Msg: validate: ', schema_Msg.errors]);
|
|
654
|
+
return b_valid;
|
|
655
|
+
},
|
|
656
|
+
// TODO: requires a separate ajv module require, and JTD specific schema
|
|
657
|
+
// https://ajv.js.org/guide/getting-started.html#parsing-and-serializing-json
|
|
658
|
+
// static #ajv_parse_= ajv.compileParser(this.#schema_json_Msg);
|
|
659
|
+
// static parse(json) {
|
|
660
|
+
// return this.#ajv_parse_(json);
|
|
661
|
+
// }
|
|
662
|
+
};
|
|
555
663
|
})();
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
664
|
+
var JSON_MsgEffect = (function () {
|
|
665
|
+
return {
|
|
666
|
+
create_with_cause_merge: function (msg_cause, json) {
|
|
667
|
+
const _cause = msg_cause;
|
|
668
|
+
return Object.assign(JSON_Msg.merge(json), { _cause });
|
|
669
|
+
},
|
|
670
|
+
validate: function (json) {
|
|
671
|
+
if (!JSON_Msg.validate(json))
|
|
672
|
+
return false;
|
|
673
|
+
const b_valid = schema_MsgEffect(json);
|
|
674
|
+
if (!b_valid)
|
|
675
|
+
log_(l_.VALIDATION, () => ['JSON_MsgEffect: validate: ', schema_MsgEffect.errors]);
|
|
676
|
+
return b_valid;
|
|
677
|
+
}
|
|
678
|
+
};
|
|
571
679
|
})();
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
}
|
|
680
|
+
var JSON_MsgAck = (function () {
|
|
681
|
+
return {
|
|
682
|
+
create_with_cause_Ok: function (msg_cause, b_ok = true) {
|
|
683
|
+
return JSON_MsgEffect.create_with_cause_merge(msg_cause, {
|
|
684
|
+
ack: {
|
|
685
|
+
"ok": b_ok,
|
|
686
|
+
},
|
|
687
|
+
});
|
|
688
|
+
},
|
|
689
|
+
create_with_cause_Expired: function (msg_cause) {
|
|
690
|
+
return JSON_MsgEffect.create_with_cause_merge(msg_cause, {
|
|
691
|
+
ack: {
|
|
692
|
+
"ok": false,
|
|
693
|
+
"expired": true
|
|
694
|
+
},
|
|
695
|
+
});
|
|
696
|
+
},
|
|
697
|
+
validate: function (json) {
|
|
698
|
+
if (!JSON_MsgEffect.validate(json))
|
|
699
|
+
return false;
|
|
700
|
+
const b_valid = schema_MsgAckEffect(json);
|
|
701
|
+
if (!b_valid)
|
|
702
|
+
log_(l_.VALIDATION, () => ['JSON_MsgAckEffect: validate: ', schema_MsgAckEffect.errors]);
|
|
703
|
+
return b_valid;
|
|
704
|
+
}
|
|
705
|
+
};
|
|
599
706
|
})();
|
|
600
707
|
|
|
601
708
|
jsonMsg_cjs.JSON_Msg = JSON_Msg;
|
|
602
|
-
jsonMsg_cjs.
|
|
603
|
-
jsonMsg_cjs.
|
|
709
|
+
jsonMsg_cjs.JSON_MsgAck = JSON_MsgAck;
|
|
710
|
+
jsonMsg_cjs.JSON_MsgEffect = JSON_MsgEffect;
|
|
604
711
|
jsonMsg_cjs.l = l_;
|
|
605
712
|
return jsonMsg_cjs;
|
|
606
713
|
}
|
|
@@ -792,7 +899,7 @@ class Config {
|
|
|
792
899
|
// }
|
|
793
900
|
// })();
|
|
794
901
|
//-------------------------------------------------------------------------------------------------
|
|
795
|
-
let k_VERSION = "
|
|
902
|
+
let k_VERSION = "2";
|
|
796
903
|
// rtt_msec <= ttl_msec *2 => rtt_msec = ttl_msec *2
|
|
797
904
|
// t_ttl_rtt_(TTL, RTT) = t_ttl_rtt_(TTL, TTL *2) = TTL *2 + TTL *2 = TTL *4 MAX
|
|
798
905
|
function time_ttl_rtt_(ttl_msec, rtt_msec) {
|
|
@@ -805,8 +912,8 @@ function time_ttl_rtt_(ttl_msec, rtt_msec) {
|
|
|
805
912
|
}
|
|
806
913
|
var JSON_MsgOptions = (function () {
|
|
807
914
|
return {
|
|
808
|
-
|
|
809
|
-
return jsonMsg_cjsExports.
|
|
915
|
+
create_with_cause_options: function (msg_cause, options) {
|
|
916
|
+
return jsonMsg_cjsExports.JSON_MsgEffect.create_with_msg_merge(msg_cause, {
|
|
810
917
|
options: options,
|
|
811
918
|
"2PhW": k_VERSION
|
|
812
919
|
});
|
|
@@ -859,9 +966,9 @@ var JSON_MsgWarp = (function () {
|
|
|
859
966
|
})();
|
|
860
967
|
var JSON_MsgEngage = (function () {
|
|
861
968
|
return {
|
|
862
|
-
|
|
969
|
+
create_with_Warp: function (json_msgWarp) {
|
|
863
970
|
console.assert(json_msgWarp.ack === undefined, "Engage with a Warp, not an Ack");
|
|
864
|
-
return jsonMsg_cjsExports.
|
|
971
|
+
return jsonMsg_cjsExports.JSON_MsgEffect.create_with_cause_merge(json_msgWarp, {
|
|
865
972
|
engage: {
|
|
866
973
|
"ok": true,
|
|
867
974
|
"rtt_msec": Date.now() - Date.parse(json_msgWarp.dt)
|
|
@@ -869,12 +976,12 @@ var JSON_MsgEngage = (function () {
|
|
|
869
976
|
"2PhW": k_VERSION
|
|
870
977
|
});
|
|
871
978
|
},
|
|
872
|
-
validate: function (
|
|
979
|
+
validate: function (json_msgEffect) {
|
|
873
980
|
// if (! JSON_Msg_msg.validate(json))
|
|
874
981
|
// return false;
|
|
875
|
-
if (!JSON_MsgWarp.validate(
|
|
982
|
+
if (!JSON_MsgWarp.validate(json_msgEffect._cause))
|
|
876
983
|
return false;
|
|
877
|
-
if (!schema_MsgEngage(
|
|
984
|
+
if (!schema_MsgEngage(json_msgEffect)) {
|
|
878
985
|
log_(l_.VALIDATION, () => ['JSON_MsgEngage: schema_MsgEngage_: ', schema_MsgEngage.errors]);
|
|
879
986
|
return false;
|
|
880
987
|
}
|
|
@@ -886,23 +993,23 @@ var JSON_MsgAckWarp = (function () {
|
|
|
886
993
|
return {
|
|
887
994
|
// createWith_msgAck_msg : function(json_msgAck, _msg) {
|
|
888
995
|
// const json_msgAckWarp= structuredClone(json_msgAck);
|
|
889
|
-
// json_msgAckWarp.
|
|
996
|
+
// json_msgAckWarp._cause= _cause;
|
|
890
997
|
// return json_msgAckWarp;
|
|
891
998
|
// }
|
|
892
|
-
|
|
893
|
-
const
|
|
894
|
-
|
|
895
|
-
return
|
|
999
|
+
create_with_Warp_Ok: function (json_msgWarp, b_ok = true) {
|
|
1000
|
+
const json_msgAck = jsonMsg_cjsExports.JSON_MsgAck.create_with_cause_Ok(json_msgWarp, b_ok);
|
|
1001
|
+
json_msgAck["2PhW"] = k_VERSION;
|
|
1002
|
+
return json_msgAck;
|
|
896
1003
|
},
|
|
897
1004
|
// create_with_msgExpired : function( json_msgWarp ) {
|
|
898
1005
|
// const json_msgAck_msg= JSON_MsgAck_msg.create_with_msgExpired( json_msgWarp )
|
|
899
1006
|
// json_msgAck_msg["2PhW"]= k_VERSION;
|
|
900
1007
|
// return json_msgAck_msg;
|
|
901
1008
|
// },
|
|
902
|
-
validate: function (
|
|
1009
|
+
validate: function (json_msgAck) {
|
|
903
1010
|
// if (! JSON_MsgAck_msg.validate(json))
|
|
904
1011
|
// return false;
|
|
905
|
-
if (!JSON_MsgWarp.validate(
|
|
1012
|
+
if (!JSON_MsgWarp.validate(json_msgAck._cause))
|
|
906
1013
|
return false;
|
|
907
1014
|
return true;
|
|
908
1015
|
}
|
|
@@ -912,23 +1019,23 @@ var JSON_MsgAckEngage = (function () {
|
|
|
912
1019
|
return {
|
|
913
1020
|
// createWith_msgAck_msg : function(json_msgAck, _msg) {
|
|
914
1021
|
// const json_msgAckEngage= structuredClone(json_msgAck);
|
|
915
|
-
// json_msgAckEngage.
|
|
1022
|
+
// json_msgAckEngage._cause= _cause;
|
|
916
1023
|
// return json_msgAckEngage;
|
|
917
1024
|
// }
|
|
918
|
-
|
|
919
|
-
const
|
|
920
|
-
|
|
921
|
-
return
|
|
1025
|
+
create_with_Engage_Ok: function (json_msgEngage, b_ok = true) {
|
|
1026
|
+
const json_msgAck = jsonMsg_cjsExports.JSON_MsgAck.create_with_cause_Ok(json_msgEngage, b_ok);
|
|
1027
|
+
json_msgAck["2PhW"] = k_VERSION;
|
|
1028
|
+
return json_msgAck;
|
|
922
1029
|
},
|
|
923
1030
|
// create_with_msgExpired : function( json_msgEngage ) {
|
|
924
1031
|
// const json_msgAck_msg= JSON_MsgAck_msg.create_with_msgExpired( json_msgEngage )
|
|
925
1032
|
// json_msgAck_msg["2PhW"]= k_VERSION;
|
|
926
1033
|
// return json_msgAck_msg;
|
|
927
1034
|
// },
|
|
928
|
-
validate: function (
|
|
1035
|
+
validate: function (json_msgAck) {
|
|
929
1036
|
// if (! JSON_MsgAck_msg.validate(json_msgAck_msg))
|
|
930
1037
|
// return false;
|
|
931
|
-
if (!JSON_MsgEngage.validate(
|
|
1038
|
+
if (!JSON_MsgEngage.validate(json_msgAck._cause))
|
|
932
1039
|
return false;
|
|
933
1040
|
return true;
|
|
934
1041
|
}
|
|
@@ -986,7 +1093,7 @@ class StateEngage extends StateState {
|
|
|
986
1093
|
if (false === state_new instanceof StateAckEngage)
|
|
987
1094
|
return false;
|
|
988
1095
|
// The Engage gets to live for THE WARP'S creation time + TTL*2 + RTT
|
|
989
|
-
const json_msgWarp = this.json_msgEngage.
|
|
1096
|
+
const json_msgWarp = this.json_msgEngage._cause;
|
|
990
1097
|
const timeout_ms = time_ttl_rtt_(json_msgWarp.warp.ttl_msec, this.json_msgEngage.engage.rtt_msec);
|
|
991
1098
|
log_(l_.PROTOCOL_STATE, () => [`StateEngage: evt_AckEngage.dt@${state_new.evt_AckEngage.dt}, msgWarp.dt@${Date.parse(json_msgWarp.dt)} + ${timeout_ms}`]);
|
|
992
1099
|
if (state_new.evt_AckEngage.dt >= Date.parse(json_msgWarp.dt) + timeout_ms)
|
|
@@ -1003,14 +1110,14 @@ class StateAckWarp extends StateState {
|
|
|
1003
1110
|
return false;
|
|
1004
1111
|
if (!this.json_msgAckWarp.ack.ok)
|
|
1005
1112
|
return false;
|
|
1006
|
-
if (this.json_msgAckWarp.
|
|
1113
|
+
if (this.json_msgAckWarp._cause.warp.instantaneous)
|
|
1007
1114
|
return false;
|
|
1008
1115
|
// The Ack gets to live for THE ACK'S creation time + TTL*2 + STT
|
|
1009
1116
|
// +STT, so lines up with the Engage timeout
|
|
1010
1117
|
// - Engage: T0 +2TTL +RTT; RTT= STT+STT
|
|
1011
1118
|
// - AckWarp: TAckWarp +2TLL +STT; TAckWarp= T0 +STT;
|
|
1012
1119
|
// - STT: Date of the Ack minus date of the Warp.
|
|
1013
|
-
const timeout_ms = time_ttl_rtt_(this.json_msgAckWarp.
|
|
1120
|
+
const timeout_ms = time_ttl_rtt_(this.json_msgAckWarp._cause.warp.ttl_msec) + Date.parse(this.json_msgAckWarp.dt) - Date.parse(this.json_msgAckWarp._cause.dt);
|
|
1014
1121
|
log_(l_.PROTOCOL_STATE, () => [`StateAckWarp: evt_Engage.dt@${state_new.evt_Engage.dt}, msgAckWarp.dt@${Date.parse(this.json_msgAckWarp.dt)} + ${timeout_ms}`]);
|
|
1015
1122
|
if (state_new.evt_Engage.dt >= Date.parse(this.json_msgAckWarp.dt) + timeout_ms)
|
|
1016
1123
|
return false;
|
|
@@ -1082,7 +1189,7 @@ class TwoPhW_EventLog {
|
|
|
1082
1189
|
}
|
|
1083
1190
|
_warp(json_msg) {
|
|
1084
1191
|
const b_Ack = json_msg.ack !== undefined;
|
|
1085
|
-
const json = b_Ack ? json_msg["
|
|
1192
|
+
const json = b_Ack ? json_msg["_cause"] : json_msg;
|
|
1086
1193
|
if (json.warp) {
|
|
1087
1194
|
return {
|
|
1088
1195
|
str_type: `2PhW[JSON_Msg${b_Ack ? 'Ack' : ''}Warp]`,
|
|
@@ -1092,7 +1199,7 @@ class TwoPhW_EventLog {
|
|
|
1092
1199
|
if (json.engage) {
|
|
1093
1200
|
return {
|
|
1094
1201
|
str_type: `2PhW[JSON_Msg${b_Ack ? 'Ack' : ''}Engage]`,
|
|
1095
|
-
json_msgWarp: json["
|
|
1202
|
+
json_msgWarp: json["_cause"]
|
|
1096
1203
|
};
|
|
1097
1204
|
}
|
|
1098
1205
|
return { str_type: null, json_msgWarp: null }; // Explicit default for invalid cases
|
|
@@ -1166,8 +1273,8 @@ class TwoPhW {
|
|
|
1166
1273
|
if (! validate_Options_delay_(json_msgOptions.options))
|
|
1167
1274
|
return false;
|
|
1168
1275
|
|
|
1169
|
-
if (JSON_MsgWarp.validate(json_msgOptions.
|
|
1170
|
-
const json_msgWarp= json_msgOptions.
|
|
1276
|
+
if (JSON_MsgWarp.validate(json_msgOptions._cause)) {
|
|
1277
|
+
const json_msgWarp= json_msgOptions._cause;
|
|
1171
1278
|
|
|
1172
1279
|
const ctx= get_ctx(json_msgWarp.id);
|
|
1173
1280
|
if (!ctx )
|
|
@@ -1210,7 +1317,7 @@ class TwoPhW {
|
|
|
1210
1317
|
}
|
|
1211
1318
|
_handler_msgAckWarp(msg, json_msgAckWarp) {
|
|
1212
1319
|
log_(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckWarp: ', json_msgAckWarp]);
|
|
1213
|
-
const json_msgWarp = json_msgAckWarp.
|
|
1320
|
+
const json_msgWarp = json_msgAckWarp._cause;
|
|
1214
1321
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1215
1322
|
const b_changeState = protocolState.canChangeState(new StateAckWarp(null, {
|
|
1216
1323
|
dt: Date.now(),
|
|
@@ -1225,7 +1332,7 @@ class TwoPhW {
|
|
|
1225
1332
|
}
|
|
1226
1333
|
register_msgEngage(msg, json_msgEngage) {
|
|
1227
1334
|
log_(l_.SENDER, () => ['register_msgEngage: ', json_msgEngage]);
|
|
1228
|
-
const json_msgWarp = json_msgEngage.
|
|
1335
|
+
const json_msgWarp = json_msgEngage._cause;
|
|
1229
1336
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1230
1337
|
const b_changeState = protocolState.canChangeState(new StateEngage(null, {
|
|
1231
1338
|
dt: Date.now(),
|
|
@@ -1242,7 +1349,7 @@ class TwoPhW {
|
|
|
1242
1349
|
}
|
|
1243
1350
|
_handler_msgAckEngage(msg, json_msgAckEngage) {
|
|
1244
1351
|
log_(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckEngage: ', json_msgAckEngage]);
|
|
1245
|
-
const json_msgWarp = json_msgAckEngage.
|
|
1352
|
+
const json_msgWarp = json_msgAckEngage._cause._cause;
|
|
1246
1353
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1247
1354
|
const b_changeState = protocolState.canChangeState(new StateAckEngage(null, {
|
|
1248
1355
|
dt: Date.now(),
|
|
@@ -1272,7 +1379,7 @@ class TwoPhW {
|
|
|
1272
1379
|
}
|
|
1273
1380
|
register_msgAckWarp(msg, json_msgAckWarp) {
|
|
1274
1381
|
log_(l_.RECVER, () => ['register_msgAckWarp: ', json_msgAckWarp]);
|
|
1275
|
-
const json_msgWarp = json_msgAckWarp.
|
|
1382
|
+
const json_msgWarp = json_msgAckWarp._cause;
|
|
1276
1383
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1277
1384
|
const b_changeState = protocolState.canChangeState(new StateAckWarp(null, {
|
|
1278
1385
|
dt: Date.now(),
|
|
@@ -1289,7 +1396,7 @@ class TwoPhW {
|
|
|
1289
1396
|
}
|
|
1290
1397
|
_handler_msgEngage(msg, json_msgEngage) {
|
|
1291
1398
|
log_(l_.HANDLERS | l_.RECVER, () => ['handler_msgEngage: ', json_msgEngage]);
|
|
1292
|
-
const json_msgWarp = json_msgEngage
|
|
1399
|
+
const json_msgWarp = json_msgEngage._cause;
|
|
1293
1400
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1294
1401
|
const b_changeState = protocolState.canChangeState(new StateEngage(null, {
|
|
1295
1402
|
dt: Date.now(),
|
|
@@ -1304,7 +1411,7 @@ class TwoPhW {
|
|
|
1304
1411
|
}
|
|
1305
1412
|
register_msgAckEngage(msg, json_msgAckEngage) {
|
|
1306
1413
|
log_(l_.RECVER, () => ['register_msgAckEngage: ', json_msgAckEngage]);
|
|
1307
|
-
const json_msgWarp = json_msgAckEngage.
|
|
1414
|
+
const json_msgWarp = json_msgAckEngage._cause._cause;
|
|
1308
1415
|
const protocolState = this.eventLog.traverse_State(json_msgWarp);
|
|
1309
1416
|
const b_changeState = protocolState.canChangeState(new StateAckEngage(null, {
|
|
1310
1417
|
dt: Date.now(),
|
|
@@ -1316,19 +1423,19 @@ class TwoPhW {
|
|
|
1316
1423
|
this.eventLog._addEvent(msg, json_msgAckEngage);
|
|
1317
1424
|
}
|
|
1318
1425
|
//-------------------------------------------------------------------------------------------------
|
|
1319
|
-
|
|
1320
|
-
log_(l_.HANDLERS, () => ['
|
|
1321
|
-
if (JSON_MsgAckWarp.validate(
|
|
1426
|
+
handler_json_msgAck(msg, json_msgAck) {
|
|
1427
|
+
log_(l_.HANDLERS, () => ['handler_json_msgAck: ', json_msgAck]);
|
|
1428
|
+
if (JSON_MsgAckWarp.validate(json_msgAck) && this._handler_msgAckWarp(msg, json_msgAck))
|
|
1322
1429
|
return true;
|
|
1323
|
-
if (JSON_MsgAckEngage.validate(
|
|
1430
|
+
if (JSON_MsgAckEngage.validate(json_msgAck) && this._handler_msgAckEngage(msg, json_msgAck))
|
|
1324
1431
|
return true;
|
|
1325
1432
|
return false;
|
|
1326
1433
|
}
|
|
1327
|
-
|
|
1328
|
-
log_(l_.HANDLERS, () => ['
|
|
1329
|
-
if (jsonMsg_cjsExports.
|
|
1434
|
+
handler_json_msgEffect(msg, json_msgEffect) {
|
|
1435
|
+
log_(l_.HANDLERS, () => ['handler_json_msgEffect: ', json_msgEffect]);
|
|
1436
|
+
if (jsonMsg_cjsExports.JSON_MsgAck.validate(json_msgEffect) && this.handler_json_msgAck(msg, json_msgEffect))
|
|
1330
1437
|
return true;
|
|
1331
|
-
if (JSON_MsgEngage.validate(
|
|
1438
|
+
if (JSON_MsgEngage.validate(json_msgEffect) && this._handler_msgEngage(msg, json_msgEffect))
|
|
1332
1439
|
return true;
|
|
1333
1440
|
// if (JSON_MsgOptions.validate(json_msg) && this.handler_msgOptions_(this._config, msg, json_msg))
|
|
1334
1441
|
// return true;
|
|
@@ -1350,7 +1457,7 @@ class TwoPhW {
|
|
|
1350
1457
|
}
|
|
1351
1458
|
handler_json(msg, json) {
|
|
1352
1459
|
log_(l_.HANDLERS, () => ['handler_json: ', json]);
|
|
1353
|
-
if (jsonMsg_cjsExports.
|
|
1460
|
+
if (jsonMsg_cjsExports.JSON_MsgEffect.validate(json) && this.handler_json_msgEffect(msg, json))
|
|
1354
1461
|
return true;
|
|
1355
1462
|
if (jsonMsg_cjsExports.JSON_Msg.validate(json) && this.handler_json_msg(msg, json))
|
|
1356
1463
|
return true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rootintf/protocol-2phw",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.3-api.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/twoPhW.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,9 +28,8 @@
|
|
|
28
28
|
"homepage": "https://gitlab.com/interface-x/npm-protocol-2PhW.git#readme",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@knev/bitlogr": "^2.0.11",
|
|
31
|
-
"@rootintf/json-msg": "^
|
|
32
|
-
"ajv": "^8.17.1"
|
|
33
|
-
"tslib": "^2.8.1"
|
|
31
|
+
"@rootintf/json-msg": "^2.0.6",
|
|
32
|
+
"ajv": "^8.17.1"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
35
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
@@ -41,8 +40,9 @@
|
|
|
41
40
|
"@types/node": "^24.10.1",
|
|
42
41
|
"ajv-cli": "^5.0.0",
|
|
43
42
|
"del-cli": "^7.0.0",
|
|
44
|
-
"jasmine": "^5.
|
|
43
|
+
"jasmine": "^5.13.0",
|
|
45
44
|
"rollup": "^4.53.3",
|
|
45
|
+
"tslib": "^2.8.1",
|
|
46
46
|
"typescript": "^5.9.3",
|
|
47
47
|
"uuid": "^13.0.0"
|
|
48
48
|
}
|