From 00d039affc61352dad4da68cd5aa8e7cdedd908f Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 4 Oct 2023 22:22:22 +0200 Subject: [PATCH] Remove pure-shell examples in favor of ots-cli Signed-off-by: Knut Ahlers --- cli_create.sh | 38 -------------------------------------- cli_get.sh | 28 ---------------------------- 2 files changed, 66 deletions(-) delete mode 100644 cli_create.sh delete mode 100644 cli_get.sh diff --git a/cli_create.sh b/cli_create.sh deleted file mode 100644 index 736e471..0000000 --- a/cli_create.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -set -euo pipefail - -: ${INSTANCE:=https://ots.fyi} # Where to reach the API of the instance (omit trailing slash) - -deps=(curl jq) -for cmd in "${deps[@]}"; do - which ${cmd} >/dev/null || { - echo "'${cmd}' util is required for this script" - exit 1 - } -done - -# Get secret from CLI argument -SECRET=${1:-} -[[ -n $SECRET ]] || { - echo "Usage: $0 'secret to share'" - exit 1 -} - -# Generate a random 20 character password -pass=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 20 || true) - -# Encrypt the secret -ciphertext=$(echo "${SECRET}" | openssl aes-256-cbc -base64 -A -pass "pass:${pass}" -iter 300000 -md sha512 2>/dev/null) - -# Create a secret and extract the secret ID -id=$( - curl -sSf \ - -X POST \ - -H 'content-type: application/json' \ - -d "$(jq --arg secret "${ciphertext}" -cn '{"secret": $secret}')" \ - "${INSTANCE}/api/create" | - jq -r '.secret_id' -) - -# Display URL to user -echo -e "Secret is now available at:\n${INSTANCE}/#${id}%7C${pass}" diff --git a/cli_get.sh b/cli_get.sh deleted file mode 100644 index 96208fc..0000000 --- a/cli_get.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -set -euo pipefail - -deps=(curl jq) -for cmd in "${deps[@]}"; do - which ${cmd} >/dev/null || { - echo "'${cmd}' util is required for this script" - exit 1 - } -done - -# Get URL from CLI argument -url="${1:-}" -[[ -n $url ]] || { - echo "Usage: $0 'URL to get the secret'" - exit 1 -} -# normalize url and extract parts -url="${url/|/%7C}" -host="${url%%/\#*}" -idpass="${url##*\#}" -pass="${idpass##*\%7C}" -id="${idpass%%\%7C*}" -geturl="${host}/api/get/${id}" - -# fetch secret and decrypt to STDOUT -curl -sSf "${geturl}" | jq -r ".secret" | - openssl aes-256-cbc -base64 -A -pass "pass:${pass}" -iter 300000 -md sha512 -d