@5minds/node-red-contrib-processcube 1.5.2-develop-7add47-m2xezg12 → 1.5.2-feature-4db23e-m33j5ixt
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/processcube-engine-config.js +72 -25
package/package.json
CHANGED
@@ -12,8 +12,52 @@ module.exports = function (RED) {
|
|
12
12
|
this.url = RED.util.evaluateNodeProperty(n.url, n.urlType, node);
|
13
13
|
this.identity = null;
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
async function startUpdatingCredentialsCycle() {
|
16
|
+
let retries = 5;
|
17
|
+
const UPDATE_INTERVAL = 10000;
|
18
|
+
let previousClientId, previousClientSecret;
|
19
|
+
|
20
|
+
const updateCredentials = async () => {
|
21
|
+
try {
|
22
|
+
const newClientId = RED.util.evaluateNodeProperty(n.clientId, n.clientIdType, node);
|
23
|
+
const newClientSecret = RED.util.evaluateNodeProperty(n.clientSecret, n.clientSecretType, node);
|
24
|
+
|
25
|
+
if (newClientId !== previousClientId || newClientSecret !== previousClientSecret) {
|
26
|
+
if (this.engineClient) this.engineClient.dispose();
|
27
|
+
|
28
|
+
this.credentials.clientId = newClientId;
|
29
|
+
this.credentials.clientSecret = newClientSecret;
|
30
|
+
|
31
|
+
this.engineClient = new engine_client.EngineClient(this.url);
|
32
|
+
|
33
|
+
if (this.credentials.clientId && this.credentials.clientSecret) {
|
34
|
+
const authorityUrl = await this.engineClient.applicationInfo.getAuthorityAddress();
|
35
|
+
startRefreshingIdentityCycle(
|
36
|
+
this.credentials.clientId,
|
37
|
+
this.credentials.clientSecret,
|
38
|
+
authorityUrl,
|
39
|
+
node
|
40
|
+
).catch(console.error);
|
41
|
+
}
|
42
|
+
|
43
|
+
previousClientId = newClientId;
|
44
|
+
previousClientSecret = newClientSecret;
|
45
|
+
}
|
46
|
+
|
47
|
+
retries = 5;
|
48
|
+
setTimeout(updateCredentials, UPDATE_INTERVAL);
|
49
|
+
} catch (error) {
|
50
|
+
if (retries === 0) return console.error('Credential update failed permanently:', error);
|
51
|
+
console.error('Credential update error, retrying:', { error, retries });
|
52
|
+
retries--;
|
53
|
+
setTimeout(updateCredentials, 2000);
|
54
|
+
}
|
55
|
+
};
|
56
|
+
|
57
|
+
await updateCredentials();
|
58
|
+
}
|
59
|
+
|
60
|
+
console.log('luis888', this.credentials.clientId);
|
17
61
|
|
18
62
|
this.registerOnIdentityChanged = function (callback) {
|
19
63
|
identityChangedCallbacks.push(callback);
|
@@ -43,29 +87,32 @@ module.exports = function (RED) {
|
|
43
87
|
}
|
44
88
|
});
|
45
89
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
}
|
90
|
+
startUpdatingCredentialsCycle();
|
91
|
+
|
92
|
+
// if (this.credentials.clientId && this.credentials.clientSecret) {
|
93
|
+
// console.log('luis999', this.credentials.clientId);
|
94
|
+
// this.engineClient = new engine_client.EngineClient(this.url);
|
95
|
+
|
96
|
+
// this.engineClient.applicationInfo
|
97
|
+
// .getAuthorityAddress()
|
98
|
+
// .then((authorityUrl) => {
|
99
|
+
// startRefreshingIdentityCycle(
|
100
|
+
// this.credentials.clientId,
|
101
|
+
// this.credentials.clientSecret,
|
102
|
+
// authorityUrl,
|
103
|
+
// node
|
104
|
+
// ).catch((reason) => {
|
105
|
+
// console.error(reason);
|
106
|
+
// node.error(reason);
|
107
|
+
// });
|
108
|
+
// })
|
109
|
+
// .catch((reason) => {
|
110
|
+
// console.error(reason);
|
111
|
+
// node.error(reason);
|
112
|
+
// });
|
113
|
+
// } else {
|
114
|
+
// this.engineClient = new engine_client.EngineClient(this.url);
|
115
|
+
// }
|
69
116
|
}
|
70
117
|
RED.nodes.registerType('processcube-engine-config', ProcessCubeEngineNode, {
|
71
118
|
credentials: {
|