diff --git a/FireWalletBrowser.bsdesign b/FireWalletBrowser.bsdesign index b926f57..ae4e7da 100644 Binary files a/FireWalletBrowser.bsdesign and b/FireWalletBrowser.bsdesign differ diff --git a/README.md b/README.md index 6b1d321..c18439c 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ python3 main.py On Windows: ```bash -python main.py +python3 main.py ``` diff --git a/account.py b/account.py index 9b8b2ea..bd7e663 100644 --- a/account.py +++ b/account.py @@ -345,8 +345,7 @@ def setDNS(account,domain,records): newRecords.append({ 'type': 'TXT', 'txt': TXTRecords - }) - + }) data = '{"records":'+str(newRecords).replace("'","\"")+'}' response = hsw.sendUPDATE(account_name,password,domain,data) return response diff --git a/assets/plugin_page.png b/assets/plugin_page.png new file mode 100644 index 0000000..e875a36 Binary files /dev/null and b/assets/plugin_page.png differ diff --git a/assets/plugins.png b/assets/plugins.png new file mode 100644 index 0000000..eea6288 Binary files /dev/null and b/assets/plugins.png differ diff --git a/main.py b/main.py index a966e70..b19ebce 100644 --- a/main.py +++ b/main.py @@ -1237,8 +1237,14 @@ def report(): return redirect("/login") account = account_module.check_account(request.cookies.get("account")) + csv = '\n'.join(account_module.generateReport(account)) + # Create a download - return jsonify(account_module.generateReport(account)) + response = make_response(csv) + response.headers["Content-Disposition"] = "attachment; filename=report.csv" + response.headers["Content-Type"] = "text/csv" + return response + #endregion diff --git a/plugin.py b/plugin.py index b7bb4cf..659c43e 100644 --- a/plugin.py +++ b/plugin.py @@ -12,6 +12,8 @@ def listPlugins(): if file.endswith(".py"): if file != "main.py": plugin = importlib.import_module("plugins."+file[:-3]) + if "info" not in dir(plugin): + continue details = plugin.info details["link"] = file[:-3] plugins.append(details) diff --git a/plugins/template.py b/plugins/template.py new file mode 100644 index 0000000..2a5cf1c --- /dev/null +++ b/plugins/template.py @@ -0,0 +1,32 @@ +import json +import account +import requests + +# Plugin Data +info = { + "name": "Plugin Template", + "description": "Plugin Description", + "version": "1.0", + "author": "Nathan.Woodburn/" +} + +# Functions +functions = { + "main":{ + "name": "Function name", + "type": "dashboard", + "description": "Description", + "params": {}, + "returns": { + "status": + { + "name": "Status of the function", + "type": "text" + } + } + } +} + +def main(params, authentication): + return {"status": "Success"} + \ No newline at end of file diff --git a/plugins/varo.py b/plugins/varo.py new file mode 100644 index 0000000..1ea52b8 --- /dev/null +++ b/plugins/varo.py @@ -0,0 +1,135 @@ +import json +import account +import requests +import os +import dotenv + +# Plugin Data +info = { + "name": "Varo Functions", + "description": "Integration with Varo.", + "version": "1.0", + "author": "Nathan.Woodburn/" +} + +# Functions +functions = { + "status":{ + "name": "Check connection", + "type": "dashboard", + "description": "You need tp set varo_instance to the ICANN domain of the chosen Varo instance and varo_api to your varo API key before you can connect", + "params": {}, + "returns": { + "status": + { + "name": "Status of varo connection", + "type": "text" + } + } + }, + "addDomain":{ + "name": "Add domain", + "type": "default", + "description": "Add a domain to Varo", + "params": { + "domain": { + "name":"Domain", + "type":"text" + } + }, + "returns": { + "status": + { + "name": "Status of the function", + "type": "text" + } + } + + } +} + +def status(params, authentication): + # Try to connect to Varo + dotenv.load_dotenv() + api = os.getenv("varo_api") + instance = os.getenv("varo_instance") + + if not api or not instance: + return {"status": "Missing Varo API or instance"} + + headers = {"Authorization": f"Bearer {api}"} + data = { + "action": "getInfo" + } + response = requests.post(f"https://{instance}/api", json=data, headers=headers) + if response.status_code != 200: + return {"status": "Error connecting to Varo"} + if response.json()["success"] != True: + return {"status": "Error connecting to Varo"} + return {"status": "Success"} + +def addDomain(params, authentication): + # Add a domain to Varo + domain = params["domain"] + + dotenv.load_dotenv() + api = os.getenv("varo_api") + instance = os.getenv("varo_instance") + + if not api or not instance: + return {"status": "Missing Varo API or instance"} + + headers = {"Authorization": f"Bearer {api}"} + data = { + "action": "getZones" + } + zones = requests.post(f"https://{instance}/api", json=data, headers=headers) + if zones.status_code != 200: + return {"status": "Error connecting to Varo"} + if zones.json()["success"] != True: + return {"status": "Error connecting to Varo"} + + zones = zones.json()["data"] + for zone in zones: + if zone["name"] == domain: + return {"status": "Domain already exists"} + + # Check domain is owned by user + wallet = authentication.split(":")[0] + owned = account.getDomains(wallet) + # Only keep owned domains ["name"] + ownedNames = [domain["name"] for domain in owned] + if domain not in ownedNames: + return {"status": "Domain not owned by user"} + + data = { + "action": "createZone", + "domain": domain + } + response = requests.post(f"https://{instance}/api", json=data, headers=headers) + if response.status_code != 200: + return {"status": "Error connecting to Varo"} + if response.json()["success"] != True: + return {"status": "Error connecting to Varo"} + zoneID = response.json()["data"]["zone"] + data = { + "action": "showZone", + "zone": zoneID + } + response = requests.post(f"https://{instance}/api", json=data, headers=headers) + if response.status_code != 200: + return {"status": "Error connecting to Varo"} + if response.json()["success"] != True: + return {"status": "Error connecting to Varo"} + zone = response.json()["data"] + + dns = [] + for ns in zone['NS']: + dns.append({'type': 'NS', 'value': ns}) + ds = zone['DS'] + ds = ds.split(' ') + dns.append({'type': 'DS', 'keyTag': int(ds[0]), 'algorithm': int(ds[1]), 'digestType': int(ds[2]), 'digest': ds[3]}) + dns = json.dumps(dns) + response = account.setDNS(authentication,domain,dns) + + return {"status": "Success"} \ No newline at end of file diff --git a/templates/auctions.html b/templates/auctions.html index bdc6ae0..0896ff2 100644 --- a/templates/auctions.html +++ b/templates/auctions.html @@ -65,7 +65,7 @@
-

Dashboard

 Generate Report +

Bids

{{message}}