mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-27 15:31:31 +00:00
digitalbitbox: make constant strings
This commit is contained in:
parent
9a3f2e8fcc
commit
0169ec880c
1 changed files with 11 additions and 8 deletions
|
@ -53,6 +53,9 @@ def derive_keys(x):
|
||||||
|
|
||||||
MIN_MAJOR_VERSION = 5
|
MIN_MAJOR_VERSION = 5
|
||||||
|
|
||||||
|
ENCRYPTION_PRIVKEY_KEY = 'encryptionprivkey'
|
||||||
|
CHANNEL_ID_KEY = 'comserverchannelid'
|
||||||
|
|
||||||
class DigitalBitbox_Client():
|
class DigitalBitbox_Client():
|
||||||
|
|
||||||
def __init__(self, plugin, hidDevice):
|
def __init__(self, plugin, hidDevice):
|
||||||
|
@ -280,7 +283,7 @@ class DigitalBitbox_Client():
|
||||||
except (FileNotFoundError, jsonDecodeError):
|
except (FileNotFoundError, jsonDecodeError):
|
||||||
return
|
return
|
||||||
|
|
||||||
if 'encryptionprivkey' not in dbb_config or 'comserverchannelid' not in dbb_config:
|
if ENCRYPTION_PRIVKEY_KEY not in dbb_config or CHANNEL_ID_KEY not in dbb_config:
|
||||||
return
|
return
|
||||||
|
|
||||||
choices = [
|
choices = [
|
||||||
|
@ -294,12 +297,12 @@ class DigitalBitbox_Client():
|
||||||
|
|
||||||
if reply == 0:
|
if reply == 0:
|
||||||
if self.plugin.is_mobile_paired():
|
if self.plugin.is_mobile_paired():
|
||||||
del self.plugin.digitalbitbox_config['encryptionprivkey']
|
del self.plugin.digitalbitbox_config[ENCRYPTION_PRIVKEY_KEY]
|
||||||
del self.plugin.digitalbitbox_config['comserverchannelid']
|
del self.plugin.digitalbitbox_config[CHANNEL_ID_KEY]
|
||||||
elif reply == 1:
|
elif reply == 1:
|
||||||
# import pairing from dbb app
|
# import pairing from dbb app
|
||||||
self.plugin.digitalbitbox_config['encryptionprivkey'] = dbb_config['encryptionprivkey']
|
self.plugin.digitalbitbox_config[ENCRYPTION_PRIVKEY_KEY] = dbb_config[ENCRYPTION_PRIVKEY_KEY]
|
||||||
self.plugin.digitalbitbox_config['comserverchannelid'] = dbb_config['comserverchannelid']
|
self.plugin.digitalbitbox_config[CHANNEL_ID_KEY] = dbb_config[CHANNEL_ID_KEY]
|
||||||
self.plugin.config.set_key('digitalbitbox', self.plugin.digitalbitbox_config)
|
self.plugin.config.set_key('digitalbitbox', self.plugin.digitalbitbox_config)
|
||||||
|
|
||||||
def dbb_generate_wallet(self):
|
def dbb_generate_wallet(self):
|
||||||
|
@ -729,15 +732,15 @@ class DigitalBitboxPlugin(HW_PluginBase):
|
||||||
|
|
||||||
|
|
||||||
def is_mobile_paired(self):
|
def is_mobile_paired(self):
|
||||||
return 'encryptionprivkey' in self.digitalbitbox_config
|
return ENCRYPTION_PRIVKEY_KEY in self.digitalbitbox_config
|
||||||
|
|
||||||
|
|
||||||
def comserver_post_notification(self, payload):
|
def comserver_post_notification(self, payload):
|
||||||
assert self.is_mobile_paired(), "unexpected mobile pairing error"
|
assert self.is_mobile_paired(), "unexpected mobile pairing error"
|
||||||
url = 'https://digitalbitbox.com/smartverification/index.php'
|
url = 'https://digitalbitbox.com/smartverification/index.php'
|
||||||
key_s = base64.b64decode(self.digitalbitbox_config['encryptionprivkey'])
|
key_s = base64.b64decode(self.digitalbitbox_config[ENCRYPTION_PRIVKEY_KEY])
|
||||||
args = 'c=data&s=0&dt=0&uuid=%s&pl=%s' % (
|
args = 'c=data&s=0&dt=0&uuid=%s&pl=%s' % (
|
||||||
self.digitalbitbox_config['comserverchannelid'],
|
self.digitalbitbox_config[CHANNEL_ID_KEY],
|
||||||
EncodeAES_base64(key_s, json.dumps(payload).encode('ascii')).decode('ascii'),
|
EncodeAES_base64(key_s, json.dumps(payload).encode('ascii')).decode('ascii'),
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Reference in a new issue