mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-08 21:18:14 -05:00
* feat(INJI-473) - Removed unused injiTourGuide action. Signed-off-by: Swati Goel <meet2swati@gmail.com> * feat(INJI-473) - Removed unused logKey action. Signed-off-by: Swati Goel <meet2swati@gmail.com> * feat(INJI-473) - Removed unused backendInfo api and state. Signed-off-by: Swati Goel <meet2swati@gmail.com> * feat(INJI-473) - simplify isPasscodeSet logic. Signed-off-by: Swati Goel <meet2swati@gmail.com> * feat(INJI-473) - Move logState to commonUtil to remove cyclic dependency. Signed-off-by: Swati Goel <meet2swati@gmail.com> * feat(INJI-473) - Delete unused code. Signed-off-by: Swati Goel <meet2swati@gmail.com> * feat(INJI-473) - Refactor code to use util function for iOS or isAndroid. Signed-off-by: Swati Goel <meet2swati@gmail.com> * feat(INJI-473) - Move Issuers_Key_Ref into utils. Signed-off-by: Swati Goel <meet2swati@gmail.com> * feat(INJI-473) - Remove profile related resource from setting screen Signed-off-by: Swati Goel <meet2swati@gmail.com> * feat(INJI-473) - Remove unused code for locales. Signed-off-by: Swati Goel <meet2swati@gmail.com> --------- Signed-off-by: Swati Goel <meet2swati@gmail.com>
55 lines
1.3 KiB
TypeScript
55 lines
1.3 KiB
TypeScript
import {Platform} from 'react-native';
|
|
import argon2 from 'react-native-argon2';
|
|
import {AnyState} from 'xstate';
|
|
import {getDeviceNameSync} from 'react-native-device-info';
|
|
import {isAndroid} from './constants';
|
|
|
|
export const hashData = async (
|
|
data: string,
|
|
salt: string,
|
|
config: Argon2iConfig,
|
|
): Promise<string> => {
|
|
const result = await argon2(data, salt, config);
|
|
return result.rawHash as string;
|
|
};
|
|
|
|
export interface Argon2iConfig {
|
|
iterations: number;
|
|
memory: number;
|
|
parallelism: number;
|
|
hashLength: number;
|
|
mode: string;
|
|
}
|
|
|
|
export default function testIDProps(id) {
|
|
return isAndroid()
|
|
? {accessible: true, accessibilityLabel: id}
|
|
: {testID: id};
|
|
}
|
|
|
|
export const removeWhiteSpace = (str: string) => {
|
|
return str ? str.replace(/\s/g, '') : str;
|
|
};
|
|
|
|
export function logState(state: AnyState) {
|
|
const data = JSON.stringify(
|
|
state.event,
|
|
(key, value) => {
|
|
if (key === 'type') return undefined;
|
|
if (typeof value === 'string' && value.length >= 100) {
|
|
return value.slice(0, 100) + '...';
|
|
}
|
|
return value;
|
|
},
|
|
2,
|
|
);
|
|
console.log(
|
|
`[${getDeviceNameSync()}] ${state.machine.id}: ${
|
|
state.event.type
|
|
} -> ${state.toStrings().pop()}\n${
|
|
data.length > 300 ? data.slice(0, 300) + '...' : data
|
|
}
|
|
`,
|
|
);
|
|
}
|