Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for asynchronous encrypt/decrypt functions in afterSerialization and beforeSerialization #69

Open
jwh-hutchison opened this issue Feb 24, 2021 · 0 comments

Comments

@jwh-hutchison
Copy link

inside my datastore configuration:

  afterSerialization: async (data) => {
    const payload = await data;
    console.log('E1: ', payload);

    const encrypted = await encryptData(payload);
    console.log('E2: ', encrypted);
    return encrypted;
  },
  beforeDeserialization: async (data) => {
    const payload = await data;
    console.log('D1: ', payload);

    const decrypted = await decryptData(payload);
    console.log('D2: ', decrypted);
    return decrypted;
  },

gives me:

Error: beforeDeserialization is not the reverse of afterSerialization, cautiously refusing to start NeDB to prevent dataloss
E1:  W
E2:  FuoRfmMKynBFuOOLrEBhSw==
D1:  FuoRfmMKynBFuOOLrEBhSw==
D2:  W

it appears that the encryption/decryption will not work if they are asynchronous functions, it would be good to support this because all the good AES crypto libraries on react-native are asynchronous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant