walt-id / waltid-web-wallet-deprecated

web-wallet @ walt.id
https://wallet.walt.id
Apache License 2.0
17 stars 14 forks source link

DID creation #9

Closed severinstampler closed 2 years ago

severinstampler commented 2 years ago

Provide functionality to create DID from wallet.

severinstampler commented 2 years ago

create automatically on login if not existing

severinstampler commented 2 years ago

An API is available for DID creation and registration. For EBSI, it requires a bearer token to be given as a form parameter "ebsiBearerToken", see details: createDid API

If a did of that method already exists, it will return an error 400. Use listDids to list existing dids.

iietmoon commented 2 years ago

@severinstampler I am working to integrate the API for create a did for EBSI and I don't know if the "token" that user fill in "Your token ebsiBearerToken that need be sent to create it in /api/wallet/did/create

severinstampler commented 2 years ago

yes it needs to be sent in order to register the did on EBSI.

iietmoon commented 2 years ago

is any ebsiBearerToken for testing available to get the success data formats

severinstampler commented 2 years ago

Hi, yes, you have to go to https://app.preprod.ebsi.eu/users-onboarding/ click "onboard with captcha", "Desktop wallet". It will show a token, that's valid for 15 minutes.

iietmoon commented 2 years ago

I don't know if the exact schema for post, but i did axios.post('/api/wallet/did/create?method=ebsi', { header:{ "Content-Type": "application/x-www-form-urlencoded" }, data:{ "ebsiBearerToken": ${this.token} } })

iietmoon commented 2 years ago

axios.post('/api/wallet/did/create?method=ebsi', { header:{ "Content-Type": "application/x-www-form-urlencoded" }, data:{ "ebsiBearerToken":${this.token} } })

severinstampler commented 2 years ago

this endoint is currently implemented to accept form data, like it is produced when submitting an HTML form. however, on second thought, I could also make it accept a data object, like you implemented it.

severinstampler commented 2 years ago

well, to support the form data body, just pass the key-value pair in plain text, like:

"ebsiBearerToken=${this.token}"

cheers

iietmoon commented 2 years ago

Hello @severinstampler, I don't know but this still gives us "400 error", please check if the format I use is correct because it took it same as used in cURL in the API Documentation, I see need to tell me the exact format because that currently in doc, also if need authorisation in header or not

async tokenSubmit (){
        try{
            const data = await this.$axios.$post('/api/wallet/did/create?method=ebsi', {
              header:{
                "accept": "text/plain",
                "Content-Type": "application/x-www-form-urlencoded" 
              },
              data:{
                ebsiBearerToken:`${this.token}`,
              }
            })
            console.log(data.data)
            this.tokenSubmitted=true
            this.wizardIndex = this.wizardIndex+1
        }catch(e){
            console.warn(e)
            this.tokenWrong=true
        }  
    }
severinstampler commented 2 years ago

Hi @iietmoon, like I described in my previous comment, the key-value pair should be given in plain text in the post body. You are passing it as a JSON object, however, the right way would be just like this: "ebsiBearerToken=${this.token}"

Alternatively, you can use the FormData object to pass the data, like described here: https://blog.digital-craftsman.de/send-form-data-with-axios-vue-js/

Regarding authorization: You don't have to care about it, as it is automatically handled by the auth plugin.

severinstampler commented 2 years ago

@iietmoon, I adapted the DID creation API and already changed the API call in the vue component. It seems to work now.