@5minds/node-red-contrib-processcube 1.5.2-feature-059ba7-m35qmr4f → 1.5.2-feature-03d546-m361r6u4
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/package.json +1 -1
- package/processcube-engine-config.js +42 -37
package/package.json
CHANGED
@@ -37,43 +37,48 @@ 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
|
+
configNode.setIdentity(freshIdentity);
|
75
|
+
|
76
|
+
return freshIdentity;
|
77
|
+
} catch (e) {
|
78
|
+
console.log('Could not get fresh identity', e);
|
79
|
+
node.error('Could not get fresh identity');
|
80
|
+
node.error(e);
|
81
|
+
}
|
77
82
|
}
|
78
83
|
|
79
84
|
node.on('close', async () => {
|