diff --git a/package.json b/package.json index dafffb6ea88332ffc6740a24f9a371ea9690d117..eb37601921af595d15a0c773c4070a767327e4e3 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,9 @@ , "colors" : "0.5.0" , "sax" : "0.2.3" , "mimelib-noiconv" : "0.1.3" - , "jwcrypto": "https://github.com/lloyd/jwcrypto/tarball/8edb08b" + , "jwcrypto": "https://github.com/lloyd/jwcrypto/tarball/ace101" + } + , "scripts": { + "postinstall": "./scripts/generate_ephemeral_keys.sh" } } diff --git a/prepare_deps.sh b/prepare_deps.sh deleted file mode 100755 index e8b6c4c81cd73a32e3c34dcca2ca1a03d7e10955..0000000000000000000000000000000000000000 --- a/prepare_deps.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -echo '' -echo '*** Generating keys and placing them into correct location ***' -cd node_modules/jwcrypto -node generate-keypair.js - -mv key.publickey ../../var/root.publickey -mv key.secretkey ../../var/root.secretkey -cd ../.. diff --git a/scripts/generate_ephemeral_keys.sh b/scripts/generate_ephemeral_keys.sh new file mode 100755 index 0000000000000000000000000000000000000000..a5da918124e102b516502d31871854210b5e60cd --- /dev/null +++ b/scripts/generate_ephemeral_keys.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" +VAR=SCRIPT_DIR/../var +export PATH=$PATH:$SCRIPT_DIR/../node_modules/.bin + +# if keys already exist, do nothing +if [ -f $VAR/root.publickey ] ; then + exit 0 +fi + +GENERATE_KEYPAIR=`which generate-keypair 2> /dev/null` + +if [ ! -x "$GENERATE_KEYPAIR" ] ; then + echo "can't find generate-keypair from the jwcrypto package. try: npm install" + exit 1 +fi + +echo '*** Generating ephemeral keys used for testing ***' +$GENERATE_KEYPAIR +mkdir -p $VAR +mv key.publickey $VAR/root.publickey +mv key.secretkey $VAR/root.secretkey