Merge branch 'new_dpp' into oidc4vp-new

This commit is contained in:
Cayo Puigdefabregas 2024-01-29 17:49:35 +01:00
commit ca273285fe
2 changed files with 17 additions and 5 deletions

View File

@ -899,7 +899,7 @@ class Snapshot(JoinedWithOneDeviceMixin, ActionWithOneDevice):
if 'dpp' not in app.blueprints.keys() or not self.device.hid:
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)
if Dpp.query.filter_by(key=dpp).all():
@ -916,15 +916,14 @@ class Snapshot(JoinedWithOneDeviceMixin, ActionWithOneDevice):
api = API(api_dlt, token_dlt, "ethereum")
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:
return
timestamp = result['Data'].get('data', {}).get('timestamp', time.time())
docID = "{}".format(self.uuid or '')
d_issue = {
"device_id": self.device.id,
"snapshot": self,

View File

@ -954,11 +954,24 @@ class Device(Thing):
return API(api_dlt, token_dlt, "ethereum")
def register_dlt(self):
if not app.config.get('ID_FEDERATED'):
return
api = self.connect_api()
if not api:
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)
if app.config.get('ID_FEDERATED'):