mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-29 18:45:31 +01:00
OTS API documentation
This commit is contained in:
@@ -252,11 +252,40 @@ serve_ots_verify() {
|
||||
trace "Entering serve_ots_verify()..."
|
||||
|
||||
local request=${1}
|
||||
local hash=$(echo "${request}" | jq ".hash" | tr -d '"')
|
||||
local hash
|
||||
hash=$(echo "${request}" | jq -e ".hash")
|
||||
if [ "$?" -ne "0" ]; then
|
||||
# Hash tag null, so there's no hash provided
|
||||
trace "[serve_ots_verify] hash field missing!"
|
||||
echo "{\"method\":\"ots_verify\",\"result\":\"error\",\"message\":\"hash must be provided\"}"
|
||||
return 1
|
||||
else
|
||||
hash=$(echo "${hash}" | tr -d '"')
|
||||
fi
|
||||
trace "[serve_ots_verify] hash=${hash}"
|
||||
local base64otsfile=$(echo "${request}" | jq ".base64otsfile" | tr -d '"')
|
||||
local base64otsfile
|
||||
base64otsfile=$(echo "${request}" | jq -e ".base64otsfile")
|
||||
if [ "$?" -ne "0" ]; then
|
||||
# base64otsfile tag null, so there's no base64otsfile provided
|
||||
base64otsfile=
|
||||
else
|
||||
base64otsfile=$(echo "${base64otsfile}" | tr -d '"')
|
||||
fi
|
||||
trace "[serve_ots_verify] base64otsfile=${base64otsfile}"
|
||||
|
||||
# If file is provided, we will execute info on it
|
||||
# If file not provided, we will check for hash.ots in our folder and execute info on it
|
||||
if [ -z "${base64otsfile}" ]; then
|
||||
if [ -f otsfiles/${hash}.ots ]; then
|
||||
trace "[serve_ots_verify] Constructing base64otsfile from provided hash, file otsfiles/${hash}.ots"
|
||||
base64otsfile=$(cat otsfiles/${hash}.ots | base64 | tr -d '\n')
|
||||
else
|
||||
trace "[serve_ots_verify] File otsfiles/${hash}.ots does not exists!"
|
||||
echo "{\"method\":\"ots_verify\",\"hash\":\"${hash}\",\"result\":\"error\",\"message\":\"OTS File not found\"}"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
local result
|
||||
local message
|
||||
local returncode
|
||||
|
||||
@@ -399,8 +399,10 @@ main() {
|
||||
;;
|
||||
ots_verify)
|
||||
# POST http://192.168.111.152:8080/ots_verify
|
||||
# BODY {"hash":"1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7"}
|
||||
# BODY {"hash":"1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7","base64otsfile":"AE9wZW5UaW1lc3RhbXBzAABQcm9vZ...gABYiWDXPXGQEDxNch"}
|
||||
|
||||
# curl -v -d "{\"hash\":\"a6ea81a46fec3d02d40815b8667b388351edecedc1cc9f97aab55b566db7aac8\"}" localhost:8888/ots_verify
|
||||
# curl -v -d "{\"hash\":\"a6ea81a46fec3d02d40815b8667b388351edecedc1cc9f97aab55b566db7aac8\",\"base64otsfile\":\"$(cat a6ea81a46fec3d02d40815b8667b388351edecedc1cc9f97aab55b566db7aac8.ots | base64 | tr -d '\n')\"}" localhost:8888/ots_verify
|
||||
|
||||
response=$(serve_ots_verify "${line}")
|
||||
|
||||
Reference in New Issue
Block a user