@gregoriusrippenstein/node-red-contrib-introspection 0.5.8 → 0.5.9
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/nodes/60-client-code.js +61 -21
- package/package.json +3 -2
- package/plugins/sidebar.html +45 -14
package/nodes/60-client-code.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
module.exports = function(RED) {
|
|
2
|
+
let UglifyJS = require('uglify-js')
|
|
3
|
+
|
|
2
4
|
function ClientCodeFunctionality(config) {
|
|
3
5
|
RED.nodes.createNode(this,config);
|
|
4
6
|
|
|
@@ -26,27 +28,26 @@ module.exports = function(RED) {
|
|
|
26
28
|
RED.nodes.registerType("ClientCode", ClientCodeFunctionality);
|
|
27
29
|
|
|
28
30
|
RED.httpAdmin.post("/ClientCode/:id",
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
31
|
+
RED.auth.needsPermission("ClientCode.write"),
|
|
32
|
+
(req,res) => {
|
|
33
|
+
var node = RED.nodes.getNode(req.params.id);
|
|
34
|
+
if (node != null) {
|
|
35
|
+
try {
|
|
36
|
+
if (req.body && node.type == "ClientCode" ) {
|
|
37
|
+
node.send(req.body);
|
|
38
|
+
res.sendStatus(200);
|
|
39
|
+
} else {
|
|
40
|
+
res.sendStatus(404);
|
|
41
|
+
}
|
|
42
|
+
} catch(err) {
|
|
43
|
+
res.sendStatus(500);
|
|
44
|
+
node.error("ClientCode: Submission failed: " +
|
|
45
|
+
err.toString())
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
res.sendStatus(404);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
50
51
|
|
|
51
52
|
RED.httpAdmin.post("/ClientCode/:id/status",
|
|
52
53
|
RED.auth.needsPermission("ClientCode.write"),
|
|
@@ -70,4 +71,43 @@ module.exports = function(RED) {
|
|
|
70
71
|
}
|
|
71
72
|
});
|
|
72
73
|
|
|
74
|
+
RED.httpAdmin.post("/ClientCode/:id/ugify",
|
|
75
|
+
RED.auth.needsPermission("ClientCode.write"),
|
|
76
|
+
(req, res) => {
|
|
77
|
+
var node = RED.nodes.getNode(req.params.id);
|
|
78
|
+
if (node != null) {
|
|
79
|
+
try {
|
|
80
|
+
if (req.body ) {
|
|
81
|
+
req.body.nodes.forEach( n => {
|
|
82
|
+
|
|
83
|
+
if ( n.format == "javascript") {
|
|
84
|
+
/* this handles PkgFile nodes and template nodes */
|
|
85
|
+
let result = UglifyJS.minify(n.template, req.body.cfg)
|
|
86
|
+
if ( result.code && !result.error) {
|
|
87
|
+
n.template = result.code
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (n.type == "function") {
|
|
92
|
+
let result = UglifyJS.minify(n.func, req.body.cfg)
|
|
93
|
+
if (result.code && !result.error) {
|
|
94
|
+
n.func = result.code
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
res.status(200).send(req.body.nodes);
|
|
99
|
+
} else {
|
|
100
|
+
res.sendStatus(404);
|
|
101
|
+
}
|
|
102
|
+
} catch (err) {
|
|
103
|
+
res.sendStatus(500);
|
|
104
|
+
node.error("ClientCode: Submission failed: " +
|
|
105
|
+
err.toString())
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
res.sendStatus(404);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
|
|
73
113
|
}
|
package/package.json
CHANGED
package/plugins/sidebar.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
(function() {
|
|
3
3
|
var globalRefToSvgData;
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
let obfuscateHelpers={getFlowDataFromCurrentWorkspace:e=>{var e=e||RED.workspaces.active(),o=RED.nodes.groups(e),e=(o=(o=o.concat(RED.nodes.junctions(e))).concat(RED.nodes.filterNodes({z:e})),RED.nodes.eachConfig(function(e){e.z===RED.workspaces.active()&&!1===e._def.hasUsers&&o.push(e)}),RED.nodes.workspace(e)||RED.nodes.subflow(e));return o.unshift(e),RED.nodes.createExportableNodeSet(o)},openImportDialog:e=>{RED.clipboard.import();let o=e;setTimeout(()=>{$("#red-ui-clipboard-dialog-import-text").val(JSON.stringify(o)).trigger("paste")},300)}};function obfuscatieCurrentFlow(o){let t=obfuscateHelpers.getFlowDataFromCurrentWorkspace();t=t.filter(e=>"group"!=e.type);let r={},a=[];console.log("CFG",o),t.forEach(e=>{r[e.id]=e,o.name&&(e.name=e.id),o.info&&(e.info=""),o.position&&(e.x=150,e.y=150),!o.javascript||"javascript"!=e.format&&"function"!=e.type||a.push(e)}),0<a.length?$.ajax({url:"ClientCode/"+a[0].id+"/ugify",type:"POST",contentType:"application/json; charset=utf-8",data:JSON.stringify({nodes:a,cfg:{parse:{},compress:{},mangle:{reserved:["$","export","require"]},output:null,sourceMap:null,nameCache:null,toplevel:!1,warnings:!1}}),success:function(e){e.forEach(e=>{var o=r[e.id];"function"==o.type?o.func=e.func:"javascript"==o.format&&(o.template=e.template)}),obfuscateHelpers.openImportDialog(t)},error:function(e,o,t){RED.notify("ClientCode Communcation Failure: "+n.id+": "+o,{type:"error",timeout:3e3})}}):obfuscateHelpers.openImportDialog(t)}
|
|
6
6
|
|
|
7
7
|
function setupTreelist(){var e=collectOrphans();if(0==e.length){RED.notify("No Orphans Found",{type:"warning",timeout:2e3});try{$("#node-input-orphan-target-container-div").treeList("empty")}catch(e){}}else{try{$("#node-input-orphan-target-container-div").treeList("empty")}catch(e){$("#node-input-orphan-target-container-div").css({width:"100%",height:"calc(100%)"}).treeList({multi:!1}).on("treelistitemmouseover",function(e,t){t.node&&t.node.z==RED.workspaces.active()&&(RED.view.reveal(t.node.id,!0),RED.view.redraw())}).on("treelistitemmouseout",function(e,t){}).on("treelistselect",function(e,t){t.node&&(RED.workspaces.show(t.node.z,!1,!1,!0),RED.view.reveal(t.node.id,!0),RED.view.redraw())}).on("treelistconfirm",function(e,t){var n;t.node&&(n=t.node.id,setTimeout(()=>{var e=RED.nodes.node(n);e&&(RED.view.reveal(e.id),RED.view.select(e.id),RED.editor.edit(e)),n==RED.workspaces.active()&&RED.workspaces.edit()},50))}),$("#node-input-orphan-target-filter").show();var n=$("#node-input-orphan-target-filter").searchBox({style:"compact",delay:300,change:function(){var e,t=$(this).val().trim().toLowerCase();""===t?($("#node-input-orphan-target-container-div").treeList("filter",null),n.searchBox("count","")):(e=$("#node-input-orphan-target-container-div").treeList("filter",function(e){return-1<e.label.toLowerCase().indexOf(t)||-1<e.node.type.toLowerCase().indexOf(t)}),n.searchBox("count",e+" / "+$("#node-input-orphan-target-container-div").treeList("data").length))}})}$("#node-input-orphan-target-container-div").treeList("data",e.sort((e,t)=>e.node.z>t.node.z))}}function collectOrphans(){const t=new Set;var n=[],i=(RED.nodes.eachLink(e=>{t.add(e.source),t.add(e.target)}),RED.nodes.eachNode(e=>{t.has(e)||n.push(e)}),[]),r={};return n.forEach(function(e){var t=RED.nodes.getType(e.type);if(t){var n=t.label,n=("function"==typeof n?n.call(e):n)||"",o=e.type;if(0===o.indexOf("subflow:"))return}t&&n||(n=e.type),r[e.id]={node:e,label:n,sublabel:o,selected:!1,checkbox:!1},i.push(r[e.id])}),i}
|
|
8
8
|
|
|
@@ -57,19 +57,13 @@
|
|
|
57
57
|
|
|
58
58
|
$('#node-input-obfuscation-generate-btn').on("click", function (e) {
|
|
59
59
|
if ( e ) { e.preventDefault() }
|
|
60
|
-
|
|
61
|
-
let nodes = getFlowDataFromCurrentWorkspace()
|
|
62
|
-
|
|
63
|
-
nodes.forEach( (n) => {
|
|
64
|
-
n.name = n.id;
|
|
65
|
-
n.info = ""
|
|
66
|
-
n.x = 150
|
|
67
|
-
n.y = 150
|
|
68
|
-
})
|
|
69
60
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
61
|
+
obfuscatieCurrentFlow({
|
|
62
|
+
name: $('#node-input-obfuscate-name').is(":checked"),
|
|
63
|
+
info: $('#node-input-obfuscate-info').is(":checked"),
|
|
64
|
+
position: $('#node-input-obfuscate-position').is(":checked"),
|
|
65
|
+
javascript: $('#node-input-obfuscate-javascript').is(":checked"),
|
|
66
|
+
})
|
|
73
67
|
})
|
|
74
68
|
|
|
75
69
|
$('#node-screenshot-capture-btn').on("click", function (e) {
|
|
@@ -124,6 +118,10 @@
|
|
|
124
118
|
.col-100.no-label .red-ui-typedInput-container {
|
|
125
119
|
width: 100% !important;
|
|
126
120
|
}
|
|
121
|
+
.w-30 {
|
|
122
|
+
width: 30% !important;
|
|
123
|
+
margin-left: 10px;
|
|
124
|
+
}
|
|
127
125
|
</style>
|
|
128
126
|
|
|
129
127
|
<!-- The html for the right sidebar plugin screen -->
|
|
@@ -175,6 +173,7 @@
|
|
|
175
173
|
</div>
|
|
176
174
|
|
|
177
175
|
<div id="func-introspection-tab-obfuscation" style="display:none; min-height: calc(100%);">
|
|
176
|
+
|
|
178
177
|
<div class="form-row">
|
|
179
178
|
<div class="col-100">
|
|
180
179
|
<div class="form-row node-input-target-row" style="margin-left: 10px; margin-top: 30px">
|
|
@@ -183,7 +182,39 @@
|
|
|
183
182
|
</div>
|
|
184
183
|
</div>
|
|
185
184
|
</div>
|
|
186
|
-
|
|
185
|
+
|
|
186
|
+
<div class="form-row col-100">
|
|
187
|
+
<label for="node-input-obfuscate-name" class="w-30">
|
|
188
|
+
<i class="fa fa-tag"></i>
|
|
189
|
+
<span>Obfuscate Name?</span>
|
|
190
|
+
</label>
|
|
191
|
+
<input type="checkbox" checked=checked id="node-input-obfuscate-name"
|
|
192
|
+
style="display:inline-block; width:15px; vertical-align:baseline;">
|
|
193
|
+
</div>
|
|
194
|
+
<div class="form-row">
|
|
195
|
+
<label for="node-input-obfuscate-position" class="w-30">
|
|
196
|
+
<i class="fa fa-map-pin"></i>
|
|
197
|
+
<span>Obfuscate Position?</span>
|
|
198
|
+
</label>
|
|
199
|
+
<input type="checkbox" checked=checked id="node-input-obfuscate-position"
|
|
200
|
+
style="display:inline-block; width:15px; vertical-align:baseline;">
|
|
201
|
+
</div>
|
|
202
|
+
<div class="form-row">
|
|
203
|
+
<label for="node-input-obfuscate-info" class="w-30">
|
|
204
|
+
<i class="fa fa-info"></i>
|
|
205
|
+
<span>Obfuscate Info?</span>
|
|
206
|
+
</label>
|
|
207
|
+
<input type="checkbox" checked=checked id="node-input-obfuscate-info"
|
|
208
|
+
style="display:inline-block; width:15px; vertical-align:baseline;">
|
|
209
|
+
</div>
|
|
210
|
+
<div class="form-row">
|
|
211
|
+
<label for="node-input-obfuscate-javascript" class="w-30">
|
|
212
|
+
<i class="fa fa-code"></i>
|
|
213
|
+
<span>Obfuscate Javascript?</span>
|
|
214
|
+
</label>
|
|
215
|
+
<input type="checkbox" checked=checked id="node-input-obfuscate-javascript"
|
|
216
|
+
style="display:inline-block; width:15px; vertical-align:baseline;">
|
|
217
|
+
</div>
|
|
187
218
|
</div>
|
|
188
219
|
|
|
189
220
|
</script>
|