Skip to content

Commit 053e1ef

Browse files
authored
Merge pull request #36 from hypersign-protocol/fix-resolver
fix : resolver
2 parents 0144a5c + cf73e2e commit 053e1ef

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-3
lines changed

src/store/mainStore.js

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ const mainStore = {
13011301

13021302

13031303

1304-
resolveDIDForAService({ getters, }, payload = {}) {
1304+
resolveDIDForAKycService({ getters, }, payload = {}) {
13051305
return new Promise(function (resolve, reject) {
13061306
{
13071307
let tenantUrl = ""
@@ -1352,7 +1352,59 @@ const mainStore = {
13521352
})
13531353

13541354
},
1355+
resolveDIDForAService({ commit, getters, }, payload) {
1356+
return new Promise(function (resolve, reject) {
1357+
{
1358+
1359+
let selectedService = {};
1360+
if (getters.getSelectedService.services[0].id === 'SSI_API') {
1361+
selectedService = getters.getSelectedService
1362+
} else if (getters.getSelectedService.services[0].id === 'CAVACH_API') {
1363+
const ssiSserviceId = getters.getSelectedService.dependentServices[0];
1364+
const associatedSSIService = getters.getAppsWithSSIServices.find(
1365+
(x) => x.appId === ssiSserviceId
1366+
);
1367+
selectedService = associatedSSIService
1368+
}
1369+
1370+
if (!selectedService || !selectedService.tenantUrl) {
1371+
return reject(new Error('Tenant url is null or empty, service is not selected'))
1372+
}
1373+
1374+
const url = `${sanitizeUrl(selectedService.tenantUrl)}/api/v1/did/resolve/${payload}`;
1375+
const options = {
1376+
method: "GET",
1377+
headers: {
1378+
"Content-Type": "application/json",
1379+
"Authorization": `Bearer ${selectedService.access_token}`,
1380+
"Origin": '*'
1381+
}
1382+
}
1383+
fetch(url, {
1384+
headers: options.headers
1385+
})
1386+
.then(response => response.json())
1387+
.then(json => {
1388+
if (json) {
1389+
const data = {
1390+
did: payload,
1391+
didDocument: json.didDocument,
1392+
status: json.didDocumentMetadata && Object.keys(json.didDocumentMetadata).length > 0 ? 'Registered' : 'Created',
1393+
name: json.name
1394+
}
1395+
commit('updateADID', data);
1396+
resolve()
1397+
} else {
1398+
reject(new Error('Could not fetch DID for this service'))
1399+
}
13551400

1401+
}).catch(e => {
1402+
reject(e)
1403+
})
1404+
}
1405+
})
1406+
1407+
},
13561408
createDIDsForAService({ commit, getters, dispatch }, payload) {
13571409
return new Promise(function (resolve, reject) {
13581410
{

src/views/Apps.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ export default {
10791079
"keepAccessTokenReadyForApp",
10801080
"fetchDIDsForAService",
10811081
"fetchAppsListFromServer",
1082-
"resolveDIDForAService",
1082+
"resolveDIDForAKycService",
10831083
"fetchServicesList",
10841084
"deleteAnAppOnServer"
10851085
]),
@@ -1421,7 +1421,7 @@ export default {
14211421
did
14221422
};
14231423
this.isLoading = true;
1424-
const didDocument = await this.resolveDIDForAService(payload);
1424+
const didDocument = await this.resolveDIDForAKycService(payload);
14251425
this.issuerVerificationMethodIds = didDocument.verificationMethod.filter(vm => {
14261426
return vm
14271427
})

0 commit comments

Comments
 (0)