mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-24 22:25:48 +00:00
[CHORE] gulp lint cleanup
This commit is contained in:
@@ -2,7 +2,7 @@ var RippleTxt = require('./rippletxt').RippleTxt;
|
|||||||
var request = require('superagent');
|
var request = require('superagent');
|
||||||
|
|
||||||
function AuthInfo () {
|
function AuthInfo () {
|
||||||
this.rippleTxt = new RippleTxt;
|
this.rippleTxt = new RippleTxt();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,7 +17,7 @@ AuthInfo.prototype.get = function (domain, username, fn) {
|
|||||||
self.rippleTxt.get(domain, function(err, txt){
|
self.rippleTxt.get(domain, function(err, txt){
|
||||||
if (err) return fn(err);
|
if (err) return fn(err);
|
||||||
|
|
||||||
processTxt(txt)
|
processTxt(txt);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -31,6 +31,6 @@ AuthInfo.prototype.get = function (domain, username, fn) {
|
|||||||
fn(null, resp.body);
|
fn(null, resp.body);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports.AuthInfo = AuthInfo;
|
module.exports.AuthInfo = AuthInfo;
|
||||||
@@ -67,7 +67,7 @@ var nationalIDFields = [
|
|||||||
'number',
|
'number',
|
||||||
'type',
|
'type',
|
||||||
'country',
|
'country',
|
||||||
]
|
];
|
||||||
|
|
||||||
var idTypeFields = [
|
var idTypeFields = [
|
||||||
'ssn',
|
'ssn',
|
||||||
@@ -75,7 +75,7 @@ var idTypeFields = [
|
|||||||
'passport',
|
'passport',
|
||||||
'driversLicense',
|
'driversLicense',
|
||||||
'other'
|
'other'
|
||||||
]
|
];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize a new blob object
|
* Initialize a new blob object
|
||||||
@@ -112,7 +112,7 @@ BlobObj.prototype.init = function (fn) {
|
|||||||
fn(null, self);//return with newly decrypted blob
|
fn(null, self);//return with newly decrypted blob
|
||||||
|
|
||||||
}).timeout(8000);
|
}).timeout(8000);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -175,7 +175,7 @@ BlobObj.prototype.applyEncryptedPatch = function (patch)
|
|||||||
console.log(err.stack);
|
console.log(err.stack);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -550,8 +550,8 @@ var Identity = function (blob) {
|
|||||||
else return fn(null, true);
|
else return fn(null, true);
|
||||||
});
|
});
|
||||||
} else return fn(null, true);
|
} else return fn(null, true);
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -578,7 +578,7 @@ Identity.prototype.getFullAddress = function (key) {
|
|||||||
if (address.value.postalCode) text += " " + address.value.postalCode;
|
if (address.value.postalCode) text += " " + address.value.postalCode;
|
||||||
if (address.value.country) text += " " + address.value.country;
|
if (address.value.country) text += " " + address.value.country;
|
||||||
return text;
|
return text;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getAll
|
* getAll
|
||||||
@@ -598,7 +598,7 @@ Identity.prototype.getAll = function (key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -643,7 +643,7 @@ Identity.prototype.get = function (pointer, key) {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -709,7 +709,7 @@ Identity.prototype.set = function (pointer, key, value, fn) {
|
|||||||
data[pointer] = {
|
data[pointer] = {
|
||||||
encrypted : key ? true : false,
|
encrypted : key ? true : false,
|
||||||
value : key ? encrypt(key, value) : value
|
value : key ? encrypt(key, value) : value
|
||||||
}
|
};
|
||||||
|
|
||||||
self.blob.extend("/" + identityRoot, data, fn);
|
self.blob.extend("/" + identityRoot, data, fn);
|
||||||
});
|
});
|
||||||
@@ -718,7 +718,7 @@ Identity.prototype.set = function (pointer, key, value, fn) {
|
|||||||
if (typeof value === 'object') value = JSON.stringify(value);
|
if (typeof value === 'object') value = JSON.stringify(value);
|
||||||
return crypt.encrypt(key, value);
|
return crypt.encrypt(key, value);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -739,7 +739,7 @@ Identity.prototype.unset = function (pointer, key, fn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.blob.unset("/" + identityRoot+"/" + pointer, fn);
|
this.blob.unset("/" + identityRoot+"/" + pointer, fn);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -748,7 +748,7 @@ Identity.prototype.unset = function (pointer, key, fn) {
|
|||||||
/**
|
/**
|
||||||
* Blob object class
|
* Blob object class
|
||||||
*/
|
*/
|
||||||
BlobClient.Blob = BlobObj
|
BlobClient.Blob = BlobObj;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get ripple name for a given address
|
* Get ripple name for a given address
|
||||||
@@ -762,7 +762,7 @@ module.exports.getRippleName = function (url, address, fn) {
|
|||||||
else if (resp.body && resp.body.exists === false) return fn (new Error("No ripple name for this address"));
|
else if (resp.body && resp.body.exists === false) return fn (new Error("No ripple name for this address"));
|
||||||
else return fn(new Error("Unable to determine if ripple name exists"));
|
else return fn(new Error("Unable to determine if ripple name exists"));
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -771,7 +771,7 @@ module.exports.getRippleName = function (url, address, fn) {
|
|||||||
BlobClient.get = function (url, id, crypt, fn) {
|
BlobClient.get = function (url, id, crypt, fn) {
|
||||||
var blob = new BlobObj(url, id, crypt);
|
var blob = new BlobObj(url, id, crypt);
|
||||||
blob.init(fn);
|
blob.init(fn);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -784,7 +784,7 @@ BlobClient.verify = function (url, username, token, fn) {
|
|||||||
else if (resp.body && resp.body.result === 'success') return fn(null, data);
|
else if (resp.body && resp.body.result === 'success') return fn(null, data);
|
||||||
else return fn(new Error("Failed to verify the account"));
|
else return fn(new Error("Failed to verify the account"));
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -846,6 +846,6 @@ BlobClient.create = function (options, fn) {
|
|||||||
else if (resp.body && resp.body.result === 'success') return fn(null, blob,resp.body);
|
else if (resp.body && resp.body.result === 'success') return fn(null, blob,resp.body);
|
||||||
else return fn(new Error("Could not create blob"));
|
else return fn(new Error("Could not create blob"));
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports.BlobClient = BlobClient;
|
module.exports.BlobClient = BlobClient;
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
var sjcl = require('./utils').sjcl,
|
var sjcl = require('./utils').sjcl;
|
||||||
base = require('./base').Base,
|
var base = require('./base').Base;
|
||||||
UInt160 = require('./uint160').UInt160,
|
var UInt160 = require('./uint160').UInt160;
|
||||||
message = require('./message'),
|
var message = require('./message');
|
||||||
request = require('superagent'),
|
var request = require('superagent');
|
||||||
extend = require("extend"),
|
var extend = require("extend");
|
||||||
parser = require("url");
|
var parser = require("url");
|
||||||
|
var Crypt = {};
|
||||||
|
|
||||||
var cryptConfig = {
|
var cryptConfig = {
|
||||||
cipher : "aes",
|
cipher : "aes",
|
||||||
@@ -14,7 +15,6 @@ var cryptConfig = {
|
|||||||
iter : 1000 // iterations (key derivation)
|
iter : 1000 // iterations (key derivation)
|
||||||
};
|
};
|
||||||
|
|
||||||
var Crypt = {};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Full domain hash based on SHA512
|
* Full domain hash based on SHA512
|
||||||
@@ -104,9 +104,9 @@ Crypt.derive = function (opts, purpose, username, secret, fn) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var iBlind = iRandom.powermodMontgomery(iPublic.mul(iExponent), iModulus),
|
var iBlind = iRandom.powermodMontgomery(iPublic.mul(iExponent), iModulus);
|
||||||
iSignreq = iSecret.mulmod(iBlind, iModulus),
|
var iSignreq = iSecret.mulmod(iBlind, iModulus);
|
||||||
signreq = sjcl.codec.hex.fromBits(iSignreq.toBits());
|
var signreq = sjcl.codec.hex.fromBits(iSignreq.toBits());
|
||||||
|
|
||||||
request.post(opts.url)
|
request.post(opts.url)
|
||||||
.send({
|
.send({
|
||||||
@@ -118,13 +118,13 @@ Crypt.derive = function (opts, purpose, username, secret, fn) {
|
|||||||
|
|
||||||
var data = resp.body || resp.text ? JSON.parse(resp.text) : {};
|
var data = resp.body || resp.text ? JSON.parse(resp.text) : {};
|
||||||
|
|
||||||
if (!data.result=='success') return fn(new Error("Could not query PAKDF server "+opts.host));
|
if (data.result !== 'success') return fn(new Error("Could not query PAKDF server "+opts.host));
|
||||||
|
|
||||||
var iSignres = new sjcl.bn(String(data.signres));
|
var iSignres = new sjcl.bn(String(data.signres));
|
||||||
iRandomInv = iRandom.inverseMod(iModulus),
|
var iRandomInv = iRandom.inverseMod(iModulus);
|
||||||
iSigned = iSignres.mulmod(iRandomInv, iModulus),
|
var iSigned = iSignres.mulmod(iRandomInv, iModulus);
|
||||||
key = iSigned.toBits(),
|
var key = iSigned.toBits();
|
||||||
result = {};
|
var result = {};
|
||||||
|
|
||||||
tokens.forEach(function (token) {
|
tokens.forEach(function (token) {
|
||||||
result[token] = keyHash(key, token);
|
result[token] = keyHash(key, token);
|
||||||
@@ -132,7 +132,7 @@ Crypt.derive = function (opts, purpose, username, secret, fn) {
|
|||||||
|
|
||||||
fn (null, result);
|
fn (null, result);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Imported from ripple-client
|
* Imported from ripple-client
|
||||||
@@ -140,7 +140,7 @@ Crypt.derive = function (opts, purpose, username, secret, fn) {
|
|||||||
*/
|
*/
|
||||||
Crypt.RippleAddress = (function () {
|
Crypt.RippleAddress = (function () {
|
||||||
function append_int(a, i) {
|
function append_int(a, i) {
|
||||||
return [].concat(a, i >> 24, (i >> 16) & 0xff, (i >> 8) & 0xff, i & 0xff)
|
return [].concat(a, i >> 24, (i >> 16) & 0xff, (i >> 8) & 0xff, i & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
function firstHalfOfSHA512(bytes) {
|
function firstHalfOfSHA512(bytes) {
|
||||||
@@ -158,7 +158,7 @@ Crypt.RippleAddress = (function () {
|
|||||||
this.seed = base.decode_check(33, seed);
|
this.seed = base.decode_check(33, seed);
|
||||||
|
|
||||||
if (!this.seed) {
|
if (!this.seed) {
|
||||||
throw "Invalid seed."
|
throw "Invalid seed.";
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getAddress = function (seq) {
|
this.getAddress = function (seq) {
|
||||||
@@ -206,7 +206,7 @@ Crypt.encrypt = function(key, data)
|
|||||||
encryptedBits = sjcl.bitArray.concat(encryptedBits, ciphertext);
|
encryptedBits = sjcl.bitArray.concat(encryptedBits, ciphertext);
|
||||||
|
|
||||||
return sjcl.codec.base64.fromBits(encryptedBits);
|
return sjcl.codec.base64.fromBits(encryptedBits);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -214,8 +214,8 @@ Crypt.encrypt = function(key, data)
|
|||||||
* @params {string} key
|
* @params {string} key
|
||||||
* @params {string} data
|
* @params {string} data
|
||||||
*/
|
*/
|
||||||
Crypt.decrypt = function(key, data)
|
Crypt.decrypt = function (key, data) {
|
||||||
{
|
|
||||||
key = sjcl.codec.hex.toBits(key);
|
key = sjcl.codec.hex.toBits(key);
|
||||||
var encryptedBits = sjcl.codec.base64.toBits(data);
|
var encryptedBits = sjcl.codec.base64.toBits(data);
|
||||||
|
|
||||||
@@ -231,7 +231,7 @@ Crypt.decrypt = function(key, data)
|
|||||||
});
|
});
|
||||||
|
|
||||||
return sjcl.decrypt(key, JSON.stringify(encrypted));
|
return sjcl.decrypt(key, JSON.stringify(encrypted));
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -240,7 +240,7 @@ Crypt.decrypt = function(key, data)
|
|||||||
*/
|
*/
|
||||||
Crypt.isValidAddress = function (address) {
|
Crypt.isValidAddress = function (address) {
|
||||||
return UInt160.is_valid(address);
|
return UInt160.is_valid(address);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -249,7 +249,7 @@ Crypt.isValidAddress = function (address) {
|
|||||||
*/
|
*/
|
||||||
Crypt.createSecret = function (nWords) {
|
Crypt.createSecret = function (nWords) {
|
||||||
return sjcl.codec.hex.fromBits(sjcl.random.randomWords(nWords));
|
return sjcl.codec.hex.fromBits(sjcl.random.randomWords(nWords));
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -257,7 +257,7 @@ Crypt.createSecret = function (nWords) {
|
|||||||
*/
|
*/
|
||||||
Crypt.createMaster = function () {
|
Crypt.createMaster = function () {
|
||||||
return base.encode_check(33, sjcl.codec.bytes.fromBits(sjcl.random.randomWords(4)));
|
return base.encode_check(33, sjcl.codec.bytes.fromBits(sjcl.random.randomWords(4)));
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -266,7 +266,7 @@ Crypt.createMaster = function () {
|
|||||||
*/
|
*/
|
||||||
Crypt.getAddress = function (masterkey) {
|
Crypt.getAddress = function (masterkey) {
|
||||||
return new Crypt.RippleAddress(masterkey).getAddress();
|
return new Crypt.RippleAddress(masterkey).getAddress();
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -275,7 +275,7 @@ Crypt.getAddress = function (masterkey) {
|
|||||||
*/
|
*/
|
||||||
Crypt.hashSha512 = function (data) {
|
Crypt.hashSha512 = function (data) {
|
||||||
return sjcl.codec.hex.fromBits(sjcl.hash.sha512.hash(data));
|
return sjcl.codec.hex.fromBits(sjcl.hash.sha512.hash(data));
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -286,7 +286,7 @@ Crypt.hashSha512 = function (data) {
|
|||||||
Crypt.signString = function (secret, data) {
|
Crypt.signString = function (secret, data) {
|
||||||
var hmac = new sjcl.misc.hmac(sjcl.codec.hex.toBits(secret), sjcl.hash.sha512);
|
var hmac = new sjcl.misc.hmac(sjcl.codec.hex.toBits(secret), sjcl.hash.sha512);
|
||||||
return sjcl.codec.hex.fromBits(hmac.mac(data));
|
return sjcl.codec.hex.fromBits(hmac.mac(data));
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -299,7 +299,7 @@ Crypt.deriveRecoveryEncryptionKeyFromSecret = function(secret) {
|
|||||||
var key = hmac.mac("ripple/hmac/recovery_encryption_key/v1");
|
var key = hmac.mac("ripple/hmac/recovery_encryption_key/v1");
|
||||||
key = sjcl.bitArray.bitSlice(key, 0, 256);
|
key = sjcl.bitArray.bitSlice(key, 0, 256);
|
||||||
return sjcl.codec.hex.fromBits(key);
|
return sjcl.codec.hex.fromBits(key);
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert base64 encoded data into base64url encoded data.
|
* Convert base64 encoded data into base64url encoded data.
|
||||||
@@ -355,12 +355,12 @@ Crypt.getStringToSign = function (config, parsed, date, mechanism) {
|
|||||||
// We don't have a credential scope, so we skip it.
|
// We don't have a credential scope, so we skip it.
|
||||||
//
|
//
|
||||||
// But that modifies the format, so the format ID is RIPPLE1, instead of AWS4.
|
// But that modifies the format, so the format ID is RIPPLE1, instead of AWS4.
|
||||||
return stringToSign = [
|
return [
|
||||||
mechanism,
|
mechanism,
|
||||||
date,
|
date,
|
||||||
Crypt.hashSha512(canonicalRequest).toLowerCase()
|
Crypt.hashSha512(canonicalRequest).toLowerCase()
|
||||||
].join('\n');
|
].join('\n');
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -383,7 +383,7 @@ Crypt.signRequestHmac = function (config, auth_secret, blob_id) {
|
|||||||
'signature='+Crypt.base64ToBase64Url(signature)+
|
'signature='+Crypt.base64ToBase64Url(signature)+
|
||||||
'&signature_date='+date+
|
'&signature_date='+date+
|
||||||
'&signature_blob_id='+blob_id+
|
'&signature_blob_id='+blob_id+
|
||||||
'&signature_type='+signatureType
|
'&signature_type='+signatureType;
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
@@ -457,7 +457,7 @@ function isPlainObject(obj) {
|
|||||||
for ( key in obj ) {}
|
for ( key in obj ) {}
|
||||||
|
|
||||||
return key === undefined || hasOwn.call( obj, key );
|
return key === undefined || hasOwn.call( obj, key );
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
var dateAsIso8601 = (function () {
|
var dateAsIso8601 = (function () {
|
||||||
@@ -467,12 +467,12 @@ var dateAsIso8601 = (function () {
|
|||||||
|
|
||||||
return function dateAsIso8601() {
|
return function dateAsIso8601() {
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
return date.getUTCFullYear() + "-"
|
return date.getUTCFullYear() + "-" +
|
||||||
+ pad(date.getUTCMonth() + 1) + "-"
|
pad(date.getUTCMonth() + 1) + "-" +
|
||||||
+ pad(date.getUTCDate()) + "T"
|
pad(date.getUTCDate()) + "T" +
|
||||||
+ pad(date.getUTCHours()) + ":"
|
pad(date.getUTCHours()) + ":" +
|
||||||
+ pad(date.getUTCMinutes()) + ":"
|
pad(date.getUTCMinutes()) + ":" +
|
||||||
+ pad(date.getUTCSeconds()) + ".000Z";
|
pad(date.getUTCSeconds()) + ".000Z";
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ var request = require('superagent');
|
|||||||
|
|
||||||
function RippleTxt() {
|
function RippleTxt() {
|
||||||
this.txts = {};
|
this.txts = {};
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,7 +14,9 @@ function RippleTxt() {
|
|||||||
RippleTxt.prototype.get = function (domain, fn) {
|
RippleTxt.prototype.get = function (domain, fn) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (self.txts[domain]) return fn(null, self.txts[domain]);
|
if (self.txts[domain]) {
|
||||||
|
return fn(null, self.txts[domain]);
|
||||||
|
}
|
||||||
|
|
||||||
var urls = [
|
var urls = [
|
||||||
'https://ripple.'+domain+'/ripple.txt',
|
'https://ripple.'+domain+'/ripple.txt',
|
||||||
@@ -38,7 +40,7 @@ RippleTxt.prototype.get = function (domain, fn) {
|
|||||||
fn(null, sections);
|
fn(null, sections);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,6 +70,6 @@ RippleTxt.prototype.parse = function (txt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return sections;
|
return sections;
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports.RippleTxt = RippleTxt;
|
module.exports.RippleTxt = RippleTxt;
|
||||||
Reference in New Issue
Block a user