Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint-disable max-len */
/* eslint new-cap: [2, {newIsCapExceptions: ["bn"]}] */
'use strict';
const assert = require('assert');
const sjcl = require('ripple-lib').sjcl;
// fix normalize bug in scjl:
// https://github.com/bitwiseshiftleft/sjcl/pull/221
function normalizeFix(bn) {
while (bn.limbs.length > 0 && bn.limbs[bn.limbs.length - 1] === 0) {
bn.limbs.pop();
}
return bn;
}
function testExp(vec) {
const actual = normalizeFix(new sjcl.bn(vec.g).powermod(
new sjcl.bn(vec.e), new sjcl.bn(vec.m)));
const expected = new sjcl.bn(vec.r);
assert.strictEqual(actual.toString(), expected.toString());
}
'use strict';
var _ = require('lodash');
var util = require('util');
var request = require('request');
var moment = require('moment');
var EventEmitter = require('events').EventEmitter;
var ripple = require('ripple-lib');
var sjcl = ripple.sjcl;
var check = require('check-types');
var Promise = require('bluebird');
/* --------------------------------- CONSTS --------------------------------- */
var DEBUG = true;
var REQUEST_STATUS = {
QUEUED: 1,
REQUESTING: 2
};
var DEFAULT_PORT = undefined;
var IPP_PATTERN = /\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\:([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])\b/;
var hexMatch = new RegExp('(0x)?[0-9a-f]+');
var base64Match = new RegExp('^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})([=]{1,2})?$');
var sjcl = require('ripple-lib').sjcl;
var Memos = function (tx) {
var list = [];
//NOTE: keep all memos
// if ( tx.metaData.TransactionResult !== "tesSUCCESS" ) {
// return list;
// }
if (tx.Memos) {
tx.Memos.forEach(function(memo, i) {
var data = {
account : tx.Account,
memo_type : memo.Memo.MemoType,
memo_data : memo.Memo.MemoData,
'use strict';
var sjcl = require('ripple-lib').sjcl;
var Seed = require('ripple-lib').Seed;
var SerializedObject = require('ripple-lib').SerializedObject;
var validate = require('../lib/validate');
/**
* These prefixes are inserted before the source material used to
* generate various hashes. This is done to put each hash in its own
* "space." This way, two different types of objects with the
* same binary data will produce different hashes.
*
* Each prefix is a 4-byte value with the last byte set to zero
* and the first three bytes formed from the ASCII equivalent of
* some arbitrary string. For example "TXN".
*/
var HASH_TX_ID = 0x54584E00; // 'TXN'
var HASH_TX_SIGN = 0x53545800; // 'STX'
var _ = require('lodash');
var util = require('util');
var request = require('request');
var moment = require('moment');
var EventEmitter = require('events').EventEmitter;
var ripple = require('ripple-lib');
var sjcl = ripple.sjcl;
var check = require('check-types');
var Promise = require('bluebird')
/* --------------------------------- CONSTS --------------------------------- */
var DEBUG = true;
var REQUEST_STATUS = {
QUEUED: 1,
REQUESTING: 2
};
var DEFAULT_PORT = 51235
var IPP_PATTERN = /\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\:([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])\b/;
function withDeterministicPRNG(callback, done) {
var prng = ripple.sjcl.random;
ripple.sjcl.random = new PRNGMock();
callback(function(err, data) {
ripple.sjcl.random = prng;
done(err, data);
});
}
app.use(cors());
app.use(express.json());
app.use(express.urlencoded());
app.delete('/v1/user', hmac.middleware, api.blob.delete);
app.post('/v1/user/ecdsa', ecdsa.middleware, api.blob.create);
app.post('/v1/user', api.blob.create);
app.get('/v1/user/:username', api.user.get);
app.get('/v1/authinfo', api.user.authinfo);
app.get('/ripple.txt', function (req, res, next) {
res.send('[authinfo_url]\r\nhttp://localhost:'+config.port+'/v1/authinfo\r\n');
});
while(!ripple.sjcl.random.isReady()) {
ripple.sjcl.random.addEntropy(require('crypto').randomBytes(128).toString('base64')); //add entropy to seed the generator
}
server= http.createServer(app);
store.db('blob')
.truncate()
.then(function() {
server.listen(config.port,function() {
done();
});
});
});
var config = require('../../config');
var reporter = require('../../lib/reporter');
var utils = require('../../lib/utils');
var Queue = require('queuelib');
var client = require('blockscore')(config.blockscore.key);
var jumio = require('../../lib/jumio');
var sjcl = require('ripple-lib').sjcl;
var store = require('./store');
var getAttestation = require('./get');
module.exports = function (options, callback) {
if (!options.subject) {
return callback({
message : '\'subject\' identifier is required',
code : 400
});
} else if (!options.client_id) {
return callback({
message : '\'client_id\' is required',
code : 400
});
} else if (!options.profile &&
hmac.setStore(store);
app.use(cors());
app.use(express.json());
app.use(express.urlencoded());
app.delete('/v1/user', hmac.middleware, api.blob.delete);
app.post('/v1/user/ecdsa', ecdsa.middleware, api.blob.create);
app.post('/v1/user', api.blob.create);
app.get('/v1/user/:username', api.user.get);
app.get('/v1/authinfo', api.user.authinfo);
app.get('/ripple.txt', function (req, res, next) {
res.send('[authinfo_url]\r\nhttp://localhost:'+config.port+'/v1/authinfo\r\n');
});
while(!ripple.sjcl.random.isReady()) {
ripple.sjcl.random.addEntropy(require('crypto').randomBytes(128).toString('base64')); //add entropy to seed the generator
}
server= http.createServer(app);
store.db('blob')
.truncate()
.then(function() {
server.listen(config.port,function() {
done();
});
});
});
function withDeterministicPRNG(callback, done) {
var prng = ripple.sjcl.random;
ripple.sjcl.random = new PRNGMock();
callback(function(err, data) {
ripple.sjcl.random = prng;
done(err, data);
});
}