Dockerfile account creation with funds

master
nannal 3 years ago
parent b161f0892e
commit 06339ca86c

@ -0,0 +1,11 @@
FROM node:latest
ADD ./ /data
WORKDIR /data
RUN npm i
EXPOSE 3000
CMD ["node","index.js"]

@ -2,18 +2,17 @@
//Edit the values in this file and rename it to config.js or everyone will (rightfully) laugh at you when you ask for help.
config = {
avalonNode: "https://avalon.tld/",
database: "keyStore",
jwtSecret: "jwtSecretjwtSecretjwtSecretjwtSecret" || process.env.jwtSecret,
secret: "secretsecretsecretsecret" || process.env.jwtSecret,
mongoUrl: "mongodb://mongodbserver/",
expressPort: 3000,
fee: 0,
discordUser: "userName#1970",
avalonNode: process.env.avalonNode ||"https://avalon.tld/",
database: process.env.database ||"keyStore",
jwtSecret: process.env.jwtSecret || "jwtSecretjwtSecretjwtSecretjwtSecret",
secret: process.env.secret || "secretsecretsecretsecret",
mongoUrl: process.env.mongoUrl ||"mongodb://mongodbserver/",
expressPort: process.env.expressPort ||3000,
fee: process.env.fee ||100,
discordUser: process.env.discordUser ||"userName#1970",
accountCreator: {
username: "accountCreatorUsername",
privKey: "",
username: process.env.username ||"accountCreatorUsername",
privKey: process.env.privKey ||"EEEEEEEEEEEEEtc",
},
}
module.exports = config

2069
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,25 @@
{
"name": "dtubeauthproxy",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://gitea.nannal.com/nannal/DtubeAuthProxy"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"crypto": "^1.0.1",
"express": "^4.17.1",
"javalon": "^1.0.32",
"jsonwebtoken": "^8.5.1",
"mongodb": "^3.6.9",
"node-fetch": "^2.6.1",
"uuid": "^8.3.2"
}
}

@ -1,3 +1,5 @@
const { config } = require("javalon")
mongo = require("../mongoHelp.js")
config = require("../config.js")
@ -15,10 +17,7 @@ function checkPayment(){
if (userArr.length != 1){
console.log("UserArray too long, this could indicate duplicate IDs which would be bad")
} else {
console.log(element.txs[0].data.amount , userArr[0].price)
if (element.txs[0].data.memo == userArr[0]._id && element.txs[0].data.amount >= userArr[0].price && userArr[0].status == "Inactive" ){
id = userArr[0]._id
tx = {
type: 0,
data: {
@ -32,8 +31,23 @@ function checkPayment(){
console.log(err)
} else {
userArr[0].status = "Active"
mongo.update(config.database, "users", {_id: id}, userArr[0])
mongo.update(config.database, "users", {_id: userArr[0]._id}, userArr[0])
console.log(res)
tx2 = {
type: 3,
data: {
amount: Math.floor(config.fee)/2,
name: userArr[0].username
}
}
signedTx2 = javalon.sign(config.accountCreator.privKey,config.accountCreator.username, tx2)
javalon.sendTransaction(signedTx2, function(err, res) {
if (err){
console.log(err)
} else {
console.log(res)
}
})
}
})
}

@ -3,7 +3,7 @@ config = require("./config.js")
accountPrice = require("./utils/accountPrice.js")
crypto = require("crypto")
uuidv4 = require('uuid/v4')
const { v4: uuidv4 } = require('uuid');
javalon = require("javalon")
@ -28,8 +28,8 @@ function register(username, password){
userObj.password = crypto.createHmac('sha256', config.secret).update(password).digest('hex')
accountPrice(username).then(price => {
console.log(price)
console.log(parseFloat(price)+config.fee)
userObj.price = parseFloat(price)+config.fee
console.log(parseFloat(price)+parseFloat(config.fee))
userObj.price = (parseFloat(price)+parseFloat(config.fee))
hPrice = (userObj.price/100)
mongo.put(config.database, "users",userObj)
resolve("Account setup: account will be accessible after sending "+hPrice+" DTC to "+config.accountCreator.username+" with a memo line of '"+ userObj._id+"' or contact "+config.discordUser+" on Discord to arrange alternate payment")

Loading…
Cancel
Save