Initialized walletkit/ssikit python api
This commit is contained in:
parent
1f959f9fe2
commit
604f450ca6
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 4.2.5 on 2023-10-02 15:55
|
# Generated by Django 4.2.5 on 2023-10-03 15:28
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
|
@ -14,42 +14,29 @@ class AppUser(models.Model):
|
||||||
class Event(models.Model):
|
class Event(models.Model):
|
||||||
# Para los "audit logs" que se requieren en las pantallas.
|
# Para los "audit logs" que se requieren en las pantallas.
|
||||||
timestamp = models.DateTimeField()
|
timestamp = models.DateTimeField()
|
||||||
kind = "PLACEHOLDER"
|
# Los eventos no tienen relación con otros objetos a nivel de BBDD.
|
||||||
|
event_data = models.CharField(max_length=250)
|
||||||
|
|
||||||
|
|
||||||
|
class DID(models.Model):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ExternallyStoredModel(models.Model):
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Any models which inherit from this class are stored in wallet-kit, not in the Django ORM
|
|
||||||
class Meta:
|
|
||||||
abstract = True
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def from_json(json_serialization):
|
|
||||||
# Construct an instance of this class by de-serialization from data returned by wallet-kit.
|
|
||||||
# Must be implemented by any deriving class.
|
|
||||||
raise NotImplementedError()
|
|
||||||
|
|
||||||
|
|
||||||
class DID(ExternallyStoredModel):
|
|
||||||
did_string = models.CharField(max_length=250)
|
did_string = models.CharField(max_length=250)
|
||||||
# kind = "KEY|JWK|WEB|EBSI|CHEQD|IOTA"
|
label = models.CharField(max_length=50)
|
||||||
|
owner = models.ForeignKey(AppUser, on_delete=models.CASCADE)
|
||||||
|
# kind = "KEY|WEB"
|
||||||
|
|
||||||
|
|
||||||
class VerifiableCredential(ExternallyStoredModel):
|
class VerifiableCredential(models.Model):
|
||||||
id_string = models.CharField(max_length=250)
|
id_string = models.CharField(max_length=250)
|
||||||
data = models.TextField()
|
|
||||||
verified = models.BooleanField()
|
verified = models.BooleanField()
|
||||||
created_on = models.DateTimeField()
|
created_on = models.DateTimeField()
|
||||||
did_issuer = models.CharField(max_length=250) # Probably not a FK but the DID directly
|
did_issuer = models.CharField(max_length=250)
|
||||||
did_subject = models.CharField(max_length=250) # Probably not a FK but the DID directly
|
did_subject = models.CharField(max_length=250)
|
||||||
|
owner = models.ForeignKey(AppUser, on_delete=models.CASCADE)
|
||||||
|
data = models.TextField()
|
||||||
|
|
||||||
|
|
||||||
|
class VCTemplate(models.Model):
|
||||||
|
wkit_template_id = models.CharField(max_length=250)
|
||||||
|
data = models.TextField()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"issuerApiUrl": "http://localhost:8080/issuer-api/default",
|
||||||
|
"issuerClientName": "PANGEA Issuer Portal",
|
||||||
|
"issuerDid": null,
|
||||||
|
"issuerUiUrl": "http://localhost:5000",
|
||||||
|
"wallets": {
|
||||||
|
"walt.id": {
|
||||||
|
"description": "walt.id web wallet",
|
||||||
|
"id": "walt.id",
|
||||||
|
"presentPath": "api/siop/initiatePresentation",
|
||||||
|
"receivePath": "api/siop/initiateIssuance",
|
||||||
|
"url": "http://localhost:3000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
|
||||||
|
WALLETKITD = 'http://localhost:8080/'
|
||||||
|
ISSUER = f'{WALLETKITD}issuer-api/default/'
|
||||||
|
VERIFIER = f'{WALLETKITD}verifier-api/default/'
|
||||||
|
|
||||||
|
default_ctype_header = {
|
||||||
|
'Content-Type': 'application/json', # specify the type of data you're sending
|
||||||
|
'Accept': 'application/json', # specify the type of data you can accept
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def include_str(path):
|
||||||
|
with open(path, "r") as f:
|
||||||
|
return f.read().strip()
|
||||||
|
|
||||||
|
|
||||||
|
# Create DID for tenant
|
||||||
|
# Valid methods: 'key'|'web'
|
||||||
|
def user_create_did(did_method):
|
||||||
|
url = f'{ISSUER}config/did/create'
|
||||||
|
data = {
|
||||||
|
'method': did_method
|
||||||
|
}
|
||||||
|
response = requests.post(url, json=data, headers=default_ctype_header)
|
||||||
|
response.raise_for_status()
|
||||||
|
return response.text
|
||||||
|
|
||||||
|
|
||||||
|
def admin_create_template(template_name, template_body):
|
||||||
|
url = f'{ISSUER}config/templates/{template_name}'
|
||||||
|
body = template_body
|
||||||
|
response = requests.post(url, data=body, headers=default_ctype_header)
|
||||||
|
response.raise_for_status()
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def user_issue_vc(vc_name, vc_params):
|
||||||
|
url = f'{ISSUER}credentials/issuance/request'
|
||||||
|
# ...
|
||||||
|
# TODO examine cross-device issuance workflow
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TENANT_CFG_TMEPLATE = include_str("./TENANT_CFG_TEMPLATE")
|
||||||
|
|
Loading…
Reference in New Issue