fixes & cookies

This commit is contained in:
fred 2023-03-27 13:27:57 +02:00
parent 5563061104
commit 79af5d395d
6 changed files with 40 additions and 89 deletions

View File

@ -120,15 +120,15 @@ fi
## QRCODE can be ASTRONAUTENS or G1PUB format
################################################################################
## QRCODE IS IPNS FORMAT : CHANGE .current AND MAKE G1BILLETS
ASTROPATH=$(grep $QRCODE ~/.zen/game/players/*/.playerns | cut -d ':' -f 1 | rev | cut -d '/' -f 2- | rev 2>/dev/null)
ASTROPATH=$(grep -r $QRCODE ~/.zen/game/players/*/ipfs/moa | tail -n 1 | cut -d ':' -f 1 | rev | cut -d '/' -f 2- | rev 2>/dev/null)
if [[ $ASTROPATH != "" && $APPNAME == "" ]]; then
PLAYER=$(echo $ASTROPATH | rev | cut -d '/' -f 1 | rev)
PLAYER=$(echo $ASTROPATH | rev | cut -d '/' -f 3 | rev)
rm ~/.zen/game/players/.current
ln -s $ASTROPATH ~/.zen/game/players/.current
echo "LINKING $ASTROPATH to .current"
#### SELECT PARRAIN "G1PalPé"
ln -s ~/.zen/game/players/$PLAYER ~/.zen/game/players/.current
echo "LINKING $PLAYER to .current"
#### SELECT PARRAIN "G1PalPay"
echo "#>>>>>>>>>>>> # REDIRECT TO CREATE G1BILLETS"
sed "s~_TWLINK_~${myG1BILLET}?montant=0\&style=$PLAYER~g" ~/.zen/Astroport.ONE/templates/index.302 > ~/.zen/tmp/${MOATS}/index.redirect
@ -221,16 +221,19 @@ else
&& ~/.zen/Astroport.ONE/tools/timeout.sh -t 20 curl -s ${myDATA}/user/profile/${QRCODE} > ~/.zen/tmp/coucou/${QRCODE}.gchange.json &
GFOUND=$(cat ~/.zen/tmp/coucou/${QRCODE}.gchange.json | jq -r '.found')
echo "GFOUND=$GFOUND"
[[ $GFOUND == "false" ]] \
&& echo "G1BILLET. NO GCHANGE YET. REDIRECT" \
&& echo "NO GCHANGE YET. REDIRECT" \
&& sed "s~_TWLINK_~${myGCHANGE}~g" ~/.zen/Astroport.ONE/templates/index.302 > ~/.zen/tmp/${MOATS}/index.redirect \
&& echo "url='"${myGCHANGE}"'" >> ~/.zen/tmp/${MOATS}/index.redirect \
&& ( cat ~/.zen/tmp/${MOATS}/index.redirect | nc -l -p ${PORT} -q 1 > /dev/null 2>&1) &
## SCAN CESIUM +
[[ ! -s ~/.zen/tmp/coucou/${QRCODE}.gplus.json ]] \
&& ~/.zen/Astroport.ONE/tools/timeout.sh -t 10 curl -s ${myCESIUM}/user/profile/${QRCODE} > ~/.zen/tmp/coucou/${QRCODE}.gplus.json 2>/dev/null &
GCFOUND=$(cat ~/.zen/tmp/coucou/${QRCODE}.gplus.json | jq -r '.found')
echo "GCFOUND=$GCFOUND"
[[ $GCFOUND == "false" ]] \
&& echo "AUCUN GCPLUS : PAS DE CESIUM POUR CLEF GCHANGE" \
&& sed "s~_TWLINK_~https://demo.cesium.app/#/app/wot/$QRCODE/~g" ~/.zen/Astroport.ONE/templates/index.302 > ~/.zen/tmp/${MOATS}/index.redirect \
@ -239,6 +242,7 @@ else
## CHECK IF GCHANGE IS LINKED TO "A DECLARED CESIUM"
CPUB=$(cat ~/.zen/tmp/coucou/${QRCODE}.gchange.json | jq -r '._source.pubkey' 2>/dev/null)
echo "CPUB=$CPUB"
## SCAN GPUB CESIUM +
##### DO WE HAVE A MEMBER LINKED ??
@ -297,45 +301,6 @@ else
fi
###################################################################################################
# THAT=$2 AND=$3 THIS=$4 APPNAME=$5 WHAT=$6 OBJ=$7 VAL=$8
### amzqr "$myASTROPORT/?qrcode=$G1PUB&junesec=$PASsec&askpass=$HPass&tw=$ASTRONAUTENS" \
### amzqr "$myASTROPORT/?qrcode=$WISHKEY&junesec=$PASsec&asksalt=$HPass&flux=$VOEUNS&tw=$ASTRONAUTENS" \
###
if [[ $AND == "junesec" ]]; then
echo "♥BOX♥BOX♥BOX♥BOX♥BOX"
echo "MAGIC WORLD ASTRONAUT & WISHES"
if [[ $APPNAME == "askpass" ]]; then
echo ">> ASTRONAUT QRCODE $APPNAME"
ENDCODED="$THIS"
HPASS="$WHAT"
TW="/ipns/$VAL"
fi
if [[ $APPNAME == "asksalt" ]]; then
echo ">> WISH QRCODE $APPNAME"
ENDCODED="$THIS"
HSALT="$WHAT"
FLUX="/ipns/$VAL"
fi
fi
### amzqr "$myASTROPORT/?qrcode=$G1FRIEND&star=1" \
###
if [[ $AND == "star" ]]; then
STAR=$THIS
echo "WebClient ask to send $STAR star to $QRCODE"
## RETURN PAGE with "salt / pepper" API to activate
fi
## TODO MAGIC QRCODE RX / TX
###################################################################################################

View File

@ -25,7 +25,7 @@ Content-Type: text/html; charset=UTF-8
"
[[ ! $APPNAME || $SALT == "pepper" ]] && echo "NO APPNAME - BAD APP - CONTINUE" && exit 1
[[ ! $APPNAME || $SALT == "pepper" ]] && echo "NO APPNAME - BAD APP - CONTINUE" && (echo "$HTTPCORS ERROR - BAD CREDENTIALS" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && exit 1
############################################################################
# WRITING API # SALT # PEPPER # MAKING THE KEY EXIST #########
################### KEY GEN ###################################
@ -438,22 +438,15 @@ echo "" > ~/.zen/tmp/.ipfsgw.bad.twt # TODO move in 20h12.sh
## REMOVE PLAYER IPNS KEY FROM STATION
PLAYER=${WHAT}
if [[ -d ~/.zen/game/players/${PLAYER}/ipfs ]]; then
ipfs key import ${PLAYER} -f pem-pkcs8-cleartext ~/.zen/tmp/coucou/${MOATS}.${G1PUB}.ipns.key
REP="LOGIN OK"
else
REP="ERROR UNKNOW ${PLAYER}"
fi
echo ${REP}
ipfs key import ${PLAYER} -f pem-pkcs8-cleartext ~/.zen/tmp/coucou/${MOATS}.${G1PUB}.ipns.key
ASTRONAUTENS=$(ipfs key list -l | grep $PLAYER | cut -d ' ' -f1)
REPLACE=${myASTROPORT}/ipns/${ASTRONAUTENS}
WSTATION=$(cat ~/.zen/tmp/WSTATION 2>/dev/null)
[[ $WSTATION != "" ]] \
&& REPLACE=${myIPFS}${WSTATION} \
|| REPLACE=${myIPFS}/ipns/${ASTRONAUTENS}
## SET COOKIE
sed "s~_TWLINK_~${REPLACE}~g" ~/.zen/Astroport.ONE/templates/index.302 > ~/.zen/tmp/coucou/${MOATS}.index.redirect
sed -i "s~_G1PUB_~${G1PUB}~g" ~/.zen/tmp/coucou/${MOATS}.index.redirect
@ -475,20 +468,10 @@ echo "" > ~/.zen/tmp/.ipfsgw.bad.twt # TODO move in 20h12.sh
## REMOVE PLAYER IPNS KEY FROM STATION
PLAYER=${WHAT}
ipfs key rm ${G1PUB}
ipfs key rm ${PLAYER}
REP="$PLAYER LOGOUT OK"
if [[ -d ~/.zen/game/players/${PLAYER}/ipfs ]]; then
ipfs key rm ${G1PUB} > /dev/null 2>&1
ipfs key rm ${PLAYER} > /dev/null 2>&1
REP="LOGOUT OK"
else
REP="ERROR UNKNOW ${PLAYER}"
fi
echo ${REP}
echo "$HTTPCORS ${REP}"| nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &
end=`date +%s`
echo $APPNAME "(☉_☉ ) Execution time was "`expr $end - $start` seconds.

View File

@ -102,7 +102,7 @@ mkdir -p ~/.zen/tmp/$MOATS
convert -gravity southeast -pointsize 25 -fill black -draw "text 30,30 \"$PEPPER\"" ~/.zen/tmp/${MOATS}/layer1.png ~/.zen/tmp/${MOATS}/result.png
## MAKE amzqr WITH astro:// LINK
amzqr "$(cat ~/.zen/tmp/${MOATS}/gpg.${PSEUDO}.asc | tr -d '\n')" \
amzqr "$(cat ~/.zen/tmp/${MOATS}/gpg.${PSEUDO}.asc | tr '\n' '~')" \
-d "$HOME/.zen/game/world/$PEPPER/$WISHKEY" \
-l H \
-p ~/.zen/tmp/${MOATS}/result.png -c

View File

@ -210,7 +210,7 @@ DISCO="/?salt=${USALT}&pepper=${UPEPPER}"
cp ${MY_PATH}/../images/astrologo_nb.png ~/.zen/tmp/${MOATS}/fond.png
## MAKE amzqr WITH astro:// LINK
amzqr "$(cat ~/.zen/tmp/${MOATS}/gpg.${PSEUDO}.asc | tr -d '\n')" \
amzqr "$(cat ~/.zen/tmp/${MOATS}/gpg.${PSEUDO}.asc | tr '\n' '~')" \
-d ~/.zen/tmp/${MOATS} \
-l H \
-p ~/.zen/tmp/${MOATS}/fond.png

View File

@ -159,17 +159,20 @@ a {
scanner.addListener('scan', function (content) {
alert(content);
if (content.startsWith('-----')) {
// Try to decrypt PGP
// Try to decode PGP
content = content.replace(/~/g, '\n');
var pass = prompt("Saisir votre PASS:");
const decrypted = openpgp.decrypt({
const decoded = openpgp.decrypt({
message: openpgp.message.readArmored(content),
passwords: [pass]
});
//print the decrypted url
console.log(decrypted.data);
passwords: pass
});
//print the decoded url
console.log(decoded);
var amount = prompt("Saisir MONTANT Ğ1:");
var myU = 'http://astroport.localhost:1234' + decrypted.data +'&pay=' + amount + '&g1pub=' + document.getElementById("resu").innerHTML.value ;
document.getElementById("resu").innerHTML = decrypted.data;
var myU = 'http://astroport.localhost:1234' + decoded +'&pay=' + amount + '&g1pub=' + document.getElementById("resu").innerHTML.value ;
document.getElementById("resu").innerHTML = decoded;
} else {
document.getElementById("resu").innerHTML = content;
var myU = 'http://astroport.localhost:1234/?qrcode=' + content;

View File

@ -115,7 +115,7 @@
<body>
<a href="javascript:FriendToMe()"><img style="width:40% height:40% position: absolute; top: 0; right: 0; border: 0;" src="http://127.0.0.1:8080/ipfs/QmYdWBx32dP14XcbXF7hhtDq7Uu6jFmDaRnuL5t7ARPYkW/l0g0.png" alt="BAck in Le Claude"></a>
<a href="javascript:FriendWithMe()"><img style="width:40% height:40% position: absolute; top: 0; right: 0; border: 0;" src="http://127.0.0.1:8080/ipfs/QmYdWBx32dP14XcbXF7hhtDq7Uu6jFmDaRnuL5t7ARPYkW/l0g0.png" alt="BAck in Le Claude"></a>
<div id="countdown"></div>
<div class="subtitle">A Friendly Planet of Friends</div>
@ -131,10 +131,10 @@
</div>
<script>
function FriendToMe() {
let salt = prompt("Secret 1");
let pepper = prompt("Secret 2");
let resultUt = 'http://astroport.localhost:1234/?salt=' + salt + '&pepper=' + pepper + '&friend=_G1PUB_';
function FriendWithMe() {
let cookies = document.cookie;
console.log(cookies);
let resultUt = 'http://astroport.localhost:1234' + cookies + '&friend=_G1PUB_';
console.log(resultUt)
homeAstroportStation( resultUt,'aframe', 4000)
}