Skip to content

Commit

Permalink
Merge pull request #331 from Mookiies/fixEncryptionTypings
Browse files Browse the repository at this point in the history
fix: Encryption typings
  • Loading branch information
ammarahm-ed authored Jul 6, 2023
2 parents e529f6b + a0ed862 commit 2aeabec
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/encryption.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Encrypt an already created instance of MMKV.
| cryptKey | no | String | Password to encrypt the storage |
| secureKeyStorage | no | boolean | Set to true of you want the library to store the password securely |
| alias | no | String | You can provide a custom alias for storage of password, by default instanceID is used |
| accessibleMode | no | IOSAccessibleStates | Choose the accessibility mode (iOS only) |

```js
import { MMKVLoader } from "react-native-mmkv-storage";
Expand Down Expand Up @@ -58,6 +59,7 @@ Change the encryption key of an encrypted instance of MMKV.
| cryptKey | yes | String | Password to encrypt the storage |
| secureKeyStorage | no | boolean | Set to true of you want the library to store the password securely |
| alias | no | String | You can provide a custom alias for storage of password, by default instanceID is used |
| accessibleMode | no | IOSAccessibleStates | Choose the accessibility mode (iOS only) |

```js
// Create an instance that is encrypted
Expand Down
6 changes: 3 additions & 3 deletions docs/loaderclass.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ Choose the accessibility mode for secure key storage (IOS ONLY);

**Arguments**

| Name | Required | Type | Description |
|------------|----------|------------------------|-------------------------------|
| accessible | yes | MMKVStorage.ACCESSIBLE | Choose the accessibility mode |
| Name | Required | Type | Description |
|------------|----------|----------------------|-------------------------------|
| accessible | yes | IOSAccessibleStates | Choose the accessibility mode |

```js
import { MMKVLoader, IOSAccessibleStates } from "react-native-mmkv-storage";
Expand Down
4 changes: 2 additions & 2 deletions src/encryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class encryption {
* @param accessibleMode Set accessible mode for secure storage on ios devices
* @returns An object with alias and key
*/
encrypt(key: string, secureKeyStorage = true, alias: string, accessibleMode: string) {
encrypt(key?: string, secureKeyStorage = true, alias?: string, accessibleMode?: string) {
if (accessibleMode) {
this.accessibleMode = accessibleMode;
}
Expand Down Expand Up @@ -108,7 +108,7 @@ export default class encryption {
* @param alias Provide a custom alias to store the key with in secure storage
* @param accessibleMode Set accessible mode for secure storage on ios devices
*/
changeEncryptionKey(key: string, secureKeyStorage = true, alias: string, accessibleMode: string) {
changeEncryptionKey(key: string, secureKeyStorage = true, alias?: string, accessibleMode?: string) {
return this.encrypt(key, secureKeyStorage, alias, accessibleMode);
}
}
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type StorageOptions = {
secureKeyStorage: boolean;
/**
* Set the AccessibleMode for iOS
* Import ACCESSIBLE from library to use it.
* Import IOSAccessibleStates from library to use it.
*/
accessibleMode: string;
/**
Expand Down

1 comment on commit 2aeabec

@vercel
Copy link

@vercel vercel bot commented on 2aeabec Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

rnmmkv – ./

rnmmkv-ammarahm-ed.vercel.app
rnmmkv-git-master-ammarahm-ed.vercel.app
rnmmkv.vercel.app

Please sign in to comment.