Skip to content

Commit

Permalink
Merge pull request #36 from hypersign-protocol/fix-resolver
Browse files Browse the repository at this point in the history
fix : resolver
  • Loading branch information
Pratap2018 authored Oct 25, 2024
2 parents 0144a5c + cf73e2e commit 053e1ef
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
54 changes: 53 additions & 1 deletion src/store/mainStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ const mainStore = {



resolveDIDForAService({ getters, }, payload = {}) {
resolveDIDForAKycService({ getters, }, payload = {}) {
return new Promise(function (resolve, reject) {
{
let tenantUrl = ""
Expand Down Expand Up @@ -1352,7 +1352,59 @@ const mainStore = {
})

},
resolveDIDForAService({ commit, getters, }, payload) {
return new Promise(function (resolve, reject) {
{

let selectedService = {};
if (getters.getSelectedService.services[0].id === 'SSI_API') {
selectedService = getters.getSelectedService
} else if (getters.getSelectedService.services[0].id === 'CAVACH_API') {
const ssiSserviceId = getters.getSelectedService.dependentServices[0];
const associatedSSIService = getters.getAppsWithSSIServices.find(
(x) => x.appId === ssiSserviceId
);
selectedService = associatedSSIService
}

if (!selectedService || !selectedService.tenantUrl) {
return reject(new Error('Tenant url is null or empty, service is not selected'))
}

const url = `${sanitizeUrl(selectedService.tenantUrl)}/api/v1/did/resolve/${payload}`;
const options = {
method: "GET",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${selectedService.access_token}`,
"Origin": '*'
}
}
fetch(url, {
headers: options.headers
})
.then(response => response.json())
.then(json => {
if (json) {
const data = {
did: payload,
didDocument: json.didDocument,
status: json.didDocumentMetadata && Object.keys(json.didDocumentMetadata).length > 0 ? 'Registered' : 'Created',
name: json.name
}
commit('updateADID', data);
resolve()
} else {
reject(new Error('Could not fetch DID for this service'))
}

}).catch(e => {
reject(e)
})
}
})

},
createDIDsForAService({ commit, getters, dispatch }, payload) {
return new Promise(function (resolve, reject) {
{
Expand Down
4 changes: 2 additions & 2 deletions src/views/Apps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ export default {
"keepAccessTokenReadyForApp",
"fetchDIDsForAService",
"fetchAppsListFromServer",
"resolveDIDForAService",
"resolveDIDForAKycService",
"fetchServicesList",
"deleteAnAppOnServer"
]),
Expand Down Expand Up @@ -1421,7 +1421,7 @@ export default {
did
};
this.isLoading = true;
const didDocument = await this.resolveDIDForAService(payload);
const didDocument = await this.resolveDIDForAKycService(payload);
this.issuerVerificationMethodIds = didDocument.verificationMethod.filter(vm => {
return vm
})
Expand Down

0 comments on commit 053e1ef

Please sign in to comment.