Add Typescript definitions and adapt callback interface fixed to match de facto usage (#38)
This commit is contained in:
parent
dad6421045
commit
fd8663a8ec
4
index.js
4
index.js
|
@ -38,7 +38,7 @@ var Keychain = {
|
|||
*/
|
||||
getInternetCredentials: function(
|
||||
server: string,
|
||||
callback?: ?(error: ?Error, result: ?string) => void
|
||||
callback?: ?(error: ?Error, username: ?string, password: ?string) => void
|
||||
): Promise {
|
||||
return new Promise((resolve, reject) => {
|
||||
RNKeychainManager.getInternetCredentialsForServer(server, function(err, username, password) {
|
||||
|
@ -110,7 +110,7 @@ var Keychain = {
|
|||
*/
|
||||
getGenericPassword: function(
|
||||
service?: string,
|
||||
callback?: ?(error: ?Error, result: ?string) => void
|
||||
callback?: ?(error: ?Error, username: ?string, password: ?string) => void
|
||||
): Promise {
|
||||
return new Promise((resolve, reject) => {
|
||||
RNKeychainManager.getGenericPasswordForService(service, function(err, username, password) {
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
"bugs": {
|
||||
"url": "https://github.com/oblador/react-native-keychain/issues"
|
||||
},
|
||||
"typescript": {
|
||||
"definition": "typings/react-native-keychain.d.ts"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/oblador/react-native-keychain.git"
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
declare module 'react-native-keychain' {
|
||||
|
||||
export interface UserCredentials {
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
function setInternetCredentials(
|
||||
server: string,
|
||||
username: string,
|
||||
password: string,
|
||||
callback?: (error?: Error) => void
|
||||
): Promise<void>;
|
||||
|
||||
function getInternetCredentials(
|
||||
server: string,
|
||||
callback?: (error?: Error, username?: string, password?: string) => void
|
||||
): Promise<UserCredentials>;
|
||||
|
||||
function resetInternetCredentials(
|
||||
server: string,
|
||||
callback?: (error?: Error) => void
|
||||
): Promise<void>;
|
||||
|
||||
function setGenericPassword(
|
||||
username: string,
|
||||
password: string,
|
||||
service?: string,
|
||||
callback?: (error?: Error) => void
|
||||
): Promise<void>;
|
||||
|
||||
|
||||
function getGenericPassword(
|
||||
service?: string,
|
||||
callback?: (error?: Error, result?: string) => void
|
||||
): Promise<void>;
|
||||
|
||||
function resetGenericPassword (
|
||||
service?: string,
|
||||
callback?: (error?: Error) => void
|
||||
): Promise<void>;
|
||||
|
||||
}
|
Loading…
Reference in New Issue