-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix HBS and springboard configuration to work with Vite and Vue (#67)
* swap kyc logic into holo & holochain stores * break out holoport API store * rework springboard modal * rework env vars * rework env vars * refactor to pass environment vars to hbs calls * fix compile issue * PR suggestions
- Loading branch information
Showing
9 changed files
with
210 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,43 @@ | ||
import axios from 'axios' | ||
import { AUTH_SERVICE_URL, AUTH_SERVICE_VERSION } from '../utils/hbsConfiguration' | ||
import { authServiceUrl, authServiceVersion } from '../utils/hbsConfiguration' | ||
import { httpCall } from '../utils/httpProvider' | ||
import { useHoloStore } from 'src/stores' | ||
|
||
async function authCall(args) { | ||
export const kycLevel1 = 'holo_kyc_1' | ||
export const kycLevel2 = 'holo_kyc_2' | ||
|
||
async function authCall(args, envirionment, hbsServicePort) { | ||
return httpCall({ | ||
serviceUrl: AUTH_SERVICE_URL, | ||
version: AUTH_SERVICE_VERSION, | ||
serviceUrl: authServiceUrl(envirionment), | ||
version: authServiceVersion(hbsServicePort), | ||
method: 'post', | ||
...args | ||
}) | ||
} | ||
|
||
export async function authenticateAgent(email, public_key) { | ||
console.log(`hbs->authenticateAgent - email: ${email} public_key: ${public_key}`) | ||
|
||
const holoStore = useHoloStore(); | ||
const payload = { | ||
"email": email, | ||
"timestamp": Date.now() - (30 * 1000), // Subtract 30 sec to prevent "future" timestamp error from API | ||
"pubKey": public_key | ||
} | ||
|
||
const { _, signature } = await holoStore.signPayload(payload) | ||
console.log(`authenticateAgent - signature: ${signature}`, payload) | ||
export async function authenticateAgent(payload, signature, envirionment, hbsServicePort) { | ||
try { | ||
const result = await authCall({ | ||
params: payload, | ||
endpoint: 'holo-client', | ||
headers: { | ||
'X-Signature': signature | ||
}, | ||
envirionment, | ||
hbsServicePort | ||
}) | ||
|
||
try { | ||
const result = await authCall({ | ||
params: payload, | ||
endpoint: 'holo-client', | ||
headers: { | ||
'X-Signature': signature | ||
} | ||
}) | ||
|
||
return result.data | ||
} catch (e) { | ||
if (axios.isAxiosError(e)) { | ||
return e.message | ||
} else { | ||
return 'unknown error' | ||
} | ||
return result.data | ||
} catch (e) { | ||
if (axios.isAxiosError(e)) { | ||
return e.message | ||
} else { | ||
return 'unknown error' | ||
} | ||
} | ||
} | ||
|
||
export async function fetchAgentKycLevel(payload, signature, envirionment, hbsServicePort) { | ||
const authResult = await authenticateAgent(payload, signature, envirionment, hbsServicePort) | ||
return (authResult && authResult.kyc) ? (authResult.kyc === kycLevel2) ? 2 : 1 : null | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.