diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index 744fc9dce..3fb46edff 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 17b019c0b..0c84f6ef0 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -612,7 +612,7 @@