Skip to content

Commit

Permalink
fix: useSecureElement types
Browse files Browse the repository at this point in the history
  • Loading branch information
reime005 committed Dec 31, 2019
1 parent fb3e415 commit ffcc091
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useRef } from 'react';
import { useRef, MutableRefObject } from 'react';

import {
AndroidKeyGenOptions,
Expand All @@ -10,50 +10,50 @@ import {
import { SecureElement } from './SecureElement';

export const useSecureElement = () => {
const se: ISecureElement = useRef(new SecureElement());
const se: MutableRefObject<ISecureElement> = useRef(new SecureElement());

const encrypt = (
key: string,
value: string,
opts: AndroidKeyGenOptions | IOSKeyGenOptions,
): Promise<string | null> => {
return se.encrypt(key, value, opts);
return se.current.encrypt(key, value, opts);
};

const decrypt = (
key: string,
value: string,
opts: AndroidKeyGenOptions | IOSKeyGenOptions,
): Promise<string | null> => {
return se.encrypt(key, value, opts);
return se.current.encrypt(key, value, opts);
};

const clearElement = (
key: string, keyProvider: AndroidKeyGenProvider
): Promise<void> => {
return se.clearElement(key, keyProvider);
return se.current.clearElement(key, keyProvider);
};

const clearAll = (
keyProvider: AndroidKeyGenProvider
): Promise<void> => {
return se.clearAll(keyProvider);
return se.current.clearAll(keyProvider);
};

const isSecureDevice = (
): Promise<boolean> => {
return se.isSecureDevice();
return se.current.isSecureDevice();
};

const getDeviceFeatures = (
): Promise<DeviceFeature[]> => {
return se.getDeviceFeatures();
return se.current.getDeviceFeatures();
};

const performAuthentication = (
withFeature: DeviceFeature
): Promise<boolean> => {
return se.performAuthentication(withFeature);
return se.current.performAuthentication(withFeature);
};

return [
Expand Down

0 comments on commit ffcc091

Please sign in to comment.