@rootintf/protocol-2phw 0.6.9 → 0.6.10
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 +1 -1
- package/dist/twoPhW.es.mjs +1 -1
- package/package.json +2 -2
- package/tests/twoPhW-new.spec.mjs +6 -6
- package/tests/twoPhW.test.mjs +46 -46
package/dist/twoPhW.cjs.js
CHANGED
|
@@ -89,7 +89,7 @@ var jsonMsg_cjs = {};
|
|
|
89
89
|
|
|
90
90
|
Object.defineProperty(jsonMsg_cjs, '__esModule', { value: true });
|
|
91
91
|
|
|
92
|
-
const validate_Msg = validate10;function validate10(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((((data.id === undefined) && (missing0 = "id")) || ((data.referer === undefined) && (missing0 = "referer"))) || ((data.dt === undefined) && (missing0 = "dt"))){validate10.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.id !== undefined){const _errs1 = errors;if(typeof data.id !== "string"){validate10.errors = [{instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data.referer !== undefined){const _errs3 = errors;if(
|
|
92
|
+
const validate_Msg = validate10;function validate10(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((((data.id === undefined) && (missing0 = "id")) || ((data.referer === undefined) && (missing0 = "referer"))) || ((data.dt === undefined) && (missing0 = "dt"))){validate10.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.id !== undefined){const _errs1 = errors;if(typeof data.id !== "string"){validate10.errors = [{instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data.referer !== undefined){let data1 = data.referer;const _errs3 = errors;{if(Array.isArray(data1)){if(data1.length > 2){validate10.errors = [{instancePath:instancePath+"/referer",schemaPath:"#/properties/referer/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"}];return false;}else {if(data1.length < 2){validate10.errors = [{instancePath:instancePath+"/referer",schemaPath:"#/properties/referer/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"}];return false;}else {var valid1 = true;const len0 = data1.length;for(let i0=0; i0<len0; i0++){const _errs5 = errors;if(typeof data1[i0] !== "string"){validate10.errors = [{instancePath:instancePath+"/referer/" + i0,schemaPath:"#/properties/referer/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid1 = _errs5 === errors;if(!valid1){break;}}}}}else {validate10.errors = [{instancePath:instancePath+"/referer",schemaPath:"#/properties/referer/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs3 === errors;}else {var valid0 = true;}if(valid0){if(data.dt !== undefined){const _errs7 = errors;if(typeof data.dt !== "string"){validate10.errors = [{instancePath:instancePath+"/dt",schemaPath:"#/properties/dt/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}}}}}else {validate10.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate10.errors = vErrors;return errors === 0;}const validate_Msg_msg = validate11;function validate11(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data._msg === undefined) && (missing0 = "_msg")){validate11.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}}else {validate11.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate11.errors = vErrors;return errors === 0;}const validate_MsgAck = validate12;function validate12(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.ack === undefined) && (missing0 = "ack")){validate12.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.ack !== undefined){let data0 = data.ack;{if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if((data0.ok === undefined) && (missing1 = "ok")){validate12.errors = [{instancePath:instancePath+"/ack",schemaPath:"#/properties/ack/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.ok !== undefined){if(typeof data0.ok !== "boolean"){validate12.errors = [{instancePath:instancePath+"/ack/ok",schemaPath:"#/properties/ack/properties/ok/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}}}}else {validate12.errors = [{instancePath:instancePath+"/ack",schemaPath:"#/properties/ack/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate12.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate12.errors = vErrors;return errors === 0;}
|
|
93
93
|
|
|
94
94
|
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
95
95
|
// require the crypto API and do not support built-in fallback to lower quality random number
|
package/dist/twoPhW.es.mjs
CHANGED
|
@@ -85,7 +85,7 @@ var jsonMsg_cjs = {};
|
|
|
85
85
|
|
|
86
86
|
Object.defineProperty(jsonMsg_cjs, '__esModule', { value: true });
|
|
87
87
|
|
|
88
|
-
const validate_Msg = validate10;function validate10(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((((data.id === undefined) && (missing0 = "id")) || ((data.referer === undefined) && (missing0 = "referer"))) || ((data.dt === undefined) && (missing0 = "dt"))){validate10.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.id !== undefined){const _errs1 = errors;if(typeof data.id !== "string"){validate10.errors = [{instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data.referer !== undefined){const _errs3 = errors;if(
|
|
88
|
+
const validate_Msg = validate10;function validate10(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((((data.id === undefined) && (missing0 = "id")) || ((data.referer === undefined) && (missing0 = "referer"))) || ((data.dt === undefined) && (missing0 = "dt"))){validate10.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.id !== undefined){const _errs1 = errors;if(typeof data.id !== "string"){validate10.errors = [{instancePath:instancePath+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data.referer !== undefined){let data1 = data.referer;const _errs3 = errors;{if(Array.isArray(data1)){if(data1.length > 2){validate10.errors = [{instancePath:instancePath+"/referer",schemaPath:"#/properties/referer/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"}];return false;}else {if(data1.length < 2){validate10.errors = [{instancePath:instancePath+"/referer",schemaPath:"#/properties/referer/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"}];return false;}else {var valid1 = true;const len0 = data1.length;for(let i0=0; i0<len0; i0++){const _errs5 = errors;if(typeof data1[i0] !== "string"){validate10.errors = [{instancePath:instancePath+"/referer/" + i0,schemaPath:"#/properties/referer/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid1 = _errs5 === errors;if(!valid1){break;}}}}}else {validate10.errors = [{instancePath:instancePath+"/referer",schemaPath:"#/properties/referer/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs3 === errors;}else {var valid0 = true;}if(valid0){if(data.dt !== undefined){const _errs7 = errors;if(typeof data.dt !== "string"){validate10.errors = [{instancePath:instancePath+"/dt",schemaPath:"#/properties/dt/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}}}}}else {validate10.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate10.errors = vErrors;return errors === 0;}const validate_Msg_msg = validate11;function validate11(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data._msg === undefined) && (missing0 = "_msg")){validate11.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}}else {validate11.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate11.errors = vErrors;return errors === 0;}const validate_MsgAck = validate12;function validate12(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;{if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.ack === undefined) && (missing0 = "ack")){validate12.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.ack !== undefined){let data0 = data.ack;{if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if((data0.ok === undefined) && (missing1 = "ok")){validate12.errors = [{instancePath:instancePath+"/ack",schemaPath:"#/properties/ack/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.ok !== undefined){if(typeof data0.ok !== "boolean"){validate12.errors = [{instancePath:instancePath+"/ack/ok",schemaPath:"#/properties/ack/properties/ok/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}}}}else {validate12.errors = [{instancePath:instancePath+"/ack",schemaPath:"#/properties/ack/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate12.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate12.errors = vErrors;return errors === 0;}
|
|
89
89
|
|
|
90
90
|
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
91
91
|
// require the crypto API and do not support built-in fallback to lower quality random number
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rootintf/protocol-2phw",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/twoPhW.cjs.js",
|
|
6
6
|
"browser": "dist/twoPhW.es.mjs",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"homepage": "https://gitlab.com/interface-x/npm-protocol-2PhW.git#readme",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@knev/bitlogr": "^0.2.4",
|
|
30
|
-
"@rootintf/json-msg": "^0.1
|
|
30
|
+
"@rootintf/json-msg": "^0.2.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@rollup/plugin-commonjs": "^23.0.0",
|
|
@@ -15,7 +15,7 @@ console.log('str_uuid_ID_= ' + str_uuid_ID_);
|
|
|
15
15
|
|
|
16
16
|
const json_msgWarp_ = {
|
|
17
17
|
id: "f5d6c2b8-1481-49b2-882c-262bb1c9ef8c",
|
|
18
|
-
referer: "af9447e3-4b36-424f-8d07-976a9216a298",
|
|
18
|
+
referer: ["twoPhW", "af9447e3-4b36-424f-8d07-976a9216a298"],
|
|
19
19
|
dt: "2022-10-28T06:26:19.692Z",
|
|
20
20
|
warp: {
|
|
21
21
|
user: {},
|
|
@@ -27,7 +27,7 @@ const json_msgWarp_ = {
|
|
|
27
27
|
|
|
28
28
|
const json_msgEngage_ = {
|
|
29
29
|
id: "f5d6c2b8-1481-49b2-882c-262bb1c9ef8c",
|
|
30
|
-
referer: "af9447e3-4b36-424f-8d07-976a9216a298",
|
|
30
|
+
referer: ["twoPhW", "af9447e3-4b36-424f-8d07-976a9216a298"],
|
|
31
31
|
dt: "2022-10-28T06:26:19.692Z",
|
|
32
32
|
engage: {
|
|
33
33
|
user: {},
|
|
@@ -38,7 +38,7 @@ const json_msgEngage_ = {
|
|
|
38
38
|
|
|
39
39
|
const json_msgAckWarp_str_ = {
|
|
40
40
|
id: "f5d6c2b8-1481-49b2-882c-262bb1c9ef8c",
|
|
41
|
-
referer: "af9447e3-4b36-424f-8d07-976a9216a298",
|
|
41
|
+
referer: ["twoPhW", "af9447e3-4b36-424f-8d07-976a9216a298"],
|
|
42
42
|
dt: "2022-10-28T06:26:19.692Z",
|
|
43
43
|
ack: {
|
|
44
44
|
"ok" : true,
|
|
@@ -49,7 +49,7 @@ const json_msgAckWarp_str_ = {
|
|
|
49
49
|
|
|
50
50
|
const json_msgAckWarp_obj_ = {
|
|
51
51
|
id: "f5d6c2b8-1481-49b2-882c-262bb1c9ef8c",
|
|
52
|
-
referer: "af9447e3-4b36-424f-8d07-976a9216a298",
|
|
52
|
+
referer: ["twoPhW", "af9447e3-4b36-424f-8d07-976a9216a298"],
|
|
53
53
|
dt: "2022-10-28T06:26:19.692Z",
|
|
54
54
|
ack: {
|
|
55
55
|
"ok" : true,
|
|
@@ -60,7 +60,7 @@ const json_msgAckWarp_obj_ = {
|
|
|
60
60
|
|
|
61
61
|
const json_msgAckEngage_ = {
|
|
62
62
|
id: "f5d6c2b8-1481-49b2-882c-262bb1c9ef8c",
|
|
63
|
-
referer: "af9447e3-4b36-424f-8d07-976a9216a298",
|
|
63
|
+
referer: ["twoPhW", "af9447e3-4b36-424f-8d07-976a9216a298"],
|
|
64
64
|
dt: "2022-10-28T06:26:19.692Z",
|
|
65
65
|
ack: {
|
|
66
66
|
"ok" : false,
|
|
@@ -71,7 +71,7 @@ const json_msgAckEngage_ = {
|
|
|
71
71
|
|
|
72
72
|
const json_msgOptions_ = {
|
|
73
73
|
id: "f5d6c2b8-1481-49b2-882c-262bb1c9ef8c",
|
|
74
|
-
referer: "af9447e3-4b36-424f-8d07-976a9216a298",
|
|
74
|
+
referer: ["twoPhW", "af9447e3-4b36-424f-8d07-976a9216a298"],
|
|
75
75
|
dt: "2022-10-28T06:26:19.692Z",
|
|
76
76
|
options: {
|
|
77
77
|
},
|
package/tests/twoPhW.test.mjs
CHANGED
|
@@ -14,11 +14,11 @@ import { TwoPhW, JSON_MsgOptions, JSON_MsgWarp, JSON_MsgEngage, l as l_2PhW } fr
|
|
|
14
14
|
|
|
15
15
|
console.log('l_2PhW', l_2PhW, Object.keys(l_2PhW).length);
|
|
16
16
|
|
|
17
|
-
const
|
|
18
|
-
console.log('
|
|
17
|
+
const recv_referer_= [ "recv", uuidv4()];
|
|
18
|
+
console.log('recv_referer_= ' + recv_referer_);
|
|
19
19
|
|
|
20
|
-
const
|
|
21
|
-
console.log('
|
|
20
|
+
const send_referer_= [ "send", uuidv4()];
|
|
21
|
+
console.log('send_referer_= ' + send_referer_);
|
|
22
22
|
|
|
23
23
|
var twoPhW_recv_= new TwoPhW();
|
|
24
24
|
var twoPhW_send_= new TwoPhW();
|
|
@@ -102,37 +102,37 @@ function callback_Abort_()
|
|
|
102
102
|
|
|
103
103
|
//-------------------------------------------------------------------------------------------------
|
|
104
104
|
|
|
105
|
-
const json_Warp_ = {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const json_Engage_ = {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const json_msgWarp_= twoPhW_send_.create_MsgWarp_out(
|
|
128
|
-
json_msgWarp_.referer=
|
|
105
|
+
// const json_Warp_ = {
|
|
106
|
+
// id: "f5d6c2b8-1481-49b2-882c-262bb1c9ef8c",
|
|
107
|
+
// referer: "af9447e3-4b36-424f-8d07-976a9216a298",
|
|
108
|
+
// dt: "2022-10-28T06:26:19.692Z",
|
|
109
|
+
// warp: {
|
|
110
|
+
// user: {},
|
|
111
|
+
// hyperport: {},
|
|
112
|
+
// ttl_msec: 4000
|
|
113
|
+
// },
|
|
114
|
+
// "2PhW" : "0.6"
|
|
115
|
+
// }
|
|
116
|
+
|
|
117
|
+
// const json_Engage_ = {
|
|
118
|
+
// referer: "af9447e3-4b36-424f-8d07-976a9216a298",
|
|
119
|
+
// dt: "2022-10-28T06:26:19.692Z",
|
|
120
|
+
// engage: {
|
|
121
|
+
// id: "f5d6c2b8-1481-49b2-882c-262bb1c9ef8c",
|
|
122
|
+
// user: {},
|
|
123
|
+
// hyperport: {}
|
|
124
|
+
// }
|
|
125
|
+
// }
|
|
126
|
+
|
|
127
|
+
const json_msgWarp_= twoPhW_send_.create_MsgWarp_out(uuidv4(), { "user": "user"}, { "hyperport" : "hyperport" }, 4000);
|
|
128
|
+
json_msgWarp_.referer= send_referer_;
|
|
129
129
|
|
|
130
130
|
const ttl_warp= json_msgWarp_.warp.ttl_msec;
|
|
131
131
|
|
|
132
132
|
const json_msgOptions= JSON_MsgOptions.create_with_msg_options(json_msgWarp_, {
|
|
133
133
|
"ttl_msec_incr" : [ ttl_warp, 3000 ]
|
|
134
134
|
});
|
|
135
|
-
json_msgOptions.referer=
|
|
135
|
+
json_msgOptions.referer= recv_referer_;
|
|
136
136
|
|
|
137
137
|
// https://stackoverflow.com/questions/951021/what-is-the-javascript-version-of-sleep
|
|
138
138
|
await new Promise(r => setTimeout(r, 1500));
|
|
@@ -145,23 +145,23 @@ twoPhW_send_.handler_msg(json_msgOptions);
|
|
|
145
145
|
|
|
146
146
|
//-------------------------------------------------------------------------------------------------
|
|
147
147
|
|
|
148
|
-
const json_Ack_str_ = {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const json_Ack_obj_ = {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
148
|
+
// const json_Ack_str_ = {
|
|
149
|
+
// referer: ["twoPhW", "af9447e3-4b36-424f-8d07-976a9216a298"],
|
|
150
|
+
// dt: "2022-10-28T06:26:19.692Z",
|
|
151
|
+
// ack: {
|
|
152
|
+
// "ok" : true,
|
|
153
|
+
// "_msg" : JSON.stringify( json_Warp_ )
|
|
154
|
+
// }
|
|
155
|
+
// }
|
|
156
|
+
|
|
157
|
+
// const json_Ack_obj_ = {
|
|
158
|
+
// referer: ["twoPhW", "af9447e3-4b36-424f-8d07-976a9216a298"],
|
|
159
|
+
// dt: "2022-10-28T06:26:19.692Z",
|
|
160
|
+
// ack: {
|
|
161
|
+
// "ok" : true,
|
|
162
|
+
// "_msg" : json_Warp_.warp
|
|
163
|
+
// }
|
|
164
|
+
// }
|
|
165
165
|
|
|
166
166
|
// twoPhW.handler_msg(json_Ack_str_);
|
|
167
167
|
|