Dockerfile account creation with funds
This commit is contained in:
parent
b161f0892e
commit
06339ca86c
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@ -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.
|
//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 = {
|
config = {
|
||||||
avalonNode: "https://avalon.tld/",
|
avalonNode: process.env.avalonNode ||"https://avalon.tld/",
|
||||||
database: "keyStore",
|
database: process.env.database ||"keyStore",
|
||||||
jwtSecret: "jwtSecretjwtSecretjwtSecretjwtSecret" || process.env.jwtSecret,
|
jwtSecret: process.env.jwtSecret || "jwtSecretjwtSecretjwtSecretjwtSecret",
|
||||||
secret: "secretsecretsecretsecret" || process.env.jwtSecret,
|
secret: process.env.secret || "secretsecretsecretsecret",
|
||||||
mongoUrl: "mongodb://mongodbserver/",
|
mongoUrl: process.env.mongoUrl ||"mongodb://mongodbserver/",
|
||||||
expressPort: 3000,
|
expressPort: process.env.expressPort ||3000,
|
||||||
fee: 0,
|
fee: process.env.fee ||100,
|
||||||
discordUser: "userName#1970",
|
discordUser: process.env.discordUser ||"userName#1970",
|
||||||
accountCreator: {
|
accountCreator: {
|
||||||
username: "accountCreatorUsername",
|
username: process.env.username ||"accountCreatorUsername",
|
||||||
privKey: "",
|
privKey: process.env.privKey ||"EEEEEEEEEEEEEtc",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = config
|
module.exports = config
|
||||||
|
2069
package-lock.json
generated
Normal file
2069
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
25
package.json
Normal file
25
package.json
Normal file
@ -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")
|
mongo = require("../mongoHelp.js")
|
||||||
config = require("../config.js")
|
config = require("../config.js")
|
||||||
|
|
||||||
@ -15,10 +17,7 @@ function checkPayment(){
|
|||||||
if (userArr.length != 1){
|
if (userArr.length != 1){
|
||||||
console.log("UserArray too long, this could indicate duplicate IDs which would be bad")
|
console.log("UserArray too long, this could indicate duplicate IDs which would be bad")
|
||||||
} else {
|
} 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" ){
|
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 = {
|
tx = {
|
||||||
type: 0,
|
type: 0,
|
||||||
data: {
|
data: {
|
||||||
@ -32,8 +31,23 @@ function checkPayment(){
|
|||||||
console.log(err)
|
console.log(err)
|
||||||
} else {
|
} else {
|
||||||
userArr[0].status = "Active"
|
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)
|
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")
|
accountPrice = require("./utils/accountPrice.js")
|
||||||
|
|
||||||
crypto = require("crypto")
|
crypto = require("crypto")
|
||||||
uuidv4 = require('uuid/v4')
|
const { v4: uuidv4 } = require('uuid');
|
||||||
javalon = require("javalon")
|
javalon = require("javalon")
|
||||||
|
|
||||||
|
|
||||||
@ -28,8 +28,8 @@ function register(username, password){
|
|||||||
userObj.password = crypto.createHmac('sha256', config.secret).update(password).digest('hex')
|
userObj.password = crypto.createHmac('sha256', config.secret).update(password).digest('hex')
|
||||||
accountPrice(username).then(price => {
|
accountPrice(username).then(price => {
|
||||||
console.log(price)
|
console.log(price)
|
||||||
console.log(parseFloat(price)+config.fee)
|
console.log(parseFloat(price)+parseFloat(config.fee))
|
||||||
userObj.price = parseFloat(price)+config.fee
|
userObj.price = (parseFloat(price)+parseFloat(config.fee))
|
||||||
hPrice = (userObj.price/100)
|
hPrice = (userObj.price/100)
|
||||||
mongo.put(config.database, "users",userObj)
|
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")
|
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…
Reference in New Issue
Block a user