Files
inji-wallet/shared/commonprops/commonProps.ts
Tilak Puli ca83cb8158 Inji-400: Cache api calls and return initial values if network not available (#883)
* feat(inji-400): Use Initial Config for all properties incase cache and network not available.

* feat(inji-400): Create cache apis to fetch and cache issuer api's

* feat(inji-400): Update Initial Config comments and remove qa-inji urls

* feat(inji-400): Rename catchAPIMethod to generateCacheAPIFunction

* feat(inji-400): Rename qa inji url from warningDomainName

* feat(inji-400): Update logs for api calls

---------

Signed-off-by: Swati Goel <meet2swati@gmail.com>
Co-authored-by: Swati Goel <meet2swati@gmail.com>
2023-10-04 15:44:15 +05:30

37 lines
1.0 KiB
TypeScript

import {init} from 'mosip-inji-face-sdk';
import {changeCrendetialRegistry} from '../constants';
import {CACHED_API} from '../api';
export const COMMON_PROPS_KEY: string =
'CommonPropsKey-' + '6964d04a-9268-11ed-a1eb-0242ac120002';
export default async function getAllConfigurations(host = undefined) {
host && changeCrendetialRegistry(host);
return await CACHED_API.getAllProperties();
}
export async function downloadModel() {
try {
var injiProp = await getAllConfigurations();
const maxRetryStr = injiProp.modelDownloadMaxRetry;
const maxRetry = parseInt(maxRetryStr);
const resp: string = injiProp != null ? injiProp.faceSdkModelUrl : null;
if (resp != null) {
for (let counter = 0; counter < maxRetry; counter++) {
var result = await init(resp, false);
console.log('model download result is = ' + result);
if (result) {
break;
}
}
}
} catch (error) {
console.log(error);
}
}
export interface DownloadProps {
maxDownloadLimit: number;
downloadInterval: number;
}