Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added publisherJurisdiction to hbs auth response #96

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading