Merge branch 'new_dpp' into oidc4vp-new
This commit is contained in:
commit
ca273285fe
|
@ -899,7 +899,7 @@ class Snapshot(JoinedWithOneDeviceMixin, ActionWithOneDevice):
|
||||||
if 'dpp' not in app.blueprints.keys() or not self.device.hid:
|
if 'dpp' not in app.blueprints.keys() or not self.device.hid:
|
||||||
return
|
return
|
||||||
|
|
||||||
from ereuse_devicehub.modules.dpp.models import Dpp
|
from ereuse_devicehub.modules.dpp.models import Dpp, ALGORITHM
|
||||||
|
|
||||||
dpp = "{chid}:{phid}".format(chid=self.device.chid, phid=self.phid_dpp)
|
dpp = "{chid}:{phid}".format(chid=self.device.chid, phid=self.phid_dpp)
|
||||||
if Dpp.query.filter_by(key=dpp).all():
|
if Dpp.query.filter_by(key=dpp).all():
|
||||||
|
@ -916,15 +916,14 @@ class Snapshot(JoinedWithOneDeviceMixin, ActionWithOneDevice):
|
||||||
|
|
||||||
api = API(api_dlt, token_dlt, "ethereum")
|
api = API(api_dlt, token_dlt, "ethereum")
|
||||||
docSig = self.phid_dpp
|
docSig = self.phid_dpp
|
||||||
docID = "{}".format(self.uuid or '')
|
|
||||||
issuerID = "{dh}:{user}".format(dh=dh_instance, user=g.user.id)
|
|
||||||
|
|
||||||
result = api.issue_passport(dpp, docID, docSig, issuerID)
|
result = api.issue_passport(dpp, ALGORITHM, docSig, dh_instance)
|
||||||
|
|
||||||
if result['Status'] is not StatusCode.Success.value:
|
if result['Status'] is not StatusCode.Success.value:
|
||||||
return
|
return
|
||||||
|
|
||||||
timestamp = result['Data'].get('data', {}).get('timestamp', time.time())
|
timestamp = result['Data'].get('data', {}).get('timestamp', time.time())
|
||||||
|
docID = "{}".format(self.uuid or '')
|
||||||
d_issue = {
|
d_issue = {
|
||||||
"device_id": self.device.id,
|
"device_id": self.device.id,
|
||||||
"snapshot": self,
|
"snapshot": self,
|
||||||
|
|
|
@ -954,11 +954,24 @@ class Device(Thing):
|
||||||
return API(api_dlt, token_dlt, "ethereum")
|
return API(api_dlt, token_dlt, "ethereum")
|
||||||
|
|
||||||
def register_dlt(self):
|
def register_dlt(self):
|
||||||
|
if not app.config.get('ID_FEDERATED'):
|
||||||
|
return
|
||||||
|
|
||||||
api = self.connect_api()
|
api = self.connect_api()
|
||||||
if not api:
|
if not api:
|
||||||
return
|
return
|
||||||
|
|
||||||
result = api.register_device(self.chid)
|
snapshot = [x for x in self.actions if x.t == 'Snapshot']
|
||||||
|
if not snapshot:
|
||||||
|
return
|
||||||
|
snapshot = snapshot[0]
|
||||||
|
from ereuse_devicehub.modules.dpp.models import ALGORITHM
|
||||||
|
result = api.register_device(
|
||||||
|
self.chid,
|
||||||
|
ALGORITHM,
|
||||||
|
snapshot.phid_dpp,
|
||||||
|
app.config.get('ID_FEDERATED')
|
||||||
|
)
|
||||||
self.register_proof(result)
|
self.register_proof(result)
|
||||||
|
|
||||||
if app.config.get('ID_FEDERATED'):
|
if app.config.get('ID_FEDERATED'):
|
||||||
|
|
Reference in New Issue