hop-message 0.0.1 → 0.0.3
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/package.json +10 -4
- package/src/index.js +72 -1
- package/src/library/index.js +37 -0
- package/src/safeflow/index.js +38 -0
- package/test/live-index.test.js +9 -0
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hop-message",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "routing message for hop",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.js",
|
|
6
7
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
+
"start": "node src/index.js",
|
|
9
|
+
"test": "mocha test/*.*"
|
|
8
10
|
},
|
|
9
11
|
"repository": {
|
|
10
12
|
"type": "git",
|
|
@@ -20,5 +22,9 @@
|
|
|
20
22
|
"bugs": {
|
|
21
23
|
"url": "https://github.com/healthscience/hop-message/issues"
|
|
22
24
|
},
|
|
23
|
-
"homepage": "https://github.com/healthscience/hop-message#readme"
|
|
25
|
+
"homepage": "https://github.com/healthscience/hop-message#readme",
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"assert": "^2.0.0",
|
|
28
|
+
"mocha": "^10.0.0"
|
|
29
|
+
}
|
|
24
30
|
}
|
package/src/index.js
CHANGED
|
@@ -1 +1,72 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict'
|
|
2
|
+
/**
|
|
3
|
+
* message flow and logic routing
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* @class HopMessages
|
|
7
|
+
* @package HopMessages
|
|
8
|
+
* @copyright Copyright (c) 2022 James Littlejohn
|
|
9
|
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-3.0.html
|
|
10
|
+
* @version $Id$
|
|
11
|
+
*/
|
|
12
|
+
import util from 'util'
|
|
13
|
+
import EventEmitter from 'events'
|
|
14
|
+
import SfRoute from './safeflow/index.js'
|
|
15
|
+
import LibraryRoute from './library/index.js'
|
|
16
|
+
// import HyperRoute from './hyperspace/index.js'
|
|
17
|
+
|
|
18
|
+
class HopMessages extends EventEmitter {
|
|
19
|
+
|
|
20
|
+
constructor() {
|
|
21
|
+
super()
|
|
22
|
+
console.log('{{HOP-Messages}}')
|
|
23
|
+
this.routeSafeflow = new SfRoute()
|
|
24
|
+
this.routeLibrary = new LibraryRoute()
|
|
25
|
+
// this.routeHyper = new HyperRoute()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Message in
|
|
30
|
+
* @method messageIn
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
messageIn = function (message) {
|
|
34
|
+
let routeMessage = {}
|
|
35
|
+
// verifty -> route ECS or back to network (or both)
|
|
36
|
+
let verifyState = this.verifyMessage()
|
|
37
|
+
// library sf-ECS data-API AI
|
|
38
|
+
if (verifyState === true) {
|
|
39
|
+
if (message.type === 'launch') {
|
|
40
|
+
routeMessage.type = 'launch'
|
|
41
|
+
routeMessage.data = 'pass'
|
|
42
|
+
} else if (message.reftype.trim() === 'ignore' && message.type.trim() === 'safeflow' ) {
|
|
43
|
+
// sf-ECS
|
|
44
|
+
routeMessage = this.routeSafeflow.assessMessage(message)
|
|
45
|
+
} else if (message.type.trim() === 'library') {
|
|
46
|
+
routeMessage = this.routeLibrary.assessMessage(message)
|
|
47
|
+
} else if (message.type.trim() === 'data-api') {
|
|
48
|
+
// routeMessage = this.routeHyper.()
|
|
49
|
+
} else if (message.type.trim() === 'bb-ai') {
|
|
50
|
+
// routeMessage = this.routeBBAi(options)
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
routeMessage.type = 'launch'
|
|
54
|
+
routeMessage.data = 'fail'
|
|
55
|
+
}
|
|
56
|
+
return routeMessage
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* check if signed, structure, warm cold, allow or disallow, order priority
|
|
61
|
+
* @method verifyMessage
|
|
62
|
+
*
|
|
63
|
+
*/
|
|
64
|
+
verifyMessage = function (message) {
|
|
65
|
+
// check for public key sign, format
|
|
66
|
+
// is between peer and HOP or from network?
|
|
67
|
+
return true
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default HopMessages
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
/**
|
|
3
|
+
* library - routing
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* @class LibraryRoute
|
|
7
|
+
* @package LibraryRoute
|
|
8
|
+
* @copyright Copyright (c) 2022 James Littlejohn
|
|
9
|
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-3.0.html
|
|
10
|
+
* @version $Id$
|
|
11
|
+
*/
|
|
12
|
+
import util from 'util'
|
|
13
|
+
import EventEmitter from 'events'
|
|
14
|
+
|
|
15
|
+
class LibraryRoute extends EventEmitter {
|
|
16
|
+
|
|
17
|
+
constructor() {
|
|
18
|
+
super()
|
|
19
|
+
console.log('{{library-route}}')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* type of safeflow message?
|
|
24
|
+
* @method assessMessage
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
assessMessage = function (options) {
|
|
28
|
+
console.log('type analaysis')
|
|
29
|
+
let messageRoute = {}
|
|
30
|
+
messageRoute.type = 'library'
|
|
31
|
+
messageRoute.action = options
|
|
32
|
+
return messageRoute
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default LibraryRoute
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
/**
|
|
3
|
+
* safeflow - routing
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* @class SfRoute
|
|
7
|
+
* @package SafeflowRoute
|
|
8
|
+
* @copyright Copyright (c) 2022 James Littlejohn
|
|
9
|
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-3.0.html
|
|
10
|
+
* @version $Id$
|
|
11
|
+
*/
|
|
12
|
+
import util from 'util'
|
|
13
|
+
import EventEmitter from 'events'
|
|
14
|
+
import SafeFlow from 'node-safeflow'
|
|
15
|
+
|
|
16
|
+
class SfRoute extends EventEmitter {
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
super()
|
|
20
|
+
console.log('{{sf-route}}')
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* type of safeflow message?
|
|
25
|
+
* @method assessMessage
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
assessMessage = function (options) {
|
|
29
|
+
console.log('type analaysis')
|
|
30
|
+
let messageRoute = {}
|
|
31
|
+
messageRoute.type = 'safeflow'
|
|
32
|
+
messageRoute.action = options
|
|
33
|
+
return messageRoute
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default SfRoute
|