let contactmanager support unpaddedbase32 and bip39 keys

This commit is contained in:
Kevin Froman 2019-09-09 17:29:29 -05:00
parent 61eb4a53e6
commit d74bfbd5ee
4 changed files with 12 additions and 3 deletions

View File

@ -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` * Clone the git repo: `$ git clone https://gitlab.com/beardog/onionr`
* cd into install direction: `$ cd 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` * 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) (--require-hashes is intended to prevent exploitation via compromise of PyPi/CA certificates)

View File

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

View File

@ -22,9 +22,17 @@ import unpaddedbase32
from onionrusers import onionrusers from onionrusers import onionrusers
from onionrutils import bytesconverter, epoch from onionrutils import bytesconverter, epoch
from utils import identifyhome from utils import identifyhome
import mnemonic
class ContactManager(onionrusers.OnionrUser): class ContactManager(onionrusers.OnionrUser):
def __init__(self, publicKey, saveUser=False, recordExpireSeconds=5): 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) super(ContactManager, self).__init__(publicKey, saveUser=saveUser)
home = identifyhome.identify_home() home = identifyhome.identify_home()
self.dataDir = home + '/contacts/' self.dataDir = home + '/contacts/'

View File

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