mirror of
https://github.com/yuto-yuto/node-red-contrib-password-generator.git
synced 2024-11-21 19:06:44 +01:00
Implement
This commit is contained in:
parent
ed05952bd1
commit
9211a8308a
@ -1,3 +1,4 @@
|
||||
test
|
||||
tsconfig.json
|
||||
index.ts
|
||||
Docker
|
3
Docker/.dockerignore
Normal file
3
Docker/.dockerignore
Normal file
@ -0,0 +1,3 @@
|
||||
./test
|
||||
./node_modules
|
||||
./Docker
|
8
Docker/Dockerfile
Normal file
8
Docker/Dockerfile
Normal file
@ -0,0 +1,8 @@
|
||||
FROM nodered/node-red
|
||||
|
||||
# error without this
|
||||
RUN mkdir -p ./password-generator/node_modules/
|
||||
|
||||
COPY ../package.json ../package-lock.json ./password-generator/
|
||||
COPY ../dist ./password-generator/dist
|
||||
RUN npm install ./password-generator --unsafe-perm --no-update-notifier --no-fund --only=production
|
9
Docker/docker-compose.yml
Normal file
9
Docker/docker-compose.yml
Normal file
@ -0,0 +1,9 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
nodered:
|
||||
image: nodered-update-detector
|
||||
ports:
|
||||
- "1880:1880"
|
||||
volumes:
|
||||
- ./flow:/data
|
412
Docker/flow/.config.nodes.json
Normal file
412
Docker/flow/.config.nodes.json
Normal file
@ -0,0 +1,412 @@
|
||||
{
|
||||
"node-red": {
|
||||
"name": "node-red",
|
||||
"version": "1.2.9",
|
||||
"local": false,
|
||||
"nodes": {
|
||||
"inject": {
|
||||
"name": "inject",
|
||||
"types": [
|
||||
"inject"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/common/20-inject.js"
|
||||
},
|
||||
"debug": {
|
||||
"name": "debug",
|
||||
"types": [
|
||||
"debug"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/common/21-debug.js"
|
||||
},
|
||||
"complete": {
|
||||
"name": "complete",
|
||||
"types": [
|
||||
"complete"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/common/24-complete.js"
|
||||
},
|
||||
"catch": {
|
||||
"name": "catch",
|
||||
"types": [
|
||||
"catch"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/common/25-catch.js"
|
||||
},
|
||||
"status": {
|
||||
"name": "status",
|
||||
"types": [
|
||||
"status"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/common/25-status.js"
|
||||
},
|
||||
"link": {
|
||||
"name": "link",
|
||||
"types": [
|
||||
"link in",
|
||||
"link out"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/common/60-link.js"
|
||||
},
|
||||
"comment": {
|
||||
"name": "comment",
|
||||
"types": [
|
||||
"comment"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/common/90-comment.js"
|
||||
},
|
||||
"unknown": {
|
||||
"name": "unknown",
|
||||
"types": [
|
||||
"unknown"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/common/98-unknown.js"
|
||||
},
|
||||
"function": {
|
||||
"name": "function",
|
||||
"types": [
|
||||
"function"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/function/10-function.js"
|
||||
},
|
||||
"switch": {
|
||||
"name": "switch",
|
||||
"types": [
|
||||
"switch"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/function/10-switch.js"
|
||||
},
|
||||
"change": {
|
||||
"name": "change",
|
||||
"types": [
|
||||
"change"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/function/15-change.js"
|
||||
},
|
||||
"range": {
|
||||
"name": "range",
|
||||
"types": [
|
||||
"range"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/function/16-range.js"
|
||||
},
|
||||
"template": {
|
||||
"name": "template",
|
||||
"types": [
|
||||
"template"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/function/80-template.js"
|
||||
},
|
||||
"delay": {
|
||||
"name": "delay",
|
||||
"types": [
|
||||
"delay"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/function/89-delay.js"
|
||||
},
|
||||
"trigger": {
|
||||
"name": "trigger",
|
||||
"types": [
|
||||
"trigger"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/function/89-trigger.js"
|
||||
},
|
||||
"exec": {
|
||||
"name": "exec",
|
||||
"types": [
|
||||
"exec"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/function/90-exec.js"
|
||||
},
|
||||
"tls": {
|
||||
"name": "tls",
|
||||
"types": [
|
||||
"tls-config"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/network/05-tls.js"
|
||||
},
|
||||
"httpproxy": {
|
||||
"name": "httpproxy",
|
||||
"types": [
|
||||
"http proxy"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/network/06-httpproxy.js"
|
||||
},
|
||||
"mqtt": {
|
||||
"name": "mqtt",
|
||||
"types": [
|
||||
"mqtt in",
|
||||
"mqtt out",
|
||||
"mqtt-broker"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/network/10-mqtt.js"
|
||||
},
|
||||
"httpin": {
|
||||
"name": "httpin",
|
||||
"types": [
|
||||
"http in",
|
||||
"http response"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/network/21-httpin.js"
|
||||
},
|
||||
"httprequest": {
|
||||
"name": "httprequest",
|
||||
"types": [
|
||||
"http request"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/network/21-httprequest.js"
|
||||
},
|
||||
"websocket": {
|
||||
"name": "websocket",
|
||||
"types": [
|
||||
"websocket in",
|
||||
"websocket out",
|
||||
"websocket-listener",
|
||||
"websocket-client"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/network/22-websocket.js"
|
||||
},
|
||||
"tcpin": {
|
||||
"name": "tcpin",
|
||||
"types": [
|
||||
"tcp in",
|
||||
"tcp out",
|
||||
"tcp request"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/network/31-tcpin.js"
|
||||
},
|
||||
"udp": {
|
||||
"name": "udp",
|
||||
"types": [
|
||||
"udp in",
|
||||
"udp out"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/network/32-udp.js"
|
||||
},
|
||||
"CSV": {
|
||||
"name": "CSV",
|
||||
"types": [
|
||||
"csv"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/parsers/70-CSV.js"
|
||||
},
|
||||
"HTML": {
|
||||
"name": "HTML",
|
||||
"types": [
|
||||
"html"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/parsers/70-HTML.js"
|
||||
},
|
||||
"JSON": {
|
||||
"name": "JSON",
|
||||
"types": [
|
||||
"json"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/parsers/70-JSON.js"
|
||||
},
|
||||
"XML": {
|
||||
"name": "XML",
|
||||
"types": [
|
||||
"xml"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/parsers/70-XML.js"
|
||||
},
|
||||
"YAML": {
|
||||
"name": "YAML",
|
||||
"types": [
|
||||
"yaml"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/parsers/70-YAML.js"
|
||||
},
|
||||
"split": {
|
||||
"name": "split",
|
||||
"types": [
|
||||
"split",
|
||||
"join"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/sequence/17-split.js"
|
||||
},
|
||||
"sort": {
|
||||
"name": "sort",
|
||||
"types": [
|
||||
"sort"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/sequence/18-sort.js"
|
||||
},
|
||||
"batch": {
|
||||
"name": "batch",
|
||||
"types": [
|
||||
"batch"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/sequence/19-batch.js"
|
||||
},
|
||||
"file": {
|
||||
"name": "file",
|
||||
"types": [
|
||||
"file",
|
||||
"file in"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/storage/10-file.js"
|
||||
},
|
||||
"watch": {
|
||||
"name": "watch",
|
||||
"types": [
|
||||
"watch"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/storage/23-watch.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"node-red-node-rbe": {
|
||||
"name": "node-red-node-rbe",
|
||||
"version": "0.2.9",
|
||||
"local": false,
|
||||
"nodes": {
|
||||
"rbe": {
|
||||
"name": "rbe",
|
||||
"types": [
|
||||
"rbe"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red-node-rbe",
|
||||
"file": "/usr/src/node-red/node_modules/node-red-node-rbe/rbe.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"node-red-node-tail": {
|
||||
"name": "node-red-node-tail",
|
||||
"version": "0.1.1",
|
||||
"local": false,
|
||||
"nodes": {
|
||||
"tail": {
|
||||
"name": "tail",
|
||||
"types": [
|
||||
"tail"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red-node-tail",
|
||||
"file": "/usr/src/node-red/node_modules/node-red-node-tail/28-tail.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"node-red-contrib-password-generator": {
|
||||
"name": "node-red-contrib-password-generator",
|
||||
"version": "1.0.0",
|
||||
"local": false,
|
||||
"nodes": {
|
||||
"valueChangeDetector": {
|
||||
"name": "valueChangeDetector",
|
||||
"types": [
|
||||
"password-generator"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red-contrib-password-generator",
|
||||
"file": "/usr/src/node-red/node_modules/node-red-contrib-password-generator/dist/lib/ValueChangeDetectorNode.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
410
Docker/flow/.config.nodes.json.backup
Normal file
410
Docker/flow/.config.nodes.json.backup
Normal file
@ -0,0 +1,410 @@
|
||||
{
|
||||
"node-red": {
|
||||
"name": "node-red",
|
||||
"version": "1.2.9",
|
||||
"local": false,
|
||||
"nodes": {
|
||||
"inject": {
|
||||
"name": "inject",
|
||||
"types": [
|
||||
"inject"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/common/20-inject.js"
|
||||
},
|
||||
"debug": {
|
||||
"name": "debug",
|
||||
"types": [
|
||||
"debug"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/common/21-debug.js"
|
||||
},
|
||||
"complete": {
|
||||
"name": "complete",
|
||||
"types": [
|
||||
"complete"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/common/24-complete.js"
|
||||
},
|
||||
"catch": {
|
||||
"name": "catch",
|
||||
"types": [
|
||||
"catch"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/common/25-catch.js"
|
||||
},
|
||||
"status": {
|
||||
"name": "status",
|
||||
"types": [
|
||||
"status"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/common/25-status.js"
|
||||
},
|
||||
"link": {
|
||||
"name": "link",
|
||||
"types": [
|
||||
"link in",
|
||||
"link out"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/common/60-link.js"
|
||||
},
|
||||
"comment": {
|
||||
"name": "comment",
|
||||
"types": [
|
||||
"comment"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/common/90-comment.js"
|
||||
},
|
||||
"unknown": {
|
||||
"name": "unknown",
|
||||
"types": [
|
||||
"unknown"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/common/98-unknown.js"
|
||||
},
|
||||
"function": {
|
||||
"name": "function",
|
||||
"types": [
|
||||
"function"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/function/10-function.js"
|
||||
},
|
||||
"switch": {
|
||||
"name": "switch",
|
||||
"types": [
|
||||
"switch"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/function/10-switch.js"
|
||||
},
|
||||
"change": {
|
||||
"name": "change",
|
||||
"types": [
|
||||
"change"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/function/15-change.js"
|
||||
},
|
||||
"range": {
|
||||
"name": "range",
|
||||
"types": [
|
||||
"range"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/function/16-range.js"
|
||||
},
|
||||
"template": {
|
||||
"name": "template",
|
||||
"types": [
|
||||
"template"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/function/80-template.js"
|
||||
},
|
||||
"delay": {
|
||||
"name": "delay",
|
||||
"types": [
|
||||
"delay"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/function/89-delay.js"
|
||||
},
|
||||
"trigger": {
|
||||
"name": "trigger",
|
||||
"types": [
|
||||
"trigger"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/function/89-trigger.js"
|
||||
},
|
||||
"exec": {
|
||||
"name": "exec",
|
||||
"types": [
|
||||
"exec"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/function/90-exec.js"
|
||||
},
|
||||
"tls": {
|
||||
"name": "tls",
|
||||
"types": [
|
||||
"tls-config"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/network/05-tls.js"
|
||||
},
|
||||
"httpproxy": {
|
||||
"name": "httpproxy",
|
||||
"types": [
|
||||
"http proxy"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/network/06-httpproxy.js"
|
||||
},
|
||||
"mqtt": {
|
||||
"name": "mqtt",
|
||||
"types": [
|
||||
"mqtt in",
|
||||
"mqtt out",
|
||||
"mqtt-broker"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/network/10-mqtt.js"
|
||||
},
|
||||
"httpin": {
|
||||
"name": "httpin",
|
||||
"types": [
|
||||
"http in",
|
||||
"http response"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/network/21-httpin.js"
|
||||
},
|
||||
"httprequest": {
|
||||
"name": "httprequest",
|
||||
"types": [
|
||||
"http request"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/network/21-httprequest.js"
|
||||
},
|
||||
"websocket": {
|
||||
"name": "websocket",
|
||||
"types": [
|
||||
"websocket in",
|
||||
"websocket out",
|
||||
"websocket-listener",
|
||||
"websocket-client"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/network/22-websocket.js"
|
||||
},
|
||||
"tcpin": {
|
||||
"name": "tcpin",
|
||||
"types": [
|
||||
"tcp in",
|
||||
"tcp out",
|
||||
"tcp request"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/network/31-tcpin.js"
|
||||
},
|
||||
"udp": {
|
||||
"name": "udp",
|
||||
"types": [
|
||||
"udp in",
|
||||
"udp out"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/network/32-udp.js"
|
||||
},
|
||||
"CSV": {
|
||||
"name": "CSV",
|
||||
"types": [
|
||||
"csv"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/parsers/70-CSV.js"
|
||||
},
|
||||
"HTML": {
|
||||
"name": "HTML",
|
||||
"types": [
|
||||
"html"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/parsers/70-HTML.js"
|
||||
},
|
||||
"JSON": {
|
||||
"name": "JSON",
|
||||
"types": [
|
||||
"json"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/parsers/70-JSON.js"
|
||||
},
|
||||
"XML": {
|
||||
"name": "XML",
|
||||
"types": [
|
||||
"xml"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/parsers/70-XML.js"
|
||||
},
|
||||
"YAML": {
|
||||
"name": "YAML",
|
||||
"types": [
|
||||
"yaml"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/parsers/70-YAML.js"
|
||||
},
|
||||
"split": {
|
||||
"name": "split",
|
||||
"types": [
|
||||
"split",
|
||||
"join"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/sequence/17-split.js"
|
||||
},
|
||||
"sort": {
|
||||
"name": "sort",
|
||||
"types": [
|
||||
"sort"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/sequence/18-sort.js"
|
||||
},
|
||||
"batch": {
|
||||
"name": "batch",
|
||||
"types": [
|
||||
"batch"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/sequence/19-batch.js"
|
||||
},
|
||||
"file": {
|
||||
"name": "file",
|
||||
"types": [
|
||||
"file",
|
||||
"file in"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/storage/10-file.js"
|
||||
},
|
||||
"watch": {
|
||||
"name": "watch",
|
||||
"types": [
|
||||
"watch"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red",
|
||||
"file": "/usr/src/node-red/node_modules/@node-red/nodes/core/storage/23-watch.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"node-red-node-rbe": {
|
||||
"name": "node-red-node-rbe",
|
||||
"version": "0.2.9",
|
||||
"local": false,
|
||||
"nodes": {
|
||||
"rbe": {
|
||||
"name": "rbe",
|
||||
"types": [
|
||||
"rbe"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red-node-rbe",
|
||||
"file": "/usr/src/node-red/node_modules/node-red-node-rbe/rbe.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"node-red-node-tail": {
|
||||
"name": "node-red-node-tail",
|
||||
"version": "0.1.1",
|
||||
"local": false,
|
||||
"nodes": {
|
||||
"tail": {
|
||||
"name": "tail",
|
||||
"types": [
|
||||
"tail"
|
||||
],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red-node-tail",
|
||||
"file": "/usr/src/node-red/node_modules/node-red-node-tail/28-tail.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"node-red-contrib-password-generator": {
|
||||
"name": "node-red-contrib-password-generator",
|
||||
"version": "1.0.0",
|
||||
"local": false,
|
||||
"nodes": {
|
||||
"valueChangeDetector": {
|
||||
"name": "valueChangeDetector",
|
||||
"types": [],
|
||||
"enabled": true,
|
||||
"local": false,
|
||||
"module": "node-red-contrib-password-generator",
|
||||
"file": "/usr/src/node-red/node_modules/node-red-contrib-password-generator/dist/lib/ValueChangeDetectorNode.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
3
Docker/flow/.config.runtime.json
Normal file
3
Docker/flow/.config.runtime.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"_credentialSecret": "ff189a0e025af5c3d64114660ad5b3db41b23d85bff47e534e23f9ce7ba337e3"
|
||||
}
|
14
Docker/flow/.config.users.json
Normal file
14
Docker/flow/.config.users.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"_": {
|
||||
"editor": {
|
||||
"view": {
|
||||
"view-show-grid": true,
|
||||
"view-snap-grid": true,
|
||||
"view-grid-size": 20,
|
||||
"view-node-status": true,
|
||||
"view-node-show-label": true,
|
||||
"view-show-tips": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1
Docker/flow/flows.json
Normal file
1
Docker/flow/flows.json
Normal file
@ -0,0 +1 @@
|
||||
[{"id":"e47bf00f.6dd9","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"9d0d423f.4c2ac","type":"password-generator","z":"e47bf00f.6dd9","name":"","key":"payload.key","value":"payload.value","x":360,"y":100,"wires":[["ae3a3bc8.0bee58"]]},{"id":"7a70ce.6e466f34","type":"inject","z":"e47bf00f.6dd9","name":"key1-Hello","props":[{"p":"payload.key","v":"key1","vt":"str"},{"p":"payload.value","v":"Hello","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":160,"y":100,"wires":[["9d0d423f.4c2ac"]]},{"id":"b60da092.9834e","type":"inject","z":"e47bf00f.6dd9","name":"key1-Hello","props":[{"p":"payload.key","v":"key2","vt":"str"},{"p":"payload.value","v":"Hello","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":160,"y":140,"wires":[["9d0d423f.4c2ac"]]},{"id":"ae3a3bc8.0bee58","type":"debug","z":"e47bf00f.6dd9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":600,"y":100,"wires":[]}]
|
6
Docker/flow/package.json
Normal file
6
Docker/flow/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "node-red-project",
|
||||
"description": "A Node-RED Project",
|
||||
"version": "0.0.1",
|
||||
"private": true
|
||||
}
|
348
Docker/flow/settings.js
Normal file
348
Docker/flow/settings.js
Normal file
@ -0,0 +1,348 @@
|
||||
/**
|
||||
* This is the default settings file provided by Node-RED.
|
||||
*
|
||||
* It can contain any valid JavaScript code that will get run when Node-RED
|
||||
* is started.
|
||||
*
|
||||
* Lines that start with // are commented out.
|
||||
* Each entry should be separated from the entries above and below by a comma ','
|
||||
*
|
||||
* For more information about individual settings, refer to the documentation:
|
||||
* https://nodered.org/docs/user-guide/runtime/configuration
|
||||
**/
|
||||
|
||||
module.exports = {
|
||||
// the tcp port that the Node-RED web server is listening on
|
||||
uiPort: process.env.PORT || 1880,
|
||||
|
||||
// By default, the Node-RED UI accepts connections on all IPv4 interfaces.
|
||||
// To listen on all IPv6 addresses, set uiHost to "::",
|
||||
// The following property can be used to listen on a specific interface. For
|
||||
// example, the following would only allow connections from the local machine.
|
||||
//uiHost: "127.0.0.1",
|
||||
|
||||
// Retry time in milliseconds for MQTT connections
|
||||
mqttReconnectTime: 15000,
|
||||
|
||||
// Retry time in milliseconds for Serial port connections
|
||||
serialReconnectTime: 15000,
|
||||
|
||||
// Retry time in milliseconds for TCP socket connections
|
||||
//socketReconnectTime: 10000,
|
||||
|
||||
// Timeout in milliseconds for TCP server socket connections
|
||||
// defaults to no timeout
|
||||
//socketTimeout: 120000,
|
||||
|
||||
// Maximum number of messages to wait in queue while attempting to connect to TCP socket
|
||||
// defaults to 1000
|
||||
//tcpMsgQueueSize: 2000,
|
||||
|
||||
// Timeout in milliseconds for HTTP request connections
|
||||
// defaults to 120 seconds
|
||||
//httpRequestTimeout: 120000,
|
||||
|
||||
// Maximum buffer size for the exec node
|
||||
// defaults to 10Mb
|
||||
//execMaxBufferSize: 10000000,
|
||||
|
||||
// Timeout in milliseconds for inbound WebSocket connections that do not
|
||||
// match any configured node.
|
||||
// defaults to 5000
|
||||
//inboundWebSocketTimeout: 5000
|
||||
|
||||
|
||||
// The maximum length, in characters, of any message sent to the debug sidebar tab
|
||||
debugMaxLength: 1000,
|
||||
|
||||
// The maximum number of messages nodes will buffer internally as part of their
|
||||
// operation. This applies across a range of nodes that operate on message sequences.
|
||||
// defaults to no limit. A value of 0 also means no limit is applied.
|
||||
//nodeMessageBufferMaxLength: 0,
|
||||
|
||||
// To disable the option for using local files for storing keys and certificates in the TLS configuration
|
||||
// node, set this to true
|
||||
//tlsConfigDisableLocalFiles: true,
|
||||
|
||||
// Colourise the console output of the debug node
|
||||
//debugUseColors: true,
|
||||
|
||||
// The file containing the flows. If not set, it defaults to flows_<hostname>.json
|
||||
//flowFile: 'flows.json',
|
||||
|
||||
// To enabled pretty-printing of the flow within the flow file, set the following
|
||||
// property to true:
|
||||
//flowFilePretty: true,
|
||||
|
||||
// By default, credentials are encrypted in storage using a generated key. To
|
||||
// specify your own secret, set the following property.
|
||||
// If you want to disable encryption of credentials, set this property to false.
|
||||
// Note: once you set this property, do not change it - doing so will prevent
|
||||
// node-red from being able to decrypt your existing credentials and they will be
|
||||
// lost.
|
||||
//credentialSecret: "a-secret-key",
|
||||
|
||||
// By default, all user data is stored in a directory called `.node-red` under
|
||||
// the user's home directory. To use a different location, the following
|
||||
// property can be used
|
||||
//userDir: '/home/nol/.node-red/',
|
||||
|
||||
// Node-RED scans the `nodes` directory in the userDir to find local node files.
|
||||
// The following property can be used to specify an additional directory to scan.
|
||||
//nodesDir: '/home/nol/.node-red/nodes',
|
||||
|
||||
// By default, the Node-RED UI is available at http://localhost:1880/
|
||||
// The following property can be used to specify a different root path.
|
||||
// If set to false, this is disabled.
|
||||
//httpAdminRoot: '/admin',
|
||||
|
||||
// Some nodes, such as HTTP In, can be used to listen for incoming http requests.
|
||||
// By default, these are served relative to '/'. The following property
|
||||
// can be used to specifiy a different root path. If set to false, this is
|
||||
// disabled.
|
||||
//httpNodeRoot: '/red-nodes',
|
||||
|
||||
// The following property can be used in place of 'httpAdminRoot' and 'httpNodeRoot',
|
||||
// to apply the same root to both parts.
|
||||
//httpRoot: '/red',
|
||||
|
||||
// When httpAdminRoot is used to move the UI to a different root path, the
|
||||
// following property can be used to identify a directory of static content
|
||||
// that should be served at http://localhost:1880/.
|
||||
//httpStatic: '/home/nol/node-red-static/',
|
||||
|
||||
// The maximum size of HTTP request that will be accepted by the runtime api.
|
||||
// Default: 5mb
|
||||
//apiMaxLength: '5mb',
|
||||
|
||||
// If you installed the optional node-red-dashboard you can set it's path
|
||||
// relative to httpRoot
|
||||
// Other optional properties include
|
||||
// readOnly:{boolean},
|
||||
// middleware:{function or array}, (req,res,next) - http middleware
|
||||
// ioMiddleware:{function or array}, (socket,next) - socket.io middleware
|
||||
//ui: { path: "ui" },
|
||||
|
||||
// Securing Node-RED
|
||||
// -----------------
|
||||
// To password protect the Node-RED editor and admin API, the following
|
||||
// property can be used. See http://nodered.org/docs/security.html for details.
|
||||
//adminAuth: {
|
||||
// type: "credentials",
|
||||
// users: [{
|
||||
// username: "admin",
|
||||
// password: "$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN.",
|
||||
// permissions: "*"
|
||||
// }]
|
||||
//},
|
||||
|
||||
// To password protect the node-defined HTTP endpoints (httpNodeRoot), or
|
||||
// the static content (httpStatic), the following properties can be used.
|
||||
// The pass field is a bcrypt hash of the password.
|
||||
// See http://nodered.org/docs/security.html#generating-the-password-hash
|
||||
//httpNodeAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."},
|
||||
//httpStaticAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."},
|
||||
|
||||
// The following property can be used to enable HTTPS
|
||||
// See http://nodejs.org/api/https.html#https_https_createserver_options_requestlistener
|
||||
// for details on its contents.
|
||||
// This property can be either an object, containing both a (private) key and a (public) certificate,
|
||||
// or a function that returns such an object:
|
||||
//// https object:
|
||||
//https: {
|
||||
// key: require("fs").readFileSync('privkey.pem'),
|
||||
// cert: require("fs").readFileSync('cert.pem')
|
||||
//},
|
||||
////https function:
|
||||
// https: function() {
|
||||
// // This function should return the options object, or a Promise
|
||||
// // that resolves to the options object
|
||||
// return {
|
||||
// key: require("fs").readFileSync('privkey.pem'),
|
||||
// cert: require("fs").readFileSync('cert.pem')
|
||||
// }
|
||||
// },
|
||||
|
||||
// The following property can be used to refresh the https settings at a
|
||||
// regular time interval in hours.
|
||||
// This requires:
|
||||
// - the `https` setting to be a function that can be called to get
|
||||
// the refreshed settings.
|
||||
// - Node.js 11 or later.
|
||||
//httpsRefreshInterval : 12,
|
||||
|
||||
// The following property can be used to cause insecure HTTP connections to
|
||||
// be redirected to HTTPS.
|
||||
//requireHttps: true,
|
||||
|
||||
// The following property can be used to disable the editor. The admin API
|
||||
// is not affected by this option. To disable both the editor and the admin
|
||||
// API, use either the httpRoot or httpAdminRoot properties
|
||||
//disableEditor: false,
|
||||
|
||||
// The following property can be used to configure cross-origin resource sharing
|
||||
// in the HTTP nodes.
|
||||
// See https://github.com/troygoode/node-cors#configuration-options for
|
||||
// details on its contents. The following is a basic permissive set of options:
|
||||
//httpNodeCors: {
|
||||
// origin: "*",
|
||||
// methods: "GET,PUT,POST,DELETE"
|
||||
//},
|
||||
|
||||
// If you need to set an http proxy please set an environment variable
|
||||
// called http_proxy (or HTTP_PROXY) outside of Node-RED in the operating system.
|
||||
// For example - http_proxy=http://myproxy.com:8080
|
||||
// (Setting it here will have no effect)
|
||||
// You may also specify no_proxy (or NO_PROXY) to supply a comma separated
|
||||
// list of domains to not proxy, eg - no_proxy=.acme.co,.acme.co.uk
|
||||
|
||||
// The following property can be used to add a custom middleware function
|
||||
// in front of all http in nodes. This allows custom authentication to be
|
||||
// applied to all http in nodes, or any other sort of common request processing.
|
||||
// It can be a single function or an array of middleware functions.
|
||||
//httpNodeMiddleware: function(req,res,next) {
|
||||
// // Handle/reject the request, or pass it on to the http in node by calling next();
|
||||
// // Optionally skip our rawBodyParser by setting this to true;
|
||||
// //req.skipRawBodyParser = true;
|
||||
// next();
|
||||
//},
|
||||
|
||||
|
||||
// The following property can be used to add a custom middleware function
|
||||
// in front of all admin http routes. For example, to set custom http
|
||||
// headers. It can be a single function or an array of middleware functions.
|
||||
// httpAdminMiddleware: function(req,res,next) {
|
||||
// // Set the X-Frame-Options header to limit where the editor
|
||||
// // can be embedded
|
||||
// //res.set('X-Frame-Options', 'sameorigin');
|
||||
// next();
|
||||
// },
|
||||
|
||||
// The following property can be used to pass custom options to the Express.js
|
||||
// server used by Node-RED. For a full list of available options, refer
|
||||
// to http://expressjs.com/en/api.html#app.settings.table
|
||||
//httpServerOptions: { },
|
||||
|
||||
// The following property can be used to verify websocket connection attempts.
|
||||
// This allows, for example, the HTTP request headers to be checked to ensure
|
||||
// they include valid authentication information.
|
||||
//webSocketNodeVerifyClient: function(info) {
|
||||
// // 'info' has three properties:
|
||||
// // - origin : the value in the Origin header
|
||||
// // - req : the HTTP request
|
||||
// // - secure : true if req.connection.authorized or req.connection.encrypted is set
|
||||
// //
|
||||
// // The function should return true if the connection should be accepted, false otherwise.
|
||||
// //
|
||||
// // Alternatively, if this function is defined to accept a second argument, callback,
|
||||
// // it can be used to verify the client asynchronously.
|
||||
// // The callback takes three arguments:
|
||||
// // - result : boolean, whether to accept the connection or not
|
||||
// // - code : if result is false, the HTTP error status to return
|
||||
// // - reason: if result is false, the HTTP reason string to return
|
||||
//},
|
||||
|
||||
// The following property can be used to seed Global Context with predefined
|
||||
// values. This allows extra node modules to be made available with the
|
||||
// Function node.
|
||||
// For example,
|
||||
// functionGlobalContext: { os:require('os') }
|
||||
// can be accessed in a function block as:
|
||||
// global.get("os")
|
||||
functionGlobalContext: {
|
||||
// os:require('os'),
|
||||
// jfive:require("johnny-five"),
|
||||
// j5board:require("johnny-five").Board({repl:false})
|
||||
},
|
||||
|
||||
// Allow the Function node to load additional npm modules
|
||||
functionExternalModules: false,
|
||||
|
||||
// `global.keys()` returns a list of all properties set in global context.
|
||||
// This allows them to be displayed in the Context Sidebar within the editor.
|
||||
// In some circumstances it is not desirable to expose them to the editor. The
|
||||
// following property can be used to hide any property set in `functionGlobalContext`
|
||||
// from being list by `global.keys()`.
|
||||
// By default, the property is set to false to avoid accidental exposure of
|
||||
// their values. Setting this to true will cause the keys to be listed.
|
||||
exportGlobalContextKeys: false,
|
||||
|
||||
// Uncomment the following to run node-red in your preferred language:
|
||||
// lang: "de",
|
||||
|
||||
// Context Storage
|
||||
// The following property can be used to enable context storage. The configuration
|
||||
// provided here will enable file-based context that flushes to disk every 30 seconds.
|
||||
// Refer to the documentation for further options: https://nodered.org/docs/api/context/
|
||||
//
|
||||
//contextStorage: {
|
||||
// default: {
|
||||
// module:"localfilesystem"
|
||||
// },
|
||||
//},
|
||||
|
||||
// The following property can be used to order the categories in the editor
|
||||
// palette. If a node's category is not in the list, the category will get
|
||||
// added to the end of the palette.
|
||||
// If not set, the following default order is used:
|
||||
//paletteCategories: ['subflows', 'common', 'function', 'network', 'sequence', 'parser', 'storage'],
|
||||
|
||||
// Configure the logging output
|
||||
logging: {
|
||||
// Only console logging is currently supported
|
||||
console: {
|
||||
// Level of logging to be recorded. Options are:
|
||||
// fatal - only those errors which make the application unusable should be recorded
|
||||
// error - record errors which are deemed fatal for a particular request + fatal errors
|
||||
// warn - record problems which are non fatal + errors + fatal errors
|
||||
// info - record information about the general running of the application + warn + error + fatal errors
|
||||
// debug - record information which is more verbose than info + info + warn + error + fatal errors
|
||||
// trace - record very detailed logging + debug + info + warn + error + fatal errors
|
||||
// off - turn off all logging (doesn't affect metrics or audit)
|
||||
level: "info",
|
||||
// Whether or not to include metric events in the log output
|
||||
metrics: false,
|
||||
// Whether or not to include audit events in the log output
|
||||
audit: false
|
||||
}
|
||||
},
|
||||
|
||||
// Configure how the runtime will handle external npm modules.
|
||||
// This covers:
|
||||
// - whether the editor will allow new node modules to be installed
|
||||
// - whether nodes, such as the Function node are allowed to have their
|
||||
// own dynamically configured dependencies.
|
||||
// The allow/denyList options can be used to limit what modules the runtime
|
||||
// will install/load. It can use '*' as a wildcard that matches anything.
|
||||
externalModules: {
|
||||
// autoInstall: false, // Whether the runtime will attempt to automatically install missing modules
|
||||
// autoInstallRetry: 30, // Interval, in seconds, between reinstall attempts
|
||||
// palette: { // Configuration for the Palette Manager
|
||||
// allowInstall: true, // Enable the Palette Manager in the editor
|
||||
// allowUpload: true, // Allow module tgz files to be uploaded and installed
|
||||
// allowList: [],
|
||||
// denyList: []
|
||||
// },
|
||||
// modules: { // Configuration for node-specified modules
|
||||
// allowInstall: true,
|
||||
// allowList: [],
|
||||
// denyList: []
|
||||
// }
|
||||
},
|
||||
|
||||
// Customising the editor
|
||||
editorTheme: {
|
||||
projects: {
|
||||
// To enable the Projects feature, set this value to true
|
||||
enabled: false,
|
||||
workflow: {
|
||||
// Set the default projects workflow mode.
|
||||
// - manual - you must manually commit changes
|
||||
// - auto - changes are automatically committed
|
||||
// This can be overridden per-user from the 'Git config'
|
||||
// section of 'User Settings' within the editor
|
||||
mode: "manual"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
28
lib/PasswordGenerator.ts
Normal file
28
lib/PasswordGenerator.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import * as crypto from "crypto";
|
||||
import { promisify } from "util";
|
||||
|
||||
const AsciiRange = {
|
||||
/** space */
|
||||
min: 32,
|
||||
/** childe mark ~ */
|
||||
max: 126,
|
||||
}
|
||||
|
||||
export async function generatePassword(size: number): Promise<string> {
|
||||
let result = "";
|
||||
while (true) {
|
||||
const bytes = await promisify(crypto.randomBytes)(size * 2);
|
||||
const byteArray = Array.from(bytes);
|
||||
const filtered = byteArray.filter(isInAsciiRange);
|
||||
result += String.fromCharCode(...filtered);
|
||||
if (result.length >= size) {
|
||||
result = result.slice(0, size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function isInAsciiRange(value: number) {
|
||||
return AsciiRange.min <= value && value <= AsciiRange.max;
|
||||
}
|
26
lib/PasswordGeneratorNode.html
Normal file
26
lib/PasswordGeneratorNode.html
Normal file
@ -0,0 +1,26 @@
|
||||
<script type="text/html" data-template-name="password-generator">
|
||||
<div class="form-row">
|
||||
<label for="node-input-key"><i class="fa fa-key"></i> Key prop</label>
|
||||
<input type="text" id="node-input-key" placeholder="payload.key">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-size"><i class="fa fa-database"></i> Size</label>
|
||||
<input type="text" id="node-input-size">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-to"><i class="fa fa-database"></i> to</label>
|
||||
<input type="text" id="node-input-to">
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-help-name="password-generator">
|
||||
<p>Send incoming message only when the value of the specified key path changes.</p>
|
||||
|
||||
<h3>Configuration</h3>
|
||||
<dl class="message-properties">
|
||||
<dt>size</dt>
|
||||
<dd> The output size of the string. </dd>
|
||||
<dt>to</dt>
|
||||
<dd> The property to set password. </dd>
|
||||
</dl>
|
||||
</script>
|
26
lib/PasswordGeneratorNode.ts
Normal file
26
lib/PasswordGeneratorNode.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import * as nodered from "node-red";
|
||||
import { generatePassword } from "./PasswordGenerator";
|
||||
import { PasswordGeneratorNodeDef } from "./PasswordGeneratorNodeDef";
|
||||
import * as yutolity from "yutolity";
|
||||
|
||||
// it can't set to the input event listener now
|
||||
// using any is workaround but not good
|
||||
interface PayloadType extends nodered.NodeMessageInFlow {
|
||||
to: string;
|
||||
}
|
||||
|
||||
export = (RED: nodered.NodeAPI): void => {
|
||||
RED.nodes.registerType("password-generator",
|
||||
function (this: nodered.Node, config: PasswordGeneratorNodeDef): void {
|
||||
RED.nodes.createNode(this, config);
|
||||
|
||||
this.on("input", async (msg: any, send, done) => {
|
||||
const password = await generatePassword(config.size);
|
||||
|
||||
const valueSetPath = msg.to || config.setTo || "payload";
|
||||
yutolity.setValue(msg, valueSetPath, password);
|
||||
send(msg);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
13
lib/PasswordGeneratorNodeDef.ts
Normal file
13
lib/PasswordGeneratorNodeDef.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import * as nodered from "node-red";
|
||||
|
||||
export interface PasswordGeneratorNodeDef
|
||||
extends nodered.NodeDef {
|
||||
size: number;
|
||||
setTo?: string;
|
||||
}
|
||||
|
||||
export interface PasswordGeneratorNodeProperties
|
||||
extends nodered.EditorNodeProperties {
|
||||
size: number;
|
||||
setTo?: string;
|
||||
}
|
20
lib/PasswordGeneratorNodeInit.ts
Normal file
20
lib/PasswordGeneratorNodeInit.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import * as nodered from "node-red";
|
||||
import { PasswordGeneratorNodeProperties } from "./PasswordGeneratorNodeDef";
|
||||
|
||||
declare const RED: nodered.EditorRED;
|
||||
const nodeName = "password-generator";
|
||||
RED.nodes.registerType<PasswordGeneratorNodeProperties>(nodeName, {
|
||||
category: "function",
|
||||
color: "#a6bbcf",
|
||||
defaults: {
|
||||
name: { value: "" },
|
||||
size: { value: "", validate: RED.validators.number() },
|
||||
setTo: { value: "" },
|
||||
},
|
||||
inputs: 1,
|
||||
outputs: 1,
|
||||
icon: "fas fa-not-equal",
|
||||
label: function () {
|
||||
return this.name || nodeName;
|
||||
},
|
||||
});
|
@ -1,29 +0,0 @@
|
||||
import isEqual from "fast-deep-equal";
|
||||
|
||||
interface KeyValue {
|
||||
key: unknown;
|
||||
value: unknown;
|
||||
}
|
||||
|
||||
export class ValueChangeDetector {
|
||||
private currentValues = new Map<string, unknown>();
|
||||
|
||||
public isUpdated(args: KeyValue): boolean {
|
||||
const current = this.currentValues.get(this.toString(args.key));
|
||||
if (current === undefined) {
|
||||
return true;
|
||||
}
|
||||
return !isEqual(current, args.value);
|
||||
}
|
||||
|
||||
public update(args: KeyValue): void {
|
||||
this.currentValues.set(this.toString(args.key), args.value);
|
||||
}
|
||||
|
||||
private toString(object: unknown): string {
|
||||
if (typeof object === "string") {
|
||||
return object;
|
||||
}
|
||||
return String(object);
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<script type="text/javascript">
|
||||
RED.nodes.registerType('value-change-detector', {
|
||||
category: 'function',
|
||||
color: '#a6bbcf',
|
||||
defaults: {
|
||||
name: { value: "" },
|
||||
key: { value: "", required: true },
|
||||
value: { value: "", required: true },
|
||||
},
|
||||
inputs: 1,
|
||||
outputs: 1,
|
||||
icon: "file.png",
|
||||
label: function () {
|
||||
return this.name || "value-change-detector";
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-template-name="value-change-detector">
|
||||
<div class="form-row">
|
||||
<label for="node-input-key"><i class="fa fa-tag"></i> Key prop</label>
|
||||
<input type="text" id="node-input-key" placeholder="payload.key">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-value"><i class="fa fa-tag"></i> Value prop</label>
|
||||
<input type="text" id="node-input-value" placeholder="payload.value">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-help-name="value-change-detector">
|
||||
<p>Send incoming message only when the value changes.</p>
|
||||
</script>
|
@ -1,20 +0,0 @@
|
||||
import * as nodered from "node-red";
|
||||
import * as yutolity from "yutolity";
|
||||
import { ValueChangeDetector } from "./ValueChangeDetector";
|
||||
import { ValueChangeDetectorNodeProperties } from "./ValueChangeDetectorNodeProperties";
|
||||
|
||||
export = (RED: nodered.NodeAPI) => {
|
||||
RED.nodes.registerType("value-change-detector",
|
||||
function (this: nodered.Node, config: ValueChangeDetectorNodeProperties): void {
|
||||
RED.nodes.createNode(this, config);
|
||||
|
||||
const detector = new ValueChangeDetector();
|
||||
|
||||
this.on('input', (msg: any) => {
|
||||
const targetValue = yutolity.getValueOf(msg.payload, config.key);
|
||||
this.send(msg);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,6 +0,0 @@
|
||||
import * as nodered from "node-red";
|
||||
|
||||
export interface ValueChangeDetectorNodeProperties extends nodered.NodeDef {
|
||||
key: string;
|
||||
value: string;
|
||||
}
|
2335
package-lock.json
generated
2335
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
25
package.json
25
package.json
@ -1,24 +1,34 @@
|
||||
{
|
||||
"name": "value-change-detector",
|
||||
"name": "node-red-contrib-password-generator",
|
||||
"version": "1.0.0",
|
||||
"description": "send message only when the value changes",
|
||||
"description": "Send message only when the specified key's value changes",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "tsc && cp ./lib/*.html ./dist/",
|
||||
"start": "node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS",
|
||||
"build": "tsc && cp ./lib/*.html ./dist/lib/",
|
||||
"build-d": "npm run build && docker build -t nodered-update-detector -f ./Docker/Dockerfile .",
|
||||
"clean": "rm -rf ./dist",
|
||||
"test": "mocha --recursive --require ts-node/register test/*.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"node-red",
|
||||
"value-change"
|
||||
"password-generator",
|
||||
"update-detector",
|
||||
"rbe"
|
||||
],
|
||||
"node-red": {
|
||||
"nodes": {
|
||||
"valueChangeDetector": "./dist/lib/ValueChangeDetectorNode.js"
|
||||
}
|
||||
},
|
||||
"author": "yuto-yuto",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.2.12",
|
||||
"@types/chai": "^4.2.21",
|
||||
"@types/mocha": "^8.0.3",
|
||||
"@types/node": "^12.0.0",
|
||||
"@types/node": "^12.20.16",
|
||||
"@types/node-red": "^1.1.1",
|
||||
"@types/node-red-node-test-helper": "^0.2.2",
|
||||
"@types/sinon": "^9.0.5",
|
||||
"chai": "^4.2.0",
|
||||
"mocha": "^8.1.3",
|
||||
@ -29,6 +39,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"yutolity": "^1.0.0"
|
||||
"node-red": "^1.3.5",
|
||||
"yutolity": "^1.1.1"
|
||||
}
|
||||
}
|
||||
|
57
test/PasswordGeneratorNode_spec.ts
Normal file
57
test/PasswordGeneratorNode_spec.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import "mocha";
|
||||
import { expect } from "chai";
|
||||
// import * as helper from "node-red-node-test-helper";
|
||||
import helper = require("node-red-node-test-helper");
|
||||
|
||||
import valueChangeNode = require("../lib/PasswordGeneratorNode");
|
||||
|
||||
describe("PasswordGeneratorNode", () => {
|
||||
before(() => {
|
||||
helper.init(require.resolve('node-red'));
|
||||
});
|
||||
|
||||
beforeEach((done) => {
|
||||
helper.startServer(done);
|
||||
});
|
||||
|
||||
afterEach((done) => {
|
||||
helper.unload().then(() => helper.stopServer(done));
|
||||
});
|
||||
|
||||
const nodeId = "node-id";
|
||||
const outNodeId = "out-node-id";
|
||||
const flows = [
|
||||
{
|
||||
id: nodeId,
|
||||
type: "password-generator",
|
||||
size: 10,
|
||||
setTo: "payload.value",
|
||||
name: "generator-name",
|
||||
wires: [[outNodeId]]
|
||||
},
|
||||
{
|
||||
id: outNodeId,
|
||||
type: "helper",
|
||||
}
|
||||
];
|
||||
|
||||
it("should be loaded", (done) => {
|
||||
helper.load([valueChangeNode], flows, () => {
|
||||
const node = helper.getNode(nodeId);
|
||||
expect(node.name).to.equal("generator-name");
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
it("should set value to the property specified in setTo", (done) => {
|
||||
helper.load([valueChangeNode], flows, () => {
|
||||
const node = helper.getNode(nodeId);
|
||||
const outNode = helper.getNode(outNodeId);
|
||||
outNode.on("input", (msg: any) => {
|
||||
expect(msg.payload.value).not.to.be.undefined;
|
||||
done();
|
||||
});
|
||||
node.receive({ payload: 1 });
|
||||
|
||||
}).catch(done);
|
||||
});
|
||||
});
|
11
test/PasswordGenerator_spec.ts
Normal file
11
test/PasswordGenerator_spec.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import "mocha";
|
||||
import { expect } from "chai";
|
||||
import { generatePassword } from "../lib/PasswordGenerator";
|
||||
|
||||
describe.only("PasswordGenerator", () => {
|
||||
it("should return true for the first time", async () => {
|
||||
const result = await generatePassword(10);
|
||||
console.log(`before: "${result}"`)
|
||||
expect(result).to.lengthOf(10);
|
||||
});
|
||||
});
|
@ -1,43 +0,0 @@
|
||||
import "mocha";
|
||||
import { expect } from "chai";
|
||||
import { ValueChangeDetector } from "../lib/ValueChangeDetector";
|
||||
|
||||
describe("ValueChangeDetector", () => {
|
||||
let instance: ValueChangeDetector;
|
||||
|
||||
beforeEach(() => {
|
||||
instance = new ValueChangeDetector();
|
||||
});
|
||||
|
||||
describe("isUpdated", () => {
|
||||
it("should return true for the first time", () => {
|
||||
const result = instance.isUpdated({ key: 1, value: 1 });
|
||||
expect(result).to.equal(true);
|
||||
});
|
||||
|
||||
it("should return false when specifying the same data", () => {
|
||||
const data = { key: "key", value: "value" };
|
||||
instance.update(data);
|
||||
const result = instance.isUpdated({ ...data });
|
||||
expect(result).to.equal(false);
|
||||
});
|
||||
|
||||
it("should return true for different key", () => {
|
||||
instance.update({ key: "key", value: "value" });
|
||||
const result = instance.isUpdated({ key: "key2", value: "value" });
|
||||
expect(result).to.equal(true);
|
||||
});
|
||||
|
||||
it("should convert number to string for key", () => {
|
||||
instance.update({ key: 1, value: "value" });
|
||||
const result = instance.isUpdated({ key: "1", value: "value" });
|
||||
expect(result).to.equal(false);
|
||||
});
|
||||
|
||||
it("should convert object to string for key", () => {
|
||||
instance.update({ key: { obj: 1 }, value: "value" });
|
||||
const result = instance.isUpdated({ key: { obj: 1 }, value: "value" });
|
||||
expect(result).to.equal(false);
|
||||
});
|
||||
});
|
||||
});
|
@ -41,10 +41,7 @@
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
"typeRoots": [
|
||||
"node_modules/@types",
|
||||
"../../node_modules/@types"
|
||||
], /* List of folders to include type definitions from. */
|
||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||
// "types": [], /* Type declaration files to be included in compilation. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
|
Loading…
Reference in New Issue
Block a user