Skip to content

Commit

Permalink
feat: added publisherJurisdiction to hbs auth response
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeeshan Abid committed May 20, 2024
1 parent 2ae5248 commit 3c55baa
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 3c55baa

Please sign in to comment.