Application
Storing Data
Using Encrypted Storage
ToDesktop's @todesktop/client-core API provides access to methods for safely encrypting and decrypting strings on the user's local machine:
For a complete example, here's how we could go about saving login credentials for future use within a simple HTML form:
Using Local Storage
You can also use local storage to persist data.
For example, a common pattern in SaaS apps is to give each customer a unique subdomain. By default second-level domains are considered internal to your application. (For more info see Defining Internal URLs below)
Say you have your customers login at https://login.yourapp.com which then redirects them to https://yourcustomer.yourapp.com. You can store the last used subdomain in local storage and redirect your users there when they open the app.
When constructing URLs from stored data, validate the data to ensure it matches expected patterns before using it. See our security best practices for more tips.
We recommend having a separate javascript app for all of your ToDesktop specific login and importing that conditionally when your app is running as a desktop app.