WOT API can now serialize identities
This commit is contained in:
parent
738fa0c361
commit
8e730cef98
@ -99,6 +99,8 @@ def on_init(api, data=None):
|
||||
return
|
||||
|
||||
logging.info('Loaded active identity: ' + iden.name)
|
||||
identities.add(iden)
|
||||
|
||||
|
||||
def on_wot_cmd(api, data=None):
|
||||
def _create_new_iden():
|
||||
|
@ -1,3 +1,5 @@
|
||||
import base64
|
||||
|
||||
class IdentitySet(set):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
@ -32,7 +34,7 @@ identities = IdentitySet()
|
||||
def serialize_identity_set():
|
||||
serialized_idens = []
|
||||
for identity in list(identities):
|
||||
serialized_idens.append(identity.serialize())
|
||||
serialized_idens.append(base64.b85encode(identity.serialize()).decode('utf-8'))
|
||||
return serialized_idens
|
||||
|
||||
serialize_identity_set.json_compatible = True
|
@ -1,15 +1,18 @@
|
||||
import base64
|
||||
|
||||
import keyring
|
||||
import nacl.signing
|
||||
|
||||
import wot.identity
|
||||
|
||||
|
||||
def get_identity_by_name(name: str) -> 'Identity':
|
||||
iden_key = keyring.get_credential('onionr.wot', name)
|
||||
iden_key = base64.b85decode(iden_key)
|
||||
|
||||
if not iden_key:
|
||||
raise KeyError('Identity not found')
|
||||
iden_key = base64.b85decode(iden_key.password)
|
||||
iden_key = nacl.signing.SigningKey(iden_key)
|
||||
|
||||
return wot.identity.Identity(iden_key, name)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user