diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2025-07-21 00:27:59 +0300 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2025-07-21 00:27:59 +0300 |
commit | 9144dbd13f02215a424f7cdf8ec78c59463b5a19 (patch) | |
tree | 7d1d6dd852ec4067a2b9a1609d176a1edbc5d774 | |
parent | 5b31cb2bbc5726d9c6268475cba7e981423f1e4b (diff) | |
download | arching-kaos-tools-9144dbd13f02215a424f7cdf8ec78c59463b5a19.tar.gz arching-kaos-tools-9144dbd13f02215a424f7cdf8ec78c59463b5a19.tar.bz2 arching-kaos-tools-9144dbd13f02215a424f7cdf8ec78c59463b5a19.zip |
[bin] [api] Supports and resolves base64 encoded fingerprints
-rwxr-xr-x | api/index.js | 2 | ||||
-rwxr-xr-x | bin/ak-ns | 4 | ||||
-rwxr-xr-x | lib/_ak_ns | 31 |
3 files changed, 36 insertions, 1 deletions
diff --git a/api/index.js b/api/index.js index e9c2eb0..f22d448 100755 --- a/api/index.js +++ b/api/index.js @@ -2,6 +2,7 @@ const http = require("node:http"); const welcomeMessage = require("./routes/default/index.js"); const getAKNSKey = require("./routes/getAKNSKey/index.js"); +const getAKNSKeyFromBase = require("./routes/getAKNSKeyFromBase/index.js"); const getNodeInfo = require('./routes/getNodeInfo/index.js'); const getPeers = require('./routes/getPeers/index.js'); const getIPFSHash = require('./routes/getIPFSHash/index.js'); @@ -70,6 +71,7 @@ function getRoutes(req, res) case 'remote_node_info': getRemoteNodeInfo(req, res); break; case 'remote_peers': getRemotePeers(req, res); break; case 'ns_get': getAKNSKey(req, res); break; + case 'ns_get_base': getAKNSKeyFromBase(req, res); break; default: notImplemented(req, res); } } @@ -32,6 +32,8 @@ ## -pn, --publish2name <name> <value> Publishes value to name ## -pz, --publish-zchain Publishes zchain ## -pc, --publish-config Publishes config +## -ek, --encode-key <key> Encodes a key to Base64 +## -dk, --decode-key <base64 key> Decodes a key from Base64 ## fullprogrampath="$(realpath $0)" PROGRAM=$(basename $0) @@ -51,6 +53,8 @@ then -ll | --list-long) shift; _ak_ns_list_long; exit;; -rn | --resolve-name) shift; _ak_ns_resolve_from_name $1; exit;; -rk | --resolve-key) shift; _ak_ns_resolve_from_key $1; exit;; + -ek | --encode-key) shift; _ak_ns_encode_key $1; exit;; + -dk | --decode-key) shift; _ak_ns_decode_key $1; exit;; -p | --publish) shift; _ak_ns_publish $1 $2; exit;; -pn | --publish2name) shift; _ak_ns_publish2name $1 $2; exit;; -pz | --publish-zchain) _ak_ns_publish_zchain; exit;; @@ -56,7 +56,12 @@ function _ak_ns_list(){ } function _ak_ns_list_long(){ - _ak_gpg_list_secret_keys_long | grep '@keynames.kaos.kaos' + _ak_gpg_list_secret_keys_long \ + | grep '@keynames.kaos.kaos' \ + | while read key name + do + printf '%s %s %s\n' "${key}" "$(_ak_ns_encode_key ${key})" "${name}" + done } function _ak_ns_resolve_from_key(){ @@ -76,6 +81,30 @@ function _ak_ns_resolve_from_key(){ _ak_gpg_verify_clear_signature ${AK_NS_DIR}/${key} } +function _ak_ns_encode_key(){ + # $1; exit;; + if [ -z $1 ] || [ ! -n "$1" ] + then + _ak_log_error "No key was given" + exit 1 + fi + key="$1" + _ak_log_info "${key} was given" + printf '%s' "$(echo -n ${key}|xxd -r -p|base64)" +} + +function _ak_ns_decode_key(){ + # $1; exit;; + if [ -z $1 ] || [ ! -n "$1" ] + then + _ak_log_error "No key was given" + exit 1 + fi + key="$1" + _ak_log_info "${key} was given" + printf '%s' "$(echo -n ${key}|base64 -d|xxd -p|tr '[:lower:]' '[:upper:]')" +} + function _ak_ns_resolve_from_name(){ # $1; exit;; if [ -z $1 ] || [ ! -n "$1" ] |