-
Notifications
You must be signed in to change notification settings - Fork 0
/
certificate.js
23 lines (22 loc) · 1015 Bytes
/
certificate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module.exports = function(RED) {
const lib = require("./lib.js");
function certificate(config) {
const isObject = function(payload) { if(Object.prototype.toString.call(payload).indexOf('Object') !== -1) return true; else return false; }
RED.nodes.createNode(this,config);
this.ghgwallet = RED.nodes.getNode(config.wallet);
var node = this;
node.on('input', async function(msg) {
node.status({fill:'yellow',shape:"dot",text:""});
try {
const app_wallet = await node.ghgwallet.getGhgWallet();
msg.payload = await node.ghgwallet.getCertificate(msg.payload);
node.status({fill:'green',shape:"dot",text:""});
node.send(msg);
} catch(e) {
console.log(e);
node.status({fill:'red',shape:"dot",text:"Failed to send ("+e+")"});
}
});
}
RED.nodes.registerType("certificate",certificate);
}