[INJIMOB-1417]: integrating native library of secure-keystone in Inji (#1464)

* [INJIMOB-1417]:add nstive  integration of secure-keystore in inji

Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com>

* [INJIMOB-1417]: refactor changes

Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com>

* [INJIMOB-1417]: update snapshot version

Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com>

* [INJIMOB-1417]: update package.json

Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com>

* [INJIMOB-1417]: update podfile.lock

Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com>

---------

Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com>
This commit is contained in:
abhip2565
2024-05-29 10:22:41 +05:30
committed by GitHub
parent b48c1ec668
commit 767094b44a
15 changed files with 262 additions and 164 deletions

View File

@@ -22,18 +22,19 @@ import {
} from './shared/telemetry/TelemetryUtils';
import {TelemetryConstants} from './shared/telemetry/TelemetryConstants';
import {MessageOverlay} from './components/MessageOverlay';
import SecureKeystore from '@mosip/secure-keystore';
import { NativeModules } from 'react-native';
import {isHardwareKeystoreExists} from './shared/cryptoutil/cryptoUtil';
import i18n from './i18n';
import './shared/flipperConfig';
import * as SplashScreen from 'expo-splash-screen';
SplashScreen.preventAutoHideAsync();
const {RNSecureKeystoreModule}=NativeModules;
// kludge: this is a bad practice but has been done temporarily to surface
// an occurrence of a bug with minimal residual code changes, this should
// be removed once the bug cause is determined & fixed, ref: INJI-222
const DecryptErrorAlert = (controller, t) => {
const heading = t('errors.decryptionFailed');
const desc = t('errors.decryptionFailed');
const ignoreBtnTxt = t('ignore');
@@ -127,7 +128,7 @@ const AppInitialization: React.FC = () => {
useEffect(() => {
if (isHardwareKeystoreExists) {
SecureKeystore.updatePopup(
RNSecureKeystoreModule.updatePopup(
t('biometricPopup.title'),
t('biometricPopup.description'),
);

View File

@@ -250,6 +250,7 @@ dependencies {
implementation("com.facebook.react:react-android")
implementation 'com.facebook.soloader:soloader:0.10.1+'
implementation("io.mosip:pixelpass:1.2-SNAPSHOT")
implementation("io.mosip:secure-keystore:1.1-SNAPSHOT")
def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";

View File

@@ -10,6 +10,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class InjiPackage implements ReactPackage {
@NonNull
@Override
@@ -18,7 +19,7 @@ public class InjiPackage implements ReactPackage {
modules.add(new InjiVciClientModule(reactApplicationContext));
modules.add(new RNPixelpassModule(reactApplicationContext));
modules.add(new RNSecureKeystoreModule(reactApplicationContext));
return modules;
}

View File

@@ -12,9 +12,7 @@ import com.facebook.react.ReactPackage;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.defaults.DefaultReactNativeHost;
import com.facebook.soloader.SoLoader;
import timber.log.Timber;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
@@ -30,7 +28,6 @@ public class MainApplication extends Application implements ReactApplication {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
packages.add(new InjiPackage());
return packages;
}

View File

@@ -0,0 +1,181 @@
package io.mosip.residentapp;
import com.reactnativesecurekeystore.SecureKeystoreImpl;
import com.reactnativesecurekeystore.KeyGeneratorImpl;
import com.reactnativesecurekeystore.CipherBoxImpl;
import com.reactnativesecurekeystore.DeviceCapability;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.reactnativesecurekeystore.biometrics.Biometrics;
import com.reactnativesecurekeystore.common.Util;
import com.facebook.react.bridge.Callback;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function2;
public class RNSecureKeystoreModule extends ReactContextBaseJavaModule {
private final KeyGeneratorImpl keyGenerator = new KeyGeneratorImpl();
private final CipherBoxImpl cipherBox = new CipherBoxImpl();
private final Biometrics biometrics;
private final SecureKeystoreImpl keystore;
private final DeviceCapability deviceCapability;
private final String logTag;
public RNSecureKeystoreModule(ReactApplicationContext reactContext) {
super(reactContext);
this.biometrics = new Biometrics(reactContext);
this.keystore = new SecureKeystoreImpl(keyGenerator, cipherBox, biometrics);
this.deviceCapability = new DeviceCapability(keystore, keyGenerator, biometrics);
this.logTag = Util.Companion.getLogTag(getClass().getSimpleName());
}
@Override
public String getName() {
return "RNSecureKeystoreModule";
}
@ReactMethod(isBlockingSynchronousMethod = true)
public boolean deviceSupportsHardware() {
return deviceCapability.supportsHardwareKeyStore();
}
@ReactMethod(isBlockingSynchronousMethod = true)
public boolean hasAlias(String alias) {
return keystore.hasAlias(alias);
}
@ReactMethod(isBlockingSynchronousMethod = true)
public void updatePopup(String title, String description) {
Biometrics.Companion.updatePopupDetails(title, description);
}
@ReactMethod(isBlockingSynchronousMethod = true)
public void generateKey(String alias, boolean isAuthRequired, Integer authTimeout) {
keystore.generateKey(alias, isAuthRequired, authTimeout);
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String generateKeyPair(String alias, boolean isAuthRequired, Integer authTimeout) {
return keystore.generateKeyPair(alias, isAuthRequired, authTimeout);
}
@ReactMethod(isBlockingSynchronousMethod = true)
public void generateHmacshaKey(String alias) {
keystore.generateHmacSha256Key(alias);
}
@ReactMethod
public void encryptData(String alias, String data, Promise promise) {
Function1<String, Unit> successLambda = new Function1<String, Unit>() {
@Override
public Unit invoke(String encryptedText) {
promise.resolve(encryptedText);
return Unit.INSTANCE;
}
};
Function2<Integer, String, Unit> failureLambda = new Function2<Integer, String, Unit>() {
@Override
public Unit invoke(Integer code, String message) {
promise.reject(code.toString(),message);
return Unit.INSTANCE;
}
};
keystore.encryptData(
alias,
data,
successLambda,
failureLambda
);
}
@ReactMethod
public void decryptData(String alias, String encryptedText,Promise promise) {
Function1<String, Unit> successLambda = new Function1<String, Unit>() {
@Override
public Unit invoke(String data) {
promise.resolve(data);
return Unit.INSTANCE;
}
};
Function2<Integer, String, Unit> failureLambda = new Function2<Integer, String, Unit>() {
@Override
public Unit invoke(Integer code, String message) {
promise.reject(code.toString(),message);
return Unit.INSTANCE;
}
};
keystore.decryptData(alias, encryptedText, successLambda, failureLambda);
}
@ReactMethod
public void generateHmacSha(String alias, String data, Promise promise) {
Function1<String, Unit> successLambda = new Function1<String, Unit>() {
@Override
public Unit invoke(String sha) {
promise.resolve(sha);
return Unit.INSTANCE;
}
};
Function2<Integer, String, Unit> failureLambda = new Function2<Integer, String, Unit>() {
@Override
public Unit invoke(Integer code, String message) {
promise.reject(code.toString(),message);
return Unit.INSTANCE;
}
};
keystore.generateHmacSha(
alias,
data,
successLambda,
failureLambda
);
}
@ReactMethod
public void sign(String alias, String data, Promise promise) {
Function1<String, Unit> successLambda = new Function1<String, Unit>() {
@Override
public Unit invoke(String signature) {
promise.resolve(signature);
return Unit.INSTANCE;
}
};
Function2<Integer, String, Unit> failureLambda = new Function2<Integer, String, Unit>() {
@Override
public Unit invoke(Integer code, String message) {
promise.reject(code.toString(),message);
return Unit.INSTANCE;
}
};
keystore.sign(
alias,
data,
successLambda,
failureLambda
);
}
@ReactMethod(isBlockingSynchronousMethod = true)
public void clearKeys() {
keystore.removeAllKeys();
}
@ReactMethod(isBlockingSynchronousMethod = true)
public boolean hasBiometricsEnabled() {
return deviceCapability.hasBiometricsEnabled();
}
}

View File

@@ -1,4 +1,5 @@
{
"originHash" : "d01056e90451bce7952dbc76948d3026497a31374959581b2fdf485b17f6b992",
"pins" : [
{
"identity" : "base45-swift",

View File

@@ -514,8 +514,6 @@ PODS:
- RNZipArchive/Core (6.1.0):
- React-Core
- SSZipArchive (~> 2.2)
- secure-keystore (0.1.7):
- React-Core
- SSZipArchive (2.4.3)
- TensorFlowLiteC (2.12.0):
- TensorFlowLiteC/Core (= 2.12.0)
@@ -625,7 +623,6 @@ DEPENDENCIES:
- RNSecureRandom (from `../node_modules/react-native-securerandom`)
- RNSVG (from `../node_modules/react-native-svg`)
- RNZipArchive (from `../node_modules/react-native-zip-archive`)
- "secure-keystore (from `../node_modules/@mosip/secure-keystore`)"
- "tuvali (from `../node_modules/@mosip/tuvali`)"
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
@@ -825,8 +822,6 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-svg"
RNZipArchive:
:path: "../node_modules/react-native-zip-archive"
secure-keystore:
:path: "../node_modules/@mosip/secure-keystore"
tuvali:
:path: "../node_modules/@mosip/tuvali"
Yoga:
@@ -934,7 +929,6 @@ SPEC CHECKSUMS:
RNSecureRandom: 07efbdf2cd99efe13497433668e54acd7df49fef
RNSVG: 07dbd870b0dcdecc99b3a202fa37c8ca163caec2
RNZipArchive: ef9451b849c45a29509bf44e65b788829ab07801
secure-keystore: 3bc262bc91c5fbcfea92a8d0fd59c1b8b8ababee
SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef
TensorFlowLiteC: 20785a69299185a379ba9852b6625f00afd7984a
TensorFlowLiteObjC: 9a46a29a76661c513172cfffd3bf712b11ef25c3

View File

@@ -16,7 +16,7 @@ import {
generateKeys,
isHardwareKeystoreExists,
} from '../../shared/cryptoutil/cryptoUtil';
import SecureKeystore from '@mosip/secure-keystore';
import { NativeModules } from 'react-native';
import {getVCMetadata, VCMetadata} from '../../shared/VCMetadata';
import {
VerificationErrorType,
@@ -29,6 +29,7 @@ import {
import {TelemetryConstants} from '../../shared/telemetry/TelemetryConstants';
import {VciClient} from '../../shared/vciClient/VciClient';
const{RNSecureKeystoreModule}=NativeModules
export const IssuersService = () => {
return {
isUserSignedAlready: () => async () => {
@@ -108,8 +109,8 @@ export const IssuersService = () => {
if (!isHardwareKeystoreExists) {
return await generateKeys();
}
const isBiometricsEnabled = SecureKeystore.hasBiometricsEnabled();
return SecureKeystore.generateKeyPair(
const isBiometricsEnabled = RNSecureKeystoreModule.hasBiometricsEnabled();
return RNSecureKeystoreModule.generateKeyPair(
Issuers_Key_Ref,
isBiometricsEnabled,
0,

View File

@@ -1,4 +1,4 @@
import SecureKeystore from '@mosip/secure-keystore';
import { NativeModules } from 'react-native';
import Cloud from '../../../shared/CloudBackupAndRestoreUtils';
import {VCMetadata} from '../../../shared/VCMetadata';
import getAllConfigurations, {
@@ -19,6 +19,7 @@ import {verifyCredential} from '../../../shared/vcjs/verifyCredential';
import {getMosipIdentifier} from '../../../shared/commonUtil';
import {getVerifiableCredential} from './VCItemSelectors';
const{RNSecureKeystoreModule}=NativeModules
export const VCItemServices = model => {
return {
isUserSignedAlready: () => async () => {
@@ -96,8 +97,8 @@ export const VCItemServices = model => {
if (!isHardwareKeystoreExists) {
return await generateKeys();
}
const isBiometricsEnabled = SecureKeystore.hasBiometricsEnabled();
return SecureKeystore.generateKeyPair(
const isBiometricsEnabled = RNSecureKeystoreModule.hasBiometricsEnabled();
return RNSecureKeystoreModule.generateKeyPair(
VCMetadata.fromVC(context.vcMetadata).id,
isBiometricsEnabled,
0,

View File

@@ -20,7 +20,7 @@ import {
SHOW_FACE_AUTH_CONSENT_SHARE_FLOW,
ENOENT,
} from '../shared/constants';
import SecureKeystore from '@mosip/secure-keystore';
import { NativeModules } from 'react-native';
import {
AUTH_TIMEOUT,
decryptJson,
@@ -45,6 +45,7 @@ export const keyinvalidatedString =
'Key Invalidated due to biometric enrollment';
export const tamperedErrorMessageString = 'Data is tampered';
const{RNSecureKeystoreModule}=NativeModules
const model = createModel(
{
encryptionKey: '',
@@ -294,12 +295,12 @@ export const storeMachine =
services: {
clear: () => clear(),
hasAndroidEncryptionKey: () => async callback => {
const hasSetCredentials = SecureKeystore.hasAlias(ENCRYPTION_ID);
const hasSetCredentials = RNSecureKeystoreModule.hasAlias(ENCRYPTION_ID);
if (hasSetCredentials) {
try {
const base64EncodedString =
Buffer.from('Dummy').toString('base64');
await SecureKeystore.encryptData(
await RNSecureKeystoreModule.encryptData(
DUMMY_KEY_FOR_BIOMETRIC_ALIAS,
base64EncodedString,
);
@@ -525,14 +526,14 @@ export const storeMachine =
);
}
} else {
const isBiometricsEnabled = SecureKeystore.hasBiometricsEnabled();
await SecureKeystore.generateKey(
const isBiometricsEnabled = RNSecureKeystoreModule.hasBiometricsEnabled();
await RNSecureKeystoreModule.generateKey(
ENCRYPTION_ID,
isBiometricsEnabled,
AUTH_TIMEOUT,
);
SecureKeystore.generateHmacshaKey(HMAC_ALIAS);
SecureKeystore.generateKey(
RNSecureKeystoreModule.generateHmacshaKey(HMAC_ALIAS);
RNSecureKeystoreModule.generateKey(
DUMMY_KEY_FOR_BIOMETRIC_ALIAS,
isBiometricsEnabled,
0,
@@ -865,7 +866,7 @@ export async function clear() {
try {
console.warn('clearing entire storage');
if (isHardwareKeystoreExists) {
SecureKeystore.clearKeys();
RNSecureKeystoreModule.clearKeys();
}
await Storage.clear();
} catch (e) {

View File

@@ -1,77 +1,48 @@
// This file was automatically generated. Edits will be overwritten
export interface Typegen0 {
'@@xstate/typegen': true;
internalEvents: {
'done.invoke._store': {
type: 'done.invoke._store';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'done.invoke.store.resettingStorage:invocation[0]': {
type: 'done.invoke.store.resettingStorage:invocation[0]';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'error.platform._store': {type: 'error.platform._store'; data: unknown};
'xstate.init': {type: 'xstate.init'};
};
invokeSrcNameMap: {
checkStorageInitialisedOrNot: 'done.invoke.store.checkStorageInitialisation:invocation[0]';
clear: 'done.invoke.store.resettingStorage:invocation[0]';
generateEncryptionKey: 'done.invoke.store.generatingEncryptionKey:invocation[0]';
getEncryptionKey: 'done.invoke.store.gettingEncryptionKey:invocation[0]';
hasAndroidEncryptionKey: 'done.invoke.store.checkEncryptionKey:invocation[0]';
store: 'done.invoke._store';
};
missingImplementations: {
actions: never;
delays: never;
guards: never;
services: never;
};
eventsCausingActions: {
forwardStoreRequest:
| 'APPEND'
| 'CLEAR'
| 'EXPORT'
| 'GET'
| 'GET_VCS_DATA'
| 'PREPEND'
| 'REMOVE'
| 'REMOVE_ITEMS'
| 'REMOVE_VC_METADATA'
| 'RESTORE_BACKUP'
| 'SET'
| 'UPDATE';
notifyParent:
| 'KEY_RECEIVED'
| 'READY'
| 'done.invoke.store.resettingStorage:invocation[0]';
setEncryptionKey: 'KEY_RECEIVED';
};
eventsCausingDelays: {};
eventsCausingGuards: {
isCustomSecureKeystore: 'KEY_RECEIVED';
};
eventsCausingServices: {
checkStorageInitialisedOrNot: 'ERROR';
clear: 'KEY_RECEIVED';
generateEncryptionKey: 'ERROR' | 'IGNORE' | 'READY';
getEncryptionKey: 'TRY_AGAIN';
hasAndroidEncryptionKey: never;
store:
| 'KEY_RECEIVED'
| 'READY'
| 'done.invoke.store.resettingStorage:invocation[0]';
};
matchesStates:
| 'checkEncryptionKey'
| 'checkStorageInitialisation'
| 'failedReadingKey'
| 'generatingEncryptionKey'
| 'gettingEncryptionKey'
| 'ready'
| 'resettingStorage';
tags: never;
}
// This file was automatically generated. Edits will be overwritten
export interface Typegen0 {
'@@xstate/typegen': true;
internalEvents: {
"done.invoke._store": { type: "done.invoke._store"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." };
"done.invoke.store.resettingStorage:invocation[0]": { type: "done.invoke.store.resettingStorage:invocation[0]"; data: unknown; __tip: "See the XState TS docs to learn how to strongly type this." };
"error.platform._store": { type: "error.platform._store"; data: unknown };
"xstate.init": { type: "xstate.init" };
};
invokeSrcNameMap: {
"checkStorageInitialisedOrNot": "done.invoke.store.checkStorageInitialisation:invocation[0]";
"clear": "done.invoke.store.resettingStorage:invocation[0]";
"generateEncryptionKey": "done.invoke.store.generatingEncryptionKey:invocation[0]";
"getEncryptionKey": "done.invoke.store.gettingEncryptionKey:invocation[0]";
"hasAndroidEncryptionKey": "done.invoke.store.checkEncryptionKey:invocation[0]";
"store": "done.invoke._store";
};
missingImplementations: {
actions: never;
delays: never;
guards: never;
services: never;
};
eventsCausingActions: {
"forwardStoreRequest": "APPEND" | "CLEAR" | "EXPORT" | "GET" | "GET_VCS_DATA" | "PREPEND" | "REMOVE" | "REMOVE_ITEMS" | "REMOVE_VC_METADATA" | "RESTORE_BACKUP" | "SET" | "UPDATE";
"notifyParent": "KEY_RECEIVED" | "READY" | "done.invoke.store.resettingStorage:invocation[0]";
"setEncryptionKey": "KEY_RECEIVED";
};
eventsCausingDelays: {
};
eventsCausingGuards: {
"isCustomSecureKeystore": "KEY_RECEIVED";
};
eventsCausingServices: {
"checkStorageInitialisedOrNot": "ERROR";
"clear": "KEY_RECEIVED";
"generateEncryptionKey": "ERROR" | "IGNORE" | "READY";
"getEncryptionKey": "TRY_AGAIN";
"hasAndroidEncryptionKey": never;
"store": "KEY_RECEIVED" | "READY" | "done.invoke.store.resettingStorage:invocation[0]";
};
matchesStates: "checkEncryptionKey" | "checkStorageInitialisation" | "failedReadingKey" | "generatingEncryptionKey" | "gettingEncryptionKey" | "ready" | "resettingStorage";
tags: never;
}

52
package-lock.json generated
View File

@@ -18,8 +18,6 @@
"@expo/metro-config": "~0.10.0",
"@invertase/react-native-apple-authentication": "^2.3.0",
"@iriscan/biometric-sdk-react-native": "0.2.6",
"@mosip/pixelpass": "^0.1.5",
"@mosip/secure-keystore": "^0.1.7",
"@mosip/tuvali": "git://github.com/mosip/tuvali.git#develop",
"@react-native-clipboard/clipboard": "^1.10.0",
"@react-native-community/netinfo": "9.3.7",
@@ -5674,26 +5672,6 @@
"node": ">= 4.0.0"
}
},
"node_modules/@mosip/pixelpass": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/@mosip/pixelpass/-/pixelpass-0.1.5.tgz",
"integrity": "sha512-4vVB9P54xDi9g+1fwBnD/9h97w/nm0J5RNKkN1L0gCqLdKzzPitehnCreZEhF0pN4uOBKDDwZsRKL5KdZVsFWg==",
"dependencies": {
"base45-web": "^1.0.2",
"cbor-web": "^9.0.2",
"pako": "^2.1.0",
"qrcode": "^1.5.3"
}
},
"node_modules/@mosip/secure-keystore": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/@mosip/secure-keystore/-/secure-keystore-0.1.7.tgz",
"integrity": "sha512-Yo9pCj1do8mKkwMkhRVbnf0cqOQaD3EJlMgcM8OyEedvB/dA5qQKJ2nDt7SkA+Rjnl1XHmvv6qAmLD1xuOD8kQ==",
"peerDependencies": {
"react": "*",
"react-native": "*"
}
},
"node_modules/@mosip/tuvali": {
"version": "0.4.9",
"resolved": "git+ssh://git@github.com/mosip/tuvali.git#1b7fb2575bead357da73f971aceb317e384be543",
@@ -10687,14 +10665,6 @@
"resolved": "https://registry.npmjs.org/canonicalize/-/canonicalize-1.0.8.tgz",
"integrity": "sha512-0CNTVCLZggSh7bc5VkX5WWPWO+cyZbNd07IHIsSXLia/eAq+r836hgk+8BKoEh7949Mda87VUOitx5OddVj64A=="
},
"node_modules/cbor-web": {
"version": "9.0.2",
"resolved": "https://registry.npmjs.org/cbor-web/-/cbor-web-9.0.2.tgz",
"integrity": "sha512-N6gU2GsJS8RR5gy1d9wQcSPgn9FGJFY7KNvdDRlwHfz6kCxrQr2TDnrjXHmr6TFSl6Fd0FC4zRnityEldjRGvQ==",
"engines": {
"node": ">=16"
}
},
"node_modules/chalk": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
@@ -33586,23 +33556,6 @@
}
}
},
"@mosip/pixelpass": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/@mosip/pixelpass/-/pixelpass-0.1.5.tgz",
"integrity": "sha512-4vVB9P54xDi9g+1fwBnD/9h97w/nm0J5RNKkN1L0gCqLdKzzPitehnCreZEhF0pN4uOBKDDwZsRKL5KdZVsFWg==",
"requires": {
"base45-web": "^1.0.2",
"cbor-web": "^9.0.2",
"pako": "^2.1.0",
"qrcode": "^1.5.3"
}
},
"@mosip/secure-keystore": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/@mosip/secure-keystore/-/secure-keystore-0.1.7.tgz",
"integrity": "sha512-Yo9pCj1do8mKkwMkhRVbnf0cqOQaD3EJlMgcM8OyEedvB/dA5qQKJ2nDt7SkA+Rjnl1XHmvv6qAmLD1xuOD8kQ==",
"requires": {}
},
"@mosip/tuvali": {
"version": "git+ssh://git@github.com/mosip/tuvali.git#1b7fb2575bead357da73f971aceb317e384be543",
"integrity": "sha512-220+zbZ3m9LOp2f3upeu500mOr3uxEdnnHvbHayzaZMsBEvK8D7/5UoXSF3OLRJZlZ/f4VKD7GKxMVlZ1thP3Q==",
@@ -37332,11 +37285,6 @@
"resolved": "https://registry.npmjs.org/canonicalize/-/canonicalize-1.0.8.tgz",
"integrity": "sha512-0CNTVCLZggSh7bc5VkX5WWPWO+cyZbNd07IHIsSXLia/eAq+r836hgk+8BKoEh7949Mda87VUOitx5OddVj64A=="
},
"cbor-web": {
"version": "9.0.2",
"resolved": "https://registry.npmjs.org/cbor-web/-/cbor-web-9.0.2.tgz",
"integrity": "sha512-N6gU2GsJS8RR5gy1d9wQcSPgn9FGJFY7KNvdDRlwHfz6kCxrQr2TDnrjXHmr6TFSl6Fd0FC4zRnityEldjRGvQ=="
},
"chalk": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",

View File

@@ -21,8 +21,6 @@
"@expo/metro-config": "~0.10.0",
"@invertase/react-native-apple-authentication": "^2.3.0",
"@iriscan/biometric-sdk-react-native": "0.2.6",
"@mosip/pixelpass": "^0.1.5",
"@mosip/secure-keystore": "^0.1.7",
"@mosip/tuvali": "git://github.com/mosip/tuvali.git#develop",
"@react-native-clipboard/clipboard": "^1.10.0",
"@react-native-community/netinfo": "9.3.7",

View File

@@ -1,7 +1,7 @@
import {KeyPair, RSA} from 'react-native-rsa-native';
import forge from 'node-forge';
import {BIOMETRIC_CANCELLED, DEBUG_MODE_ENABLED, isIOS} from '../constants';
import SecureKeystore from '@mosip/secure-keystore';
import { NativeModules } from 'react-native';
import {BiometricCancellationError} from '../error/BiometricCancellationError';
import {EncryptedOutput} from './encryptedOutput';
import {Buffer} from 'buffer';
@@ -21,6 +21,7 @@ export function generateKeys(): Promise<KeyPair> {
/**
* isCustomKeystore is a cached check of existence of a hardware keystore.
*/
const{RNSecureKeystoreModule}=NativeModules
export const isHardwareKeystoreExists = isCustomSecureKeystore();
export async function getJWT(
@@ -61,7 +62,7 @@ export async function createSignature(
return encodeB64(signature);
} else {
try {
signature64 = await SecureKeystore.sign(individualId, preHash);
signature64 = await RNSecureKeystoreModule.sign(individualId, preHash);
} catch (error) {
console.error('Error in creating signature:', error);
if (error.toString().includes(BIOMETRIC_CANCELLED)) {
@@ -90,7 +91,7 @@ export function encodeB64(str: string) {
* use the isCustomKeystore constant in the app lifeycle instead.
*/
function isCustomSecureKeystore() {
return !isIOS() ? SecureKeystore.deviceSupportsHardware() : false;
return !isIOS() ? RNSecureKeystoreModule.deviceSupportsHardware() : false;
}
export async function encryptJson(
@@ -107,7 +108,7 @@ export async function encryptJson(
return encryptWithForge(data, encryptionKey).toString();
}
const base64EncodedString = Buffer.from(data).toString('base64');
return await SecureKeystore.encryptData(ENCRYPTION_ID, base64EncodedString);
return await RNSecureKeystoreModule.encryptData(ENCRYPTION_ID, base64EncodedString);
} catch (error) {
console.error('error while encrypting:', error);
if (error.toString().includes(BIOMETRIC_CANCELLED)) {
@@ -135,7 +136,7 @@ export async function decryptJson(
return decryptWithForge(encryptedData, encryptionKey);
}
return await SecureKeystore.decryptData(ENCRYPTION_ID, encryptedData);
return await RNSecureKeystoreModule.decryptData(ENCRYPTION_ID, encryptedData);
} catch (e) {
console.error('error decryptJson:', e);

View File

@@ -4,7 +4,7 @@ import {
getFreeDiskStorageOldSync,
getFreeDiskStorageSync,
} from 'react-native-device-info';
import SecureKeystore from '@mosip/secure-keystore';
import { NativeModules } from 'react-native';
import {
decryptJson,
encryptJson,
@@ -33,6 +33,7 @@ import fileStorage from './fileStorage';
import {DocumentDirectoryPath, ReadDirItem} from 'react-native-fs';
export const MMKV = new MMKVLoader().initialize();
const{RNSecureKeystoreModule}=NativeModules
async function generateHmac(
encryptionKey: string,
@@ -41,7 +42,7 @@ async function generateHmac(
if (!isHardwareKeystoreExists) {
return hmacSHA(encryptionKey, data);
}
return await SecureKeystore.generateHmacSha(HMAC_ALIAS, data);
return await RNSecureKeystoreModule.generateHmacSha(HMAC_ALIAS, data);
}
class Storage {