diff --git a/src/services/hbs.js b/src/services/hbs.js index b7b52ce..3248ab6 100644 --- a/src/services/hbs.js +++ b/src/services/hbs.js @@ -13,7 +13,6 @@ async function authCall(args, environment, hbsServicePort) { ...args }) } - export async function authenticateAgent(payload, signature, environment, hbsServicePort) { try { const result = await authCall({ @@ -42,75 +41,6 @@ export async function fetchAgentKycLevel(payload, signature, environment, hbsSer return (authResult && authResult.kyc) ? (authResult.kyc === kycLevel2) ? 2 : 1 : null } - -async function registrationCall(args, environment, hbsServicePort) { - return httpCall({ - serviceUrl: registrationServiceUrl(environment), - version: registrationServiceVersion(hbsServicePort), - method: 'post', - ...args - }) -} - -async function registrationFetchHostCriteria(payload, environment, hbsServicePort) { - try { - const result = await registrationCall({ - params: payload, - endpoint: 'fetch-host-criteria', - }, - environment, - hbsServicePort - ) - - return result.data - } catch (e) { - if (axios.isAxiosError(e)) { - return e.message - } else { - return 'unknown error' - } - } -} - -// Returns: -// [ -// { -// "_id": "string", -// "jurisdiction": "string", -// "kyc": "string", // Note: Either `holo_kyc_1` or `holo_kyc_2` -// "error": "string", -// "pubkey": "string" -// } -// ] -export async function fetchHostCriteria(hostIds = [], environment, hbsServicePort, page = 0, itemsPerPage = 50) { - let hostsWithCriteria = []; - let currentItems = 0 - // Initialize `totalItems` with the page number for first HBS loop - // ...once first loop is complete, `totalItems` will be updated with full number of records in the collection - let totalItems = itemsPerPage; - - do { - console.log(`Fetching page ${page} from uptime records...`) - const payload = { - "page": page, - "itemsPerPage": itemsPerPage, - "ids": hostIds - } - - const result = await registrationFetchHostCriteria(payload, environment, hbsServicePort) - - for (let item of result.items) { - hostsWithCriteria.push(item) - } - - page = result.page + 1 // NB: pages are 0-indexed - currentItems = page * result.itemsPerPage - totalItems = result.totalItems - } while (totalItems > currentItems); - - return hostsWithCriteria -} - export async function registrationFetchJurisdictions(environment, hbsServicePort) { const result = httpCall({ serviceUrl: registrationServiceUrl(environment),