Browse Source

let contactmanager support unpaddedbase32 and bip39 keys

upload-fix
Kevin Froman 2 years ago
parent
commit
d74bfbd5ee
  1. 1
      README.md
  2. 2
      onionr/onionrservices/httpheaders.py
  3. 10
      onionr/onionrusers/contactmanager.py
  4. 2
      onionr/static-data/www/friends/index.html

1
README.md

@ -93,6 +93,7 @@ The following applies to Ubuntu Bionic. Other distros may have different package
* Clone the git repo: `$ git clone https://gitlab.com/beardog/onionr`
* cd into install direction: `$ cd onionr/`
* Install the Python dependencies ([virtualenv strongly recommended](https://virtualenv.pypa.io/en/stable/userguide/)): `$ pip3 install --require-hashes -r requirements.txt`
* (Optional): Install desktop notification dependencies: `$ pip3 install --require-hashes -r requirements-notifications.txt`
(--require-hashes is intended to prevent exploitation via compromise of PyPi/CA certificates)

2
onionr/onionrservices/httpheaders.py

@ -31,5 +31,5 @@ def set_default_onionr_http_headers(flask_response):
flask_response.headers['Connection'] = "close"
flask_response.headers['Clear-Site-Data'] = '"cache", "cookies", "storage", "executionContexts"'
flask_response.headers['Feature-Policy'] = FEATURE_POLICY
flask_response.headers['Referrer-Policy'] = 'no-referrer'
flask_response.headers['Referrer-Policy'] = 'same-origin'
return flask_response

10
onionr/onionrusers/contactmanager.py

@ -22,9 +22,17 @@ import unpaddedbase32
from onionrusers import onionrusers
from onionrutils import bytesconverter, epoch
from utils import identifyhome
import mnemonic
class ContactManager(onionrusers.OnionrUser):
def __init__(self, publicKey, saveUser=False, recordExpireSeconds=5):
publicKey = unpaddedbase32.repad(bytesconverter.str_to_bytes(publicKey)).decode()
try:
if " " in publicKey:
publicKey = mnemonic.Mnemonic('english').to_entropy(publicKey)
publicKey = unpaddedbase32.b32encode(bytesconverter.str_to_bytes(publicKey))
except ValueError:
pass
publicKey = bytesconverter.bytes_to_str(unpaddedbase32.repad(bytesconverter.str_to_bytes(publicKey)))
super(ContactManager, self).__init__(publicKey, saveUser=saveUser)
home = identifyhome.identify_home()
self.dataDir = home + '/contacts/'

2
onionr/static-data/www/friends/index.html

@ -102,7 +102,7 @@
<label class="label">Friend ID</label>
<p class="control is-expanded">
<input id="" class="input" type="text" name='addKey' placeholder='Public Key/ID'
minlength="52" maxlength="52" required>
minlength="52" maxlength="500" required>
</p>
</div>
<div class="field">

Loading…
Cancel
Save