[expo] Add types for SecureStore keychain item accessibility constants (#31840)

* [expo] Add types for SecureStore constants

* add use of keychainService; improve options types for getItemAsync and deleteItemAsync; test all SecureStore constants
This commit is contained in:
Jason Killian
2019-01-06 11:07:43 -08:00
committed by Sheetal Nandi
parent f1762ec1a7
commit 3ad75fac4d
2 changed files with 38 additions and 1 deletions
+25
View File
@@ -47,6 +47,7 @@ import {
Region,
registerRootComponent,
ScreenOrientation,
SecureStore,
Svg,
Updates
} from 'expo';
@@ -484,6 +485,30 @@ async () => {
isString(queryParams2['y'] || '');
};
// #region securestore
async () => {
await SecureStore.setItemAsync('some-key', 'some-val', {
keychainService: "some-service",
keychainAccessible: SecureStore.WHEN_PASSCODE_SET_THIS_DEVICE_ONLY,
});
const result = await SecureStore.getItemAsync('some-key', { keychainService: "some-service" });
if (result != null) {
result.slice() === 'some-val';
}
await SecureStore.deleteItemAsync('some-key', { keychainService: "some-service" });
};
const allSecureStoreKeychainAccessibleValues: number[] = [
SecureStore.WHEN_UNLOCKED,
SecureStore.AFTER_FIRST_UNLOCK,
SecureStore.ALWAYS,
SecureStore.WHEN_UNLOCKED_THIS_DEVICE_ONLY,
SecureStore.WHEN_PASSCODE_SET_THIS_DEVICE_ONLY,
SecureStore.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY,
SecureStore.ALWAYS_THIS_DEVICE_ONLY,
];
// #endregion
() => (
<Svg width={100} height={50}>
<Svg.Rect
+13 -1
View File
@@ -14,6 +14,7 @@
// Levan Basharuli <https://github.com/levansuper>
// Pavel Ihm <https://github.com/ihmpavel>
// Bartosz Dotryw <https://github.com/burtek>
// Jason Killian <https://github.com/jkillian>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@@ -2301,12 +2302,23 @@ export namespace ScreenOrientation {
export namespace SecureStore {
interface SecureStoreOptions {
keychainService?: string;
}
interface SecureStoreSetOptions extends SecureStoreOptions {
keychainAccessible?: number;
}
function setItemAsync(key: string, value: string, options?: SecureStoreOptions): Promise<void>;
function setItemAsync(key: string, value: string, options?: SecureStoreSetOptions): Promise<void>;
function getItemAsync(key: string, options?: SecureStoreOptions): Promise<string | null>;
function deleteItemAsync(key: string, options?: SecureStoreOptions): Promise<void>;
const WHEN_UNLOCKED: number;
const AFTER_FIRST_UNLOCK: number;
const ALWAYS: number;
const WHEN_UNLOCKED_THIS_DEVICE_ONLY: number;
const WHEN_PASSCODE_SET_THIS_DEVICE_ONLY: number;
const AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY: number;
const ALWAYS_THIS_DEVICE_ONLY: number;
}
/**