feat: Add login with signature
This commit is contained in:
parent
448b5160ca
commit
73a8708b0f
46
hnslinks.py
46
hnslinks.py
@ -7,7 +7,7 @@ import os
|
|||||||
# Plugin Data
|
# Plugin Data
|
||||||
info = {
|
info = {
|
||||||
"name": "HNS Links",
|
"name": "HNS Links",
|
||||||
"description": "This is a plugin to quickly setup a HNS Links site<br>1. Connect varo instance with api key<br>2. Add domain to varo<br> 3. Add it to hns-links<br>4. Wait a few minutes and add it to HNS Links to ensure the TLSA is correct<br>5. Wait for the DNS update to propogate (up to 7 hrs)",
|
"description": "This is a plugin to quickly setup a HNS Links site<br>1. Connect varo instance with api key<br>2. Add domain to varo<br> 3. Add it to HNS Links<br>4. Wait a few minutes and readd it to HNS Links to ensure the generated TLSA is added<br>5. Wait for the DNS update to propogate (up to 7 hrs)",
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"author": "Nathan.Woodburn/"
|
"author": "Nathan.Woodburn/"
|
||||||
}
|
}
|
||||||
@ -73,7 +73,24 @@ functions = {
|
|||||||
"type": "text"
|
"type": "text"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"edit": {
|
||||||
|
"name":" Edit HNS Links",
|
||||||
|
"type": "default",
|
||||||
|
"description": "Login and Edit your HNS Links",
|
||||||
|
"params": {
|
||||||
|
"domain": {
|
||||||
|
"name":"Domain",
|
||||||
|
"type":"text"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"returns": {
|
||||||
|
"url":
|
||||||
|
{
|
||||||
|
"name": "Login URL",
|
||||||
|
"type": "text"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,3 +307,28 @@ def hnslinks(params, authentication):
|
|||||||
return {"status": "YAY!!! All done! Just wait a few minutes for HNS Links to fully initialize the site."}
|
return {"status": "YAY!!! All done! Just wait a few minutes for HNS Links to fully initialize the site."}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def edit(params, authentication):
|
||||||
|
# Verify domain is owned by user
|
||||||
|
domain = params["domain"]
|
||||||
|
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"}
|
||||||
|
|
||||||
|
# Get wallet address
|
||||||
|
address = account.getAddress(wallet)
|
||||||
|
if address == "":
|
||||||
|
return {"status": "Error getting wallet address"}
|
||||||
|
|
||||||
|
# Sign message hns-links
|
||||||
|
response = account.signMessage(authentication,domain,"hns-links")
|
||||||
|
if "error" in response and response["error"]:
|
||||||
|
return {"status": f"Error: {response['error']}"}
|
||||||
|
|
||||||
|
if 'result' not in response:
|
||||||
|
return {"status": "Error signing message"}
|
||||||
|
signature = response["result"]
|
||||||
|
return {"url": f"https://links.hns.au/auth?username={domain}&signature={signature}"}
|
Loading…
Reference in New Issue
Block a user