-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegration.js
More file actions
30 lines (28 loc) · 800 Bytes
/
Copy pathintegration.js
File metadata and controls
30 lines (28 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* Created by mohitbhansali on 22/03/18.
*/
"use strict";
var jsonwebtoken = require("jsonwebtoken");
module.exports.IntegrationKit = {
generateChecksum: function(data, key, cb) {
let payload = {"af_claim": JSON.stringify(data)};
jsonwebtoken.sign(payload, key, function(error, token) {
cb(undefined, token);
});
},
verifyChecksum: function(token, key, cb) {
try {
jsonwebtoken.verify(token, key, function (error, response) {
if(!error) {
if(response) {
cb(undefined,response.af_claim);
}
} else {
cb(error);
}
});
} catch(error) {
cb(error);
}
}
};