joystick icon indicating copy to clipboard operation
joystick copied to clipboard

Simple Data Encryption

Open rglover opened this issue 1 year ago • 0 comments

This has come to mind a few times. Goal would be to offer a simple API that developers could use to encrypt data before storing and when retrieving. Something like this:

import { encrypt } from '@joystick.js/node';

const setters = {
  update_profile: {
    set: (input = {}, context = {}) => {
      return process.databases.mongodb.collection('users').updateOne({
        _id: context?.user?._id,
      }, {
        $set: {
          mailing_address: encrypt(input?.mailing_address),
        },
      });
    }
  }
};

export default setters;

Internally, encrypt() would pull from something like config.encryption_key in the env settings, or, you could optionally pass an encryption key on the fly. This would give full control over encryption to developers while helping to keep data more secure.

rglover avatar Apr 18 '24 05:04 rglover