[INJI-628 & INJI-630]: Local backup creation (#1160)

* [INJI-630]: add backup machine and screens for data backup

Signed-off-by: Pooja Babusingh <68894211+PoojaBabusingh@users.noreply.github.com>

* [INJI-630]: add argon2 configs for hashing salt, password and phoneNumber

Signed-off-by: Pooja Babusingh <68894211+PoojaBabusingh@users.noreply.github.com>

* [INJI-630]: add key encryption and store hashed encryption key

Signed-off-by: Pooja Babusingh <68894211+PoojaBabusingh@users.noreply.github.com>

* [INJI-630]: add toggle backup check to make modal invisible in ios

Signed-off-by: Pooja Babusingh <68894211+PoojaBabusingh@users.noreply.github.com>

* (INJI-630): update package-lock.json

Signed-off-by: Sreenadh S <32409698+sree96@users.noreply.github.com>

* [INJI-628]: restrict logic to double stringify JSON object before saving to DB

Signed-off-by: Alka <prasadalka1998@gmail.com>

* [INJI-628]: create local compressed backup file

Signed-off-by: Alka <prasadalka1998@gmail.com>

* [INJI-628]: move some functions to appropriate files

Signed-off-by: Alka <prasadalka1998@gmail.com>

* [INJI-628]: remove RN aes crypto library and use existing library to generate encryption key

Signed-off-by: Alka <prasadalka1998@gmail.com>

* [INJI-628]: update logic to check storage availability for backup creation

Signed-off-by: Alka <prasadalka1998@gmail.com>

* [INJI-628]: declare the variable and use then use it

Signed-off-by: Alka <prasadalka1998@gmail.com>

---------

Signed-off-by: Pooja Babusingh <68894211+PoojaBabusingh@users.noreply.github.com>
Signed-off-by: PoojaBabusing <115976560+PoojaBabusing@users.noreply.github.com>
Signed-off-by: Sreenadh S <32409698+sree96@users.noreply.github.com>
Signed-off-by: Alka <prasadalka1998@gmail.com>
Signed-off-by: Alka Prasad <Alka1703@users.noreply.github.com>
Co-authored-by: Pooja Babusingh <68894211+PoojaBabusingh@users.noreply.github.com>
Co-authored-by: Sreenadh S <32409698+sree96@users.noreply.github.com>
Co-authored-by: Alka <prasadalka1998@gmail.com>
Co-authored-by: Alka Prasad <Alka1703@users.noreply.github.com>
This commit is contained in:
PoojaBabusing
2024-01-19 18:24:55 +05:30
committed by GitHub
parent f340420627
commit d778b94403
22 changed files with 1132 additions and 40 deletions

View File

@@ -178,21 +178,19 @@ async function generateCacheAPIFunctionWithCachePreference(
) {
const existingCredentials = await Keychain.getGenericPassword();
try {
const response = (await getItem(
const response = await getItem(
cacheKey,
null,
existingCredentials?.password,
)) as string;
);
if (response) {
return JSON.parse(response);
return response;
} else {
const response = await fetchCall();
setItem(
cacheKey,
JSON.stringify(response),
existingCredentials?.password,
).then(() => console.log('Cached response for ' + cacheKey));
setItem(cacheKey, response, existingCredentials?.password).then(() =>
console.log('Cached response for ' + cacheKey),
);
return response;
}
@@ -219,11 +217,9 @@ async function generateCacheAPIFunctionWithAPIPreference(
const existingCredentials = await Keychain.getGenericPassword();
try {
const response = await fetchCall();
setItem(
cacheKey,
JSON.stringify(response),
existingCredentials.password,
).then(() => console.log('Cached response for ' + cacheKey));
setItem(cacheKey, response, existingCredentials.password).then(() =>
console.log('Cached response for ' + cacheKey),
);
return response;
} catch (error) {
console.warn(`Failed to load due to network issue in API preferred api call.
@@ -233,14 +229,14 @@ async function generateCacheAPIFunctionWithAPIPreference(
console.log(error);
const response = (await getItem(
const response = await getItem(
cacheKey,
null,
existingCredentials.password,
)) as string;
);
if (response) {
return JSON.parse(response);
return response;
} else {
if (response == null) {
throw error;