I try to write the script that will publish my extension to all stores, done with Chrome but stuck with Firefox. I was guided by this documentation. I am able to upload to Mozilla store through the web page. I know that I can use existing cli but I do not want to introduce useless dependencies. jwt.io shows greenlight.
My code:
AMO_JWT_ISSUER=user:132XXXXX:XXX
AMO_SECRET=503084ad4069208a1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
JWT_HEADER_BASE64=`printf %s '{"alg": "HS256", "typ": "JWT"}' | base64`
random() {
dd if=/dev/urandom bs=20 count=1 2>/dev/null | openssl sha1
}
UNIXTIME=`date +%s`
PAYLOAD_JSON=$(python3 - <<EOF
import json
print(
json.dumps({
'iss': "${AMO_JWT_ISSUER}",
'jti': "$(random)",
'iat': $UNIXTIME,
'exp': $(($UNIXTIME+99))
})
)
EOF
)
JWT_PAYLOAD_BASE64=`printf %s $PAYLOAD_JSON | base64`
FOR_SIGN="$JWT_HEADER_BASE64.$JWT_PAYLOAD_BASE64"
JWT_SIGNATURE_BASE64=`printf %s $FOR_SIGN | openssl dgst -binary -sha256 -hmac $AMO_SECRET | base64`
JWT=$JWT_HEADER_BASE64.$JWT_PAYLOAD_BASE64.$JWT_SIGNATURE_BASE64
curl "https://addons.mozilla.org/api/v3/addons/" \
--form "upload=@$FIREFOX_FILEPATH_PROD" \
--form "version=$VERSION" \
-H "Authorization: JWT $JWT" \
-v