Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!this._protocol) {
this._protocol = this._host.map(() => {
return window.location.protocol.replace(':', '');
});
}
const transportUrls = this.getEndpoints();
let _sessionId;
let client;
for (let h = 0; h < hostLength; h++) {
// node client
if (isNode) {
const connectOptions = {
transport: Thrift.TBufferedTransport,
protocol: Thrift.TJSONProtocol,
path: '/',
headers: { Connection: 'close' },
https: this._protocol[h] === 'https',
};
const connection = Thrift.createHttpConnection(
this._host[h],
this._port[h],
connectOptions
);
connection.on('error', _logError);
client = Thrift.createClient(MapD, connection);
}
// browser client
if (hasWindow) {
const transport = new window.Thrift.Transport(transportUrls[h]);
var helloSvc = require('./gen-nodejs/helloSvc');
//ServiceHandler: Implement the hello service
var helloHandler = {
getMessage: function(name, result) {
var msg = "Hello " + name + "!";
console.log(msg);
result(null, msg);
}
}
//ServiceOptions: The I/O stack for the service
var helloSvcOpt = {
handler: helloHandler,
processor: helloSvc,
protocol: thrift.TJSONProtocol,
transport: thrift.TBufferedTransport
};
//ServerOptions: Define server features
var serverOpt = {
files: ".",
services: {"/hello": helloSvcOpt},
cors: {"http://localhost:9098": true},
headers: {"Content-Security-Policy":
"default-src 'self'; connect-src http://localhost:9099"}
}
//Create and start the web server
var port = process.argv[2];
thrift.createWebServer(serverOpt).listen(port);
console.log("Http/Thrift Server running on port: " + port);
var helloSvc = require('./gen-nodejs/helloSvc');
//ServiceHandler: Implement the hello service
var helloHandler = {
getMessage: function(name, result) {
var msg = "Hello " + name + "!";
console.log(msg);
result(null, msg);
}
}
//ServiceOptions: The I/O stack for the service
var helloSvcOpt = {
handler: helloHandler,
processor: helloSvc,
protocol: thrift.TJSONProtocol,
transport: thrift.TBufferedTransport
};
//ServerOptions: Define server features
var serverOpt = {
files: ".",
services: {"/hello": helloSvcOpt},
cors: {"http://localhost:9098": true}
}
//Create and start the web server
var port = process.argv[2];
thrift.createWebServer(serverOpt).listen(port);
console.log("Http/Thrift Server running on port: " + port);
console.log("Serving files from: " + __dirname);
var helloHandler = {
getMessage: function(name, result) {
if (typeof name !== "string" || name.length < 1) {
var e = new badMsg();
e.errorCode = 13;
e.msg = "No name";
result(e, null);
} else {
result(null, "Hello " + name + "!");
}
}
}
var helloErrorOpt = {
transport: thrift.TBufferedTransport,
protocol: thrift.TJSONProtocol,
processor: helloError,
handler: helloHandler
};
var serverOpt = {
files: ".",
services: { "/hello": helloErrorOpt }
}
var server = thrift.createWebServer(serverOpt);
var port = 9099;
server.listen(port);
console.log("Http/Thrift Server running on port: " + port);
console.log("Serving files from: " + __dirname);
response = "I'm not sure";
}
responses[uuid] = response;
connection.end();
});
},
get_response: function(uuid, result) {
result(null, responses[uuid]);
responses[uuid] = null;
},
}
var ftService = {
transport: thrift.TBufferedTransport,
protocol: thrift.TJSONProtocol,
processor: FileTransferSvc,
handler: ftsHandler
};
var ServerOptions = {
files: ".",
services: {
"/fts": ftService,
}
}
var server = thrift.createWebServer(ServerOptions);
var port = process.argv[2]; //8585
var cmdcenterport = process.argv[3]; //8081
server.listen(port);
console.log("Http/Thrift Server running on port: " + port);
//ServiceHandler: Implement the hello service
var helloHandler = {
counter: 0,
getMessage: function(name, result) {
this.counter++;
var msg = "" + this.counter + ") Hello " + name + "!";
console.log(msg);
result(null, msg);
}
}
//ServiceOptions: The I/O stack for the service
var helloSvcOpt = {
handler: helloHandler,
processor: helloSvc,
protocol: thrift.TJSONProtocol,
transport: thrift.TBufferedTransport
};
//ServerOptions: Define server features
var serverOpt = {
files: ".",
services: {
"/hello": helloSvcOpt
}
}
//Create and start the web server
var port = 9090;
thrift.createWebServer(serverOpt).listen(port);
console.log("Http/Thrift Server running on port: " + port);
var fs = require("fs");
var thrift = require('thrift');
var helloSvc = require('./gen-nodejs/helloSvc');
var helloHandler = {
getMessage: function(name, result) {
var msg = "Hello " + name + "!";
console.log(msg);
result(null, msg);
}
}
var helloSvcOpt = {
transport: thrift.TBufferedTransport,
protocol: thrift.TJSONProtocol,
processor: helloSvc,
handler: helloHandler
};
var serverOpt = {
files: ".",
tls: {
key: fs.readFileSync("key.pem"),
cert: fs.readFileSync("cert.pem")
},
services: {
"/hello": helloSvcOpt
}
}
var port = 9099;
dbl: function(val, result) {
console.log("Client call: " + val);
result(null, val * 2);
}
}
var helloService = {
transport: thrift.TBufferedTransport,
protocol: thrift.TJSONProtocol,
processor: HelloSvc,
handler: helloHandler
};
var dblService = {
transport: thrift.TBufferedTransport,
protocol: thrift.TJSONProtocol,
processor: TimesTwoSvc,
handler: timesTwoHandler
};
var ServerOptions = {
files: ".",
services: {
"/hello": helloService,
"/dbl": dblService,
}
}
var server = thrift.createWebServer(ServerOptions);
var port = 8585;
server.listen(port);
console.log("Http/Thrift Server running on port: " + port);
this.call_counter = this.call_counter || 0;
console.log("Client call: " + (++this.call_counter));
result(null, "Hello Apache Thrift for JavaScript " + this.call_counter);
}
}
var timesTwoHandler = {
dbl: function(val, result) {
console.log("Client call: " + val);
result(null, val * 2);
}
}
var helloService = {
transport: thrift.TBufferedTransport,
protocol: thrift.TJSONProtocol,
processor: HelloSvc,
handler: helloHandler
};
var dblService = {
transport: thrift.TBufferedTransport,
protocol: thrift.TJSONProtocol,
processor: TimesTwoSvc,
handler: timesTwoHandler
};
var ServerOptions = {
files: ".",
services: {
"/hello": helloService,
"/dbl": dblService,
let PubKey = require("./pubKey");
let PrivKey = require("./privKey");
let Hex = require("../hex");
let Nacl = require("tweetnacl");
let client;
let MODEL = require('./client/model');
const request = require('axios');
let thrift = require('thrift');
let chainService = require('blockchain-rpc/codegen/gen-nodejs/BlockChainService');
let blockChainThriftModel = require('blockchain-rpc/codegen/gen-nodejs/model_types');
let transport = thrift.TBufferedTransport;
let protocol = thrift.TJSONProtocol;
let APIServerIP;
let APIServerPort;
var chainConnection ;
var chainClient;
//algo must be a supported algorithm now: ed25519, secp256k1
Create = function (secret, algo) {
let pub;
let addr;
let privateKey;
let publicKey;
//default algorithm ed25519
switch (algo) {
case NameSecp256k1: