Commit df5c0073 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

Merge pull request #361 from Insoleet/master

Multiple fixes in documents parsing
parents 07b2fbb1 95baeb3f
......@@ -14,7 +14,9 @@ module.exports = new function() {
raw += "Issuer: " + (json.issuer || json.pubkey) + "\n";
raw += "UniqueID: " + json.uid + '\n';
raw += "Timestamp: " + json.buid + '\n';
raw += json.sig || '';
if (json.sig) {
raw += json.sig + '\n';
}
return dos2unix(raw);
};
......@@ -25,7 +27,9 @@ module.exports = new function() {
raw += "IdtyTimestamp: " + json.idty_buid + '\n';
raw += "IdtySignature: " + json.idty_sig + '\n';
raw += "CertTimestamp: " + json.buid + '\n';
raw += json.sig || '';
if (json.sig) {
raw += json.sig + '\n';
}
return dos2unix(raw);
};
......@@ -34,7 +38,9 @@ module.exports = new function() {
raw += "IdtyUniqueID: " + json.uid + '\n';
raw += "IdtyTimestamp: " + json.buid + '\n';
raw += "IdtySignature: " + json.sig + '\n';
raw += json.revocation;
if (json.revocation) {
raw += json.revocation + '\n';
}
return dos2unix(raw);
};
......
......@@ -48,7 +48,7 @@ dtos.Membership = {
dtos.Memberships = {
"pubkey": String,
"uid": String,
"sigDate": Number,
"sigDate": String,
"memberships": [
{
"version": Number,
......@@ -310,7 +310,8 @@ dtos.Source = {
"type": String,
"noffset": Number,
"identifier": String,
"amount": Number
"amount": Number,
"base": Number
};
dtos.Sources = {
......
......@@ -59,7 +59,7 @@ function GenericParser (captures, multipleLinesFields, rawerFunc) {
let endOffset = str.match(/\n$/) ? 2 : 1;
obj.signature = sp[sp.length - endOffset];
obj.hash = hashf(str).toUpperCase();
obj.raw = sp.slice(0, sp.length - 1).join('\n') + '\n';
obj.raw = sp.slice(0, sp.length - endOffset).join('\n') + '\n';
var docLF = obj.raw.replace(/\r\n/g, "\n");
if(docLF.match(/\n$/)){
captures.forEach(function (cap) {
......
......@@ -25,9 +25,6 @@ function PeerParser (onError) {
obj.documentType = 'peer';
obj.endpoints = obj.endpoints || [];
// Removes trailing space
if (obj.endpoints.length > 0)
obj.endpoints.splice(obj.endpoints.length - 1, 1);
// Removes trailing signature
if (obj.endpoints.length > 0)
obj.endpoints.splice(obj.endpoints.length - 1, 1);
obj.getBMA = function() {
......
......@@ -26,6 +26,7 @@ function TransactionParser (onError) {
obj.documentType = 'transaction';
obj.comment = obj.comment || "";
obj.locktime = parseInt(obj.locktime) || 0;
obj.signatures.push(obj.signature)
};
this._verify = function(obj){
......
......@@ -70,7 +70,7 @@ function User (uid, options, node) {
issuer: pub,
currency: node.server.conf.currency
});
selfCert += crypto.signSync(selfCert, sec);
selfCert += crypto.signSync(selfCert, sec) + '\n';
post('/wot/add', {
"identity": selfCert
}, next);
......@@ -126,7 +126,7 @@ function User (uid, options, node) {
});
var sig = crypto.signSync(cert, sec);
post('/wot/certify', {
"cert": cert + sig
"cert": cert + sig + "\n"
}, next);
}
], function(err) {
......@@ -166,7 +166,7 @@ function User (uid, options, node) {
var sig = crypto.signSync(revocation, sec);
return Q.nfcall(post, '/wot/revoke', {
"revocation": revocation + sig
"revocation": revocation + sig + '\n'
});
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment