DefinitelyTyped/types/react-native-keychain/react-native-keychain-tests.ts
David Andre Evans Farinha 4df7adcb42 Creating type definitions for "react-native-keychain" (#25419)
* Creating type definitions for "react-native-keychain"

* Updating index.d.ts to include Promise<string> on getGenericPassword()

* Fixing all tslint and dts-lint errors and issues.

* Removing duplicate "Definitions by"

* Updating index.d.ts, improving tests.

-Updating index.d.ts to include type definitions for canImplyAuthentication and getSupportedBiometryType.
-Updating index.d.ts to fix type definitions for setInternetCredentials and resetGenericPassword.
-Adding full type test coverage to all exposed methods on react-native-keychain.

* Updating type definitions for setGenericPassword, getGenericPassword.

-Updating index.d.ts to update type definitions for setGenericPassword, getGenericPassword.
-Updating type definition tests to reflect new type definition updates.

* Updating type definitions for setGenericPassword

-Updating index.d.ts to include correct setGenericPassword parameter types.
2018-05-07 07:51:22 -07:00

40 lines
1.5 KiB
TypeScript

import * as Keychain from 'react-native-keychain';
async () => {
const username = 'username';
const password = 'password';
const service: string | undefined = "test.service";
const server = "test.server";
const serviceOrOptions: string | Keychain.Options | undefined = {};
const options: Keychain.Options = {};
const keychainServicePassword: boolean | {
service: string;
username: string;
password: string;
} = await Keychain.getGenericPassword(service);
const keychainPassword: boolean | {
service: string;
username: string;
password: string;
} = await Keychain.getGenericPassword();
const keychainServerPassword: Keychain.UserCredentials = await Keychain.getInternetCredentials(server);
const keychainSharedWebPassword: Keychain.SharedWebCredentials = await Keychain.requestSharedWebCredentials();
const keychainResetGenericPassword: boolean = await Keychain.resetGenericPassword(serviceOrOptions);
const keychainSetGenericPassword: boolean = await Keychain.setGenericPassword(username, password, options);
const keychainSetServerPassword: boolean = await Keychain.setInternetCredentials(server, username, password, serviceOrOptions);
const keychainSetSharedWebPassword: boolean = await Keychain.setSharedWebCredentials(server, username, password);
const canImplyAuthentication: boolean = await Keychain.canImplyAuthentication(serviceOrOptions);
const supportedBiometryType: string | null = await Keychain.getSupportedBiometryType();
};