Skip to content

Commit

Permalink
Merge pull request #96 from Holo-Host/feat/publisher-jurisdiction
Browse files Browse the repository at this point in the history
feat: added publisherJurisdiction to hbs auth response
  • Loading branch information
zeeshan595 authored Sep 4, 2024
2 parents a2a8cb5 + 3c55baa commit 7573bea
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/stores/useHbsStore.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { defineStore } from 'pinia'
import { fetchAgentKycLevel, registrationFetchJurisdictions } from '../services/hbs'
import { registrationFetchJurisdictions } from '../services/hbs'

const makeUseHbsStore = ({ useHoloStore }) => {
return defineStore('hbs', {
state: () => ({
kycLevel: null,
publisherJurisdiction: null,
jurisdictions: []
}),
getters: {
Expand All @@ -13,16 +14,29 @@ const makeUseHbsStore = ({ useHoloStore }) => {
},
actions: {
async loadAgentKycLevel(environment, hbsServicePort) {
const { kycLevel } = this.loadAgent(environment, hbsServicePort);
this.kycLevel = kycLevel
return kycLevel
},
async loadAgent(environment, hbsServicePort) {
const payload = {
"email": useHoloStore().agentEmail,
"timestamp": Date.now() - (30 * 1000), // Subtract 30 sec to prevent "future" timestamp error from API
"pubKey": useHoloStore().agentId
}

const { _, signature } = await await useHoloStore().signPayload(payload)
const kycLevel = await fetchAgentKycLevel(payload, signature, environment, hbsServicePort)
this.kycLevel = kycLevel
return kycLevel
const result = await authenticateAgent(payload, signature, environment, hbsServicePort)
if (result) {
if (result.kyc)
this.kycLevel = result.kyc === kycLevel2 ? 2 : 1;
if (result.jurisdiction)
this.publisherJurisdiction = result.jurisdiction;
}
return {
kycLevel: this.kycLevel,
publisherJurisdiction: this.publisherJurisdiction
};
},
async loadJurisdictions(environment, hbsServicePort) {
try {
Expand Down

0 comments on commit 7573bea

Please sign in to comment.