feat: Add json signature checker
This commit is contained in:
parent
23ac3ff8a4
commit
d8e76be40e
@ -37,6 +37,24 @@ functions = {
|
|||||||
"type": "text"
|
"type": "text"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"advancedValidate":{
|
||||||
|
"name": "Validate signature from json",
|
||||||
|
"type": "default",
|
||||||
|
"description": "Validate that a message was signed by a specific domain using json format",
|
||||||
|
"params": {
|
||||||
|
"json": {
|
||||||
|
"name": "JSON signature object",
|
||||||
|
"type": "longText",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"returns": {
|
||||||
|
"status":
|
||||||
|
{
|
||||||
|
"name": "Validity of the signature",
|
||||||
|
"type": "text"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,4 +65,22 @@ def validate(params, authentication):
|
|||||||
|
|
||||||
if account.verifyMessageWithName(domain, signature,message):
|
if account.verifyMessageWithName(domain, signature,message):
|
||||||
return {"status": "Valid"}
|
return {"status": "Valid"}
|
||||||
return {"status": "Invalid signature"}
|
return {"status": "Invalid signature"}
|
||||||
|
|
||||||
|
def advancedValidate(params, authentication):
|
||||||
|
data = params["json"]
|
||||||
|
|
||||||
|
try:
|
||||||
|
data = json.loads(data)
|
||||||
|
except:
|
||||||
|
return {"status": "Invalid JSON"}
|
||||||
|
|
||||||
|
if "domain" in data and "message" in data and "signature" in data:
|
||||||
|
domain = data["domain"]
|
||||||
|
message = data["message"]
|
||||||
|
signature = data["signature"]
|
||||||
|
|
||||||
|
if account.verifyMessageWithName(domain, signature,message):
|
||||||
|
return {"status": "Valid"}
|
||||||
|
return {"status": "Invalid signature"}
|
||||||
|
return {"status": "Invalid JSON"}
|
Loading…
Reference in New Issue
Block a user