question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[iOS] Add a new delegate RNCAsyncStorageCryptoDelegate to support encryption/decryption

See original GitHub issue

Motivation

There are some cases where the data at rest must be encrypted (for e.g. to honor enterprise policies etc). Currently, if someone wants to store encrypted data using AsyncStorage they must encrypt it on the JS side before calling AsyncStorage. This is not the most ideal in terms of performance and this approach won’t be able to take advantage of the encryption libraries/capabilities already included in the native app.

Description

The proposal here is to introduce a new delegate RNCAsyncStorageCryptoDelegate for performing crypto operations. This delegate is optional and will not be implemented by default but it gives developers the option to build encryption/decryption capabilities for AsyncStorage.

New feature implementation

The new delegate will have the following methods:

-(NSString *)encryptValue:(NSString *)value;
-(NSString *)decryptValue:(NSString *)value;

encryptValue will be called for all values just before they are written into the file and decryptValue will be called right after a value has been read from the file, before it is returned to the JS side.

Please share your thoughts and suggestions on this. I am happy to create a PR to implement this.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
krizzucommented, Sep 15, 2020

I understood your proposal, but still, this goes out of scope for this library. There is a delegate that you can implement for brownfield integration, so you could add encryption/decryption there to meet your use case? Otherwise I’m afraid you’ll have to maintain your own fork for that feature

0reactions
tido64commented, Sep 19, 2020

I think what @Krizzu suggests makes sense. Encryption is not the responsibility of this library, and we already have a generic delegate you can implement to provide the capabilities you need. Your delegate could encrypt the value before data gets stored on disk, and similarly decrypt the data on retrieval. You’ll have to handle data storage yourself, but on iOS you can use either NSUserDefaults or Core Data or even write to plain files on disk depending on your scenario.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UIApplicationDelegate | Apple Developer Documentation
Retrieves the configuration data for UIKit to use when creating a new scene. ... Tells the delegate that the user closed one or...
Read more >
Receive messages in an Apple app - Firebase - Google
You must set the UNUserNotificationCenter delegate and implement the appropriate delegate methods to ... Receive displayed notifications for iOS 10 devices.
Read more >
Apple Pay | Stripe Documentation
Allow customers to securely make payments using Apple Pay on their iPhone, iPad, and Apple Watch. Supported devices. Refer to Apple's compatibility ...
Read more >
Integrate Cast Into Your iOS App - Google Developers
This developer guide describes how to add Google Cast support to your iOS ... also a good place to set up a logging...
Read more >
How to add an AppDelegate to a SwiftUI app
How to add an AppDelegate to a SwiftUI app. Paul Hudson @twostraws December 1st 2022. Updated for Xcode 14.1. SwiftUI apps launch using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found