From 751c066bd0a0ec1e6988796e726b236a3e3c2d2b Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sun, 28 Apr 2024 17:02:31 -0600 Subject: [PATCH] constantly recheck on home screen if not registered --- src/libs/endorserServer.ts | 44 ++++++++++++++++++++++++++++++++++- src/views/AccountViewView.vue | 40 +++++++++++-------------------- src/views/HomeView.vue | 29 ++++++++++++++++++++--- 3 files changed, 82 insertions(+), 31 deletions(-) diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index 744fc9d..3fb46ed 100644 --- a/src/libs/endorserServer.ts +++ b/src/libs/endorserServer.ts @@ -1,9 +1,15 @@ -import { Axios, AxiosResponse, RawAxiosRequestHeaders } from "axios"; +import { + Axios, + AxiosRequestConfig, + AxiosResponse, + RawAxiosRequestHeaders, +} from "axios"; import * as didJwt from "did-jwt"; import { LRUCache } from "lru-cache"; import * as R from "ramda"; import { IIdentifier } from "@veramo/core"; +import { DEFAULT_IMAGE_API_SERVER } from "@/constants/app"; import { Contact } from "@/db/tables/contacts"; import { accessToken, SimpleSigner } from "@/libs/crypto"; import { NonsensitiveDexie } from "@/db/index"; @@ -1007,3 +1013,39 @@ export async function setVisibilityUtil( return { error: "Check connectivity and try again." }; } } + +/** + * Fetches rate limits from the Endorser server. + * + * @param apiServer endorser server URL string + * @param axios Axios instance + * @param {IIdentifier} identity - The identity object to check rate limits for. + * @returns {Promise} The Axios response object. + */ +export async function fetchEndorserRateLimits( + apiServer: string, + axios: Axios, + identity: IIdentifier, +) { + const url = `${apiServer}/api/report/rateLimits`; + const headers = await getHeaders(identity); + return await axios.get(url, { headers } as AxiosRequestConfig); +} + +/** + * Fetches rate limits from the image server. + * + * @param apiServer image server URL string + * @param axios Axios instance + * @param {IIdentifier} identity - The identity object to check rate limits for. + * @returns {Promise} The Axios response object. + */ +export async function fetchImageRateLimits( + apiServer: string, + axios: Axios, + identity: IIdentifier, +) { + const url = DEFAULT_IMAGE_API_SERVER + "/image-limits"; + const headers = await getHeaders(identity); + return await axios.get(url, { headers } as AxiosRequestConfig); +} diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index 17b019c..0c84f6e 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -612,7 +612,7 @@