@5minds/node-red-contrib-processcube 1.5.2-feature-059ba7-m35qmr4f → 1.5.2-feature-95789a-m3625uau
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 +44 -37
package/package.json
CHANGED
@@ -37,43 +37,50 @@ module.exports = function (RED) {
|
|
37
37
|
};
|
38
38
|
|
39
39
|
async function getFreshIdentity(url) {
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
40
|
+
try {
|
41
|
+
if (
|
42
|
+
!RED.util.evaluateNodeProperty(n.clientId, n.clientIdType, node) ||
|
43
|
+
!RED.util.evaluateNodeProperty(n.clientSecret, n.clientSecretType, node)
|
44
|
+
)
|
45
|
+
return null;
|
46
|
+
const res = await fetch(url + '/atlas_engine/api/v1/authority', {
|
47
|
+
method: 'GET',
|
48
|
+
headers: {
|
49
|
+
Authorization: `Bearer ZHVtbXlfdG9rZW4=`,
|
50
|
+
'Content-Type': 'application/json',
|
51
|
+
},
|
52
|
+
});
|
53
|
+
|
54
|
+
const issuer = await oidc.Issuer.discover(await res.json());
|
55
|
+
|
56
|
+
const client = new issuer.Client({
|
57
|
+
client_id: RED.util.evaluateNodeProperty(n.clientId, n.clientIdType, node),
|
58
|
+
client_secret: RED.util.evaluateNodeProperty(n.clientSecret, n.clientSecretType, node),
|
59
|
+
});
|
60
|
+
|
61
|
+
const tokenSet = await client.grant({
|
62
|
+
grant_type: 'client_credentials',
|
63
|
+
scope: 'engine_etw engine_read engine_write',
|
64
|
+
});
|
65
|
+
|
66
|
+
const accessToken = tokenSet.access_token;
|
67
|
+
const decodedToken = jwt.jwtDecode(accessToken);
|
68
|
+
|
69
|
+
const freshIdentity = {
|
70
|
+
token: tokenSet.access_token,
|
71
|
+
userId: decodedToken.sub,
|
72
|
+
};
|
73
|
+
|
74
|
+
console.log('luis777', freshIdentity);
|
75
|
+
|
76
|
+
configNode.setIdentity(freshIdentity);
|
77
|
+
|
78
|
+
return freshIdentity;
|
79
|
+
} catch (e) {
|
80
|
+
console.log('Could not get fresh identity', e);
|
81
|
+
node.error('Could not get fresh identity');
|
82
|
+
node.error(e);
|
83
|
+
}
|
77
84
|
}
|
78
85
|
|
79
86
|
node.on('close', async () => {
|