@5minds/node-red-contrib-processcube 1.7.6-feature-706e11-m6qjxnc2 → 1.7.6-feature-581893-m6tfilg9

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.
@@ -0,0 +1,156 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('check-authorization', {
3
+ category: 'ProcessCube',
4
+ color: '#02AFD6',
5
+ defaults: {
6
+ name: { value: '' },
7
+ engine: { value: '', type: 'processcube-engine-config' },
8
+ options: {
9
+ value: [{ label: '' }],
10
+ // validate: function (v) {
11
+ // const unique = new Set(
12
+ // v.map(function (o) {
13
+ // return o.label;
14
+ // })
15
+ // );
16
+ // return v.length === unique.size;
17
+ // },
18
+ },
19
+ },
20
+ inputs: 1,
21
+ outputs: 2,
22
+ outputLabels: function (index) {
23
+ if (index === 0) {
24
+ return 'Authorized'
25
+ } else {
26
+ return 'Unauthorized'
27
+ }
28
+ },
29
+ icon: 'font-awesome/fa-sign-in',
30
+ label: function () {
31
+ return this.name || 'check-authorization';
32
+ },
33
+ oneditprepare: function () {
34
+ $('#node-input-size').elementSizer({
35
+ width: '#node-input-width',
36
+ height: '#node-input-height',
37
+ group: '#node-input-group',
38
+ });
39
+
40
+ function generateOption(i, option) {
41
+ const container = $('<li/>', {
42
+ style: 'background: var(--red-ui-secondary-background, #fff); margin:0; padding:8px 0px 0px;',
43
+ });
44
+
45
+ const row = $('<div/>').appendTo(container);
46
+
47
+ $('<input/>', {
48
+ class: 'node-input-option-claim',
49
+ type: 'text',
50
+ style: 'margin-left:7px; width:calc(85%);',
51
+ placeholder: 'Claim',
52
+ value: option.claim,
53
+ })
54
+ .appendTo(row)
55
+ .typedInput({
56
+ type: 'str',
57
+ types: ['str'],
58
+ });
59
+
60
+ // Create delete button for the option
61
+ const finalSpan = $('<span/>', {
62
+ style: 'float:right; margin-right:8px;',
63
+ }).appendTo(row);
64
+ const deleteButton = $('<a/>', {
65
+ href: '#',
66
+ class: 'editor-button editor-button-small',
67
+ style: 'margin-top:7px; margin-left:5px;',
68
+ }).appendTo(finalSpan);
69
+ $('<i/>', { class: 'fa fa-remove' }).appendTo(deleteButton);
70
+
71
+ deleteButton.click(function () {
72
+ container.css({
73
+ background: 'var(--red-ui-secondary-background-inactive, #fee)',
74
+ });
75
+ container.fadeOut(300, function () {
76
+ $(this).remove();
77
+ });
78
+ });
79
+
80
+ $('#node-input-option-container').append(container);
81
+ }
82
+
83
+ $('#node-input-add-option').click(function () {
84
+ generateOption($('#node-input-option-container').children().length + 1, {});
85
+ $('#node-input-option-container-div').scrollTop(
86
+ $('#node-input-option-container-div').get(0).scrollHeight
87
+ );
88
+ });
89
+
90
+ for (let i = 0; i < this.options.length; i++) {
91
+ const option = this.options[i];
92
+ generateOption(i + 1, option);
93
+ }
94
+
95
+ $('#node-input-option-container').sortable({
96
+ axis: 'y',
97
+ handle: '.node-input-option-handle',
98
+ cursor: 'move',
99
+ });
100
+ },
101
+ oneditsave: function () {
102
+ const options = $('#node-input-option-container').children();
103
+ const node = this;
104
+ node.options = [];
105
+ options.each(function (i) {
106
+ const option = $(this);
107
+ const o = {
108
+ claim: option.find('.node-input-option-claim').val(),
109
+ };
110
+
111
+ node.options.push(o);
112
+ });
113
+ },
114
+ });
115
+ </script>
116
+
117
+ <script type="text/html" data-template-name="check-authorization">
118
+ <div class="form-row">
119
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
120
+ <input type="text" id="node-input-name" placeholder="Name" />
121
+ </div>
122
+
123
+ <div class="form-row">
124
+ <label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
125
+ <input type="text" id="node-input-engine" placeholder="Engine-URL" />
126
+ </div>
127
+
128
+ <div class="form-row form-row-flex node-input-option-container-row" style="margin-bottom: 0px;width: 100%">
129
+ <label for="node-input-width" style="vertical-align:top"><i class="fa fa-list-alt"></i> Claims</label>
130
+ <div id="node-input-option-container-div" style="box-sizing:border-box; border-radius:5px; height:257px; padding:5px; border:1px solid var(--red-ui-form-input-border-color, #ccc); overflow-y:scroll; display:inline-block; width: 70%;">
131
+ <ol id="node-input-option-container" style="list-style-type:none; margin:0;"></ol>
132
+ </div>
133
+ </div>
134
+ <!-- Add Option Button -->
135
+ <div class="form-row">
136
+ <a href="#" class="editor-button editor-button-small" id="node-input-add-option" style="margin-top:4px; margin-left:103px;"><i class="fa fa-plus"></i> <span>action</span></a>
137
+ </div>
138
+ </script>
139
+
140
+ <script type="text/markdown" data-help-name="check-authorization">
141
+ A Node that checks if a user has the specified claims
142
+
143
+ ## Configs
144
+
145
+ : name (string): name of the node
146
+ : engine (string): the engine to connect to
147
+
148
+ ## Outputs
149
+
150
+ : payload (string): The id of the processinstance that was terminated.
151
+
152
+ ### References
153
+
154
+ - [The ProcessCube&copy; Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform
155
+ - [ProcessCube&copy; LowCode Integration](https://processcube.io/docs/node-red) - LowCode integration in ProcessCube&copy;
156
+ </script>
@@ -0,0 +1,27 @@
1
+ module.exports = function (RED) {
2
+ function CheckAuthorization(config) {
3
+ RED.nodes.createNode(this, config);
4
+ const node = this;
5
+
6
+ const claimsToCheck = (config.options || []).map((option) => option.claim);
7
+
8
+ node.on('input', function (msg) {
9
+ if (!msg._client || !msg._client.user || typeof msg._client.user.claims !== "object") {
10
+ node.error("Invalid client claims in the input message", msg);
11
+ return;
12
+ }
13
+
14
+ const userClaims = msg._client.user.claims;
15
+
16
+ const isAuthorized = claimsToCheck.every((claim) => claim in userClaims);
17
+
18
+ if (isAuthorized) {
19
+ node.send([msg, undefined]);
20
+ } else {
21
+ node.send([undefined, msg]);
22
+ }
23
+ });
24
+ }
25
+
26
+ RED.nodes.registerType('check-authorization', CheckAuthorization);
27
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube",
3
- "version": "1.7.6-feature-706e11-m6qjxnc2",
3
+ "version": "1.7.6-feature-581893-m6tfilg9",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED nodes for ProcessCube",
6
6
  "scripts": {
@@ -35,6 +35,7 @@
35
35
  "node-red": {
36
36
  "version": ">=3.1.9",
37
37
  "nodes": {
38
+ "checkAuthorization": "check-authorization.js",
38
39
  "EndEventFinishedListener": "endevent-finished-listener.js",
39
40
  "externaltaskInput": "externaltask-input.js",
40
41
  "externaltaskOutput": "externaltask-output.js",