2 Commits

Author SHA1 Message Date
cff65b167a feat: Update settings page
All checks were successful
Build Docker / Build Image (push) Successful in 35s
2024-11-22 12:04:55 +11:00
d2ad6eaa58 feat: Update varo plugin to make it easier to setup and use 2024-11-22 11:56:08 +11:00
5 changed files with 81 additions and 21 deletions

Binary file not shown.

View File

@@ -2,7 +2,9 @@ import json
import account import account
import requests import requests
import os import os
import dotenv
if not os.path.exists("user_data"):
os.mkdir("user_data")
# Plugin Data # Plugin Data
info = { info = {
@@ -17,7 +19,7 @@ functions = {
"status":{ "status":{
"name": "Check connection", "name": "Check connection",
"type": "dashboard", "type": "dashboard",
"description": "You need to set varo_instance to the ICANN domain of the chosen Varo instance and varo_api to your varo API key before you can connect", "description": "You need to login to the varo instance before you can use this function.",
"params": {}, "params": {},
"returns": { "returns": {
"status": "status":
@@ -27,6 +29,28 @@ functions = {
} }
} }
}, },
"login":{
"name": "Login to Varo",
"type": "default",
"description": "Login to Varo<br>Use the domain of the varo instance (eg. <a target='_blank' href='https://domains.hns.au'>domains.hns.au</a>) and API key from the dashboard.",
"params": {
"instance": {
"name":"Varo instance",
"type":"text"
},
"api": {
"name":"API key",
"type":"text"
}
},
"returns": {
"status":
{
"name": "Status of the function",
"type": "text"
}
}
},
"addDomain":{ "addDomain":{
"name": "Add domain", "name": "Add domain",
"type": "default", "type": "default",
@@ -50,13 +74,18 @@ functions = {
def status(params, authentication): def status(params, authentication):
# Try to connect to Varo # Try to connect to Varo
dotenv.load_dotenv() if not os.path.exists("user_data/varo.json"):
api = os.getenv("varo_api")
instance = os.getenv("varo_instance")
if not api or not instance:
return {"status": "Missing Varo API or instance"} return {"status": "Missing Varo API or instance"}
with open("user_data/varo.json", "r") as f:
auth = json.load(f)
if not auth:
return {"status": "Missing Varo API or instance"}
if 'api' not in auth or 'instance' not in auth:
return {"status": "Missing Varo API or instance"}
api = auth["api"]
instance = auth["instance"]
headers = {"Authorization": f"Bearer {api}"} headers = {"Authorization": f"Bearer {api}"}
data = { data = {
"action": "getInfo" "action": "getInfo"
@@ -66,19 +95,50 @@ def status(params, authentication):
return {"status": "Error connecting to Varo"} return {"status": "Error connecting to Varo"}
if response.json()["success"] != True: if response.json()["success"] != True:
return {"status": "Error connecting to Varo"} return {"status": "Error connecting to Varo"}
return {"status": f"Connected to {instance}"}
def login(params, authentication):
# Verify the user has entered the correct details
instance = params["instance"]
api = params["api"]
# Strip the https:// from the instance
instance = instance.replace("https://", "")
instance = instance.replace("http://", "")
response = requests.post(f"https://{instance}/api", json={"action": "getInfo"}, headers={"Authorization": f"Bearer {api}"})
if response.status_code != 200:
return {"status": "Error connecting to Varo"}
if response.json()["success"] != True:
return {"status": "Error connecting to Varo"}
auth = {
"instance": instance,
"api": api
}
# Save the API key to the varo.json file
with open("user_data/varo.json", "w") as f:
json.dump(auth, f)
return {"status": "Success"} return {"status": "Success"}
def addDomain(params, authentication): def addDomain(params, authentication):
# Add a domain to Varo # Add a domain to Varo
domain = params["domain"] domain = params["domain"]
dotenv.load_dotenv() if not os.path.exists("user_data/varo.json"):
api = os.getenv("varo_api")
instance = os.getenv("varo_instance")
if not api or not instance:
return {"status": "Missing Varo API or instance"} return {"status": "Missing Varo API or instance"}
with open("user_data/varo.json", "r") as f:
auth = json.load(f)
if not auth:
return {"status": "Missing Varo API or instance"}
if 'api' not in auth or 'instance' not in auth:
return {"status": "Missing Varo API or instance"}
api = auth["api"]
instance = auth["instance"]
headers = {"Authorization": f"Bearer {api}"} headers = {"Authorization": f"Bearer {api}"}
data = { data = {
"action": "getZones" "action": "getZones"

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -110,8 +110,8 @@
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<h4 class="card-title">About</h4> <h4 class="card-title">About</h4>
<h6 class="text-muted card-subtitle mb-2">FireWallet version: <code>{{version}}</code></h6> <h6 class="text-muted card-subtitle mb-2">FireWallet is a UI to allow easy connection with HSD created by <a href="https://nathan.woodburn.au" target="_blank">Nathan.Woodburn/</a> and freely available. Please contact him <a href="https://l.woodburn.au/contact" target="_blank">here</a> if you would like to request any features or report any bugs.<br>FireWallet version: <code>{{version}}</code></h6>
<div class="text-center"><a href="https://github.com/nathanwoodburn/firewalletbrowser" style="margin: 15px;color: var(--bs-emphasis-color);text-decoration:none;" target="_blank"><i class="icon ion-social-github" style="color: var(--bs-emphasis-color);"></i>&nbsp;Github</a><a href="https://firewallet.au" style="margin: 15px;color: var(--bs-emphasis-color);text-decoration:none;" target="_blank"><i class="icon ion-ios-information" style="color: var(--bs-emphasis-color);"></i>&nbsp;Website</a><a href="https://l.woodburn.au/donate" style="margin: 15px;color: var(--bs-emphasis-color);text-decoration:none;" target="_blank"><i class="icon ion-social-usd" style="color: var(--bs-emphasis-color);"></i>&nbsp;Donate</a></div> <div class="text-center"><a href="https://github.com/nathanwoodburn/firewalletbrowser" style="margin: 15px;color: var(--bs-emphasis-color);text-decoration:none;" target="_blank"><i class="icon ion-social-github" style="color: var(--bs-emphasis-color);"></i>&nbsp;Github</a><a href="https://firewallet.au" style="margin: 15px;color: var(--bs-emphasis-color);text-decoration:none;" target="_blank"><i class="icon ion-ios-information" style="color: var(--bs-emphasis-color);"></i>&nbsp;Website</a><a href="https://l.woodburn.au/donate" style="margin: 15px;color: var(--bs-emphasis-color);text-decoration:none;" target="_blank"><i class="icon ion-social-usd" style="color: var(--bs-emphasis-color);"></i>&nbsp;Donate to support development</a></div>
</div> </div>
</div> </div>
</div> </div>