react-native-keychain
Advanced tools
Comparing version 9.2.0 to 9.2.1
@@ -82,3 +82,3 @@ "use strict"; | ||
function setGenericPassword(username, password, serviceOrOptions) { | ||
const options = (0, _normalizeOptions.normalizeStorageOptions)((0, _normalizeOptions.normalizeServiceOption)(serviceOrOptions)); | ||
const options = (0, _normalizeOptions.normalizeOptions)(serviceOrOptions); | ||
return RNKeychainManager.setGenericPasswordForOptions(options, username, password); | ||
@@ -194,3 +194,3 @@ } | ||
function setInternetCredentials(server, username, password, options) { | ||
return RNKeychainManager.setInternetCredentialsForServer(server, username, password, options ? (0, _normalizeOptions.normalizeStorageOptions)(options) : {}); | ||
return RNKeychainManager.setInternetCredentialsForServer(server, username, password, (0, _normalizeOptions.normalizeOptions)(options)); | ||
} | ||
@@ -197,0 +197,0 @@ |
@@ -18,3 +18,3 @@ "use strict"; | ||
function normalizeStorageOptions(options) { | ||
if (options.storage && options.storage === _enums.STORAGE_TYPE.AES) { | ||
if ('storage' in options && options.storage === _enums.STORAGE_TYPE.AES) { | ||
console.warn(`You passed 'AES' as a storage option to one of the react-native-keychain functions. | ||
@@ -52,6 +52,6 @@ This way of passing storage is deprecated and will be removed in a future major.`); | ||
function normalizeOptions(serviceOrOptions) { | ||
const options = { | ||
const options = normalizeStorageOptions({ | ||
authenticationPrompt: AUTH_PROMPT_DEFAULTS, | ||
...normalizeServiceOption(serviceOrOptions) | ||
}; | ||
}); | ||
const { | ||
@@ -58,0 +58,0 @@ authenticationPrompt |
@@ -5,3 +5,3 @@ "use strict"; | ||
import { ACCESSIBLE, ACCESS_CONTROL, AUTHENTICATION_TYPE, SECURITY_LEVEL, SECURITY_RULES, STORAGE_TYPE, BIOMETRY_TYPE } from "./enums.js"; | ||
import { normalizeOptions, normalizeServerOption, normalizeServiceOption, normalizeStorageOptions } from "./normalizeOptions.js"; | ||
import { normalizeOptions, normalizeServerOption, normalizeServiceOption } from "./normalizeOptions.js"; | ||
const { | ||
@@ -26,3 +26,3 @@ RNKeychainManager | ||
export function setGenericPassword(username, password, serviceOrOptions) { | ||
const options = normalizeStorageOptions(normalizeServiceOption(serviceOrOptions)); | ||
const options = normalizeOptions(serviceOrOptions); | ||
return RNKeychainManager.setGenericPasswordForOptions(options, username, password); | ||
@@ -138,3 +138,3 @@ } | ||
export function setInternetCredentials(server, username, password, options) { | ||
return RNKeychainManager.setInternetCredentialsForServer(server, username, password, options ? normalizeStorageOptions(options) : {}); | ||
return RNKeychainManager.setInternetCredentialsForServer(server, username, password, normalizeOptions(options)); | ||
} | ||
@@ -141,0 +141,0 @@ |
@@ -10,3 +10,3 @@ "use strict"; | ||
export function normalizeStorageOptions(options) { | ||
if (options.storage && options.storage === STORAGE_TYPE.AES) { | ||
if ('storage' in options && options.storage === STORAGE_TYPE.AES) { | ||
console.warn(`You passed 'AES' as a storage option to one of the react-native-keychain functions. | ||
@@ -44,6 +44,6 @@ This way of passing storage is deprecated and will be removed in a future major.`); | ||
export function normalizeOptions(serviceOrOptions) { | ||
const options = { | ||
const options = normalizeStorageOptions({ | ||
authenticationPrompt: AUTH_PROMPT_DEFAULTS, | ||
...normalizeServiceOption(serviceOrOptions) | ||
}; | ||
}); | ||
const { | ||
@@ -50,0 +50,0 @@ authenticationPrompt |
@@ -1,7 +0,7 @@ | ||
import type { AuthenticationPrompt, BaseOptions, SetOptions } from './types'; | ||
import type { AuthenticationPrompt, BaseOptions, GetOptions, SetOptions } from './types'; | ||
export declare const AUTH_PROMPT_DEFAULTS: AuthenticationPrompt; | ||
export declare function normalizeStorageOptions(options: SetOptions): SetOptions; | ||
export declare function normalizeStorageOptions(options: SetOptions | GetOptions): SetOptions; | ||
export declare function normalizeServiceOption(serviceOrOptions?: string | BaseOptions): BaseOptions; | ||
export declare function normalizeServerOption(serverOrOptions?: string | BaseOptions): BaseOptions; | ||
export declare function normalizeOptions(serviceOrOptions?: string | SetOptions): SetOptions; | ||
export declare function normalizeOptions(serviceOrOptions?: string | SetOptions | GetOptions): SetOptions | GetOptions; | ||
//# sourceMappingURL=normalizeOptions.d.ts.map |
@@ -53,2 +53,13 @@ import type { ACCESS_CONTROL, ACCESSIBLE, AUTHENTICATION_TYPE, SECURITY_LEVEL, SECURITY_RULES, STORAGE_TYPE } from './enums'; | ||
storage?: STORAGE_TYPE; | ||
/** Authentication prompt details or a title string. | ||
* @default | ||
* ```json | ||
* { | ||
* "title": "Authenticate to retrieve secret", | ||
* "cancel": "Cancel" | ||
* } | ||
* ``` | ||
* | ||
*/ | ||
authenticationPrompt?: string | AuthenticationPrompt; | ||
} & BaseOptions & AccessControlOption; | ||
@@ -55,0 +66,0 @@ /** Base options for keychain functions. */ |
{ | ||
"name": "react-native-keychain", | ||
"version": "9.2.0", | ||
"version": "9.2.1", | ||
"description": "Keychain Access for React Native", | ||
@@ -5,0 +5,0 @@ "main": "./lib/commonjs/index.js", |
@@ -25,3 +25,2 @@ import { NativeModules, Platform } from 'react-native'; | ||
normalizeServiceOption, | ||
normalizeStorageOptions, | ||
} from './normalizeOptions'; | ||
@@ -50,5 +49,3 @@ | ||
): Promise<false | Result> { | ||
const options = normalizeStorageOptions( | ||
normalizeServiceOption(serviceOrOptions) | ||
); | ||
const options = normalizeOptions(serviceOrOptions); | ||
return RNKeychainManager.setGenericPasswordForOptions( | ||
@@ -185,3 +182,3 @@ options, | ||
password, | ||
options ? normalizeStorageOptions(options) : {} | ||
normalizeOptions(options) | ||
); | ||
@@ -188,0 +185,0 @@ } |
import { STORAGE_TYPE } from './enums'; | ||
import type { AuthenticationPrompt, BaseOptions, SetOptions } from './types'; | ||
import type { | ||
AuthenticationPrompt, | ||
BaseOptions, | ||
GetOptions, | ||
SetOptions, | ||
} from './types'; | ||
@@ -10,4 +15,6 @@ // Default authentication prompt options | ||
export function normalizeStorageOptions(options: SetOptions): SetOptions { | ||
if (options.storage && options.storage === STORAGE_TYPE.AES) { | ||
export function normalizeStorageOptions( | ||
options: SetOptions | GetOptions | ||
): SetOptions { | ||
if ('storage' in options && options.storage === STORAGE_TYPE.AES) { | ||
console.warn( | ||
@@ -55,8 +62,9 @@ `You passed 'AES' as a storage option to one of the react-native-keychain functions. | ||
export function normalizeOptions( | ||
serviceOrOptions?: string | SetOptions | ||
): SetOptions { | ||
const options = { | ||
serviceOrOptions?: string | SetOptions | GetOptions | ||
): SetOptions | GetOptions { | ||
const options = normalizeStorageOptions({ | ||
authenticationPrompt: AUTH_PROMPT_DEFAULTS, | ||
...normalizeServiceOption(serviceOrOptions), | ||
}; | ||
}); | ||
const { authenticationPrompt } = options; | ||
@@ -63,0 +71,0 @@ |
@@ -63,2 +63,13 @@ import type { | ||
storage?: STORAGE_TYPE; | ||
/** Authentication prompt details or a title string. | ||
* @default | ||
* ```json | ||
* { | ||
* "title": "Authenticate to retrieve secret", | ||
* "cancel": "Cancel" | ||
* } | ||
* ``` | ||
* | ||
*/ | ||
authenticationPrompt?: string | AuthenticationPrompt; | ||
} & BaseOptions & | ||
@@ -65,0 +76,0 @@ AccessControlOption; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
274084
2238