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.

How to update the secretKey async

See original GitHub issue

On app load, I want to do the following:

  1. Check expo-secure-store async for a previous stored encryption secret key
  2. If it doesn’t exist, create a random uuid and save it in expo-secure-store async and use it as the secret key for encryption
  3. If it does exist, use it as the secret key for encryption

However, because this process is async, I don’t see how to export the store and persistor.

const persistConfig = {
  key: 'root',
  version: 2,
  storage: FSStorage(),
  transforms: [
    encryptTransform({
      secretKey: 'my-super-secret-key',
      onError: function (error) {
        // Handle the error.
      },
    }),
  ],
};

export const store = configureStore({
  reducer: rootReducer,
  enhancers: [autoRehydrate()]
});

export const persistor = persistStore(store, persistConfig);

Does anyone have an example of how to update the secretKey after the app has loaded, without hard-coding it?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

1reaction
keval2605commented, Jun 15, 2022

@ou2s can you provide the example for this asap.

1reaction
ou2scommented, Apr 11, 2022

@rueiwoqp @gczene @andreaslydemann I’ve managed to do this. I think I will provide a more detailed example soon but for the moment, here are the guidelines:

  1. Make your configureStore function async
  2. Do not render the Provider until store creation is finished by putting the configureStore method in a useEffet at the root of your app.
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to pass headers in axios as secret-key - Stack Overflow
REACT_APP_LOCAL_URL; const fetchPhotosFlocal = async () => { const response = await axios.get(localUrl, { headers: { "secret-key": secretKey ...
Read more >
Azure Key Vault Secrets client library for Python
Set a secret; Retrieve a secret; Update secret metadata; Delete a secret; List secrets; Asynchronously create a secret; Asynchronously list ...
Read more >
tweetnacl-async - npm
nacl.sign.keyPair.fromSecretKey(secretKey). Returns a signing key pair with public key corresponding to the given 64-byte secret key. The secret ...
Read more >
Crypto | Node.js v19.3.0 Documentation
const { createHmac } = await import('node:crypto'); const secret = 'abcdefg'; const hash = createHmac('sha256', secret) .update('I love cupcakes') ...
Read more >
Securing Node.js RESTful APIs with JSON Web Tokens(JWT ...
Securing Node.js RESTful APIs with JSON Web Tokens(JWT) using Async-await. Published Jul 18, 2018Last updated Jun 28, 2021. Securing Node.js RESTful APIs ...
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