dou
dou15mo ago

How to obfuscate data via transformer

End user with adequate knowledge can easily copy JSON data in plain text from network requests in browser dev tools. I'd like to make copying JSON data a bit more difficult for these advance users. Looks like obfuscation needs to be done in transformer. Does anyone have ideas how to implement obfuscation along with superjson within transformer?
import { uneval } from 'devalue';
import superjson from 'superjson';

export const transformer = {
input: superjson,
output: {
serialize: (object) => uneval(object),
deserialize: (object) => eval(`(${object})`),
},
};
import { uneval } from 'devalue';
import superjson from 'superjson';

export const transformer = {
input: superjson,
output: {
serialize: (object) => uneval(object),
deserialize: (object) => eval(`(${object})`),
},
};
2 Replies
Nick
Nick15mo ago
Write your own transformer which wraps superjson and base64 encodes everything What also whhhyyyy, obfuscation is not security, it's just spending your time making debugging harder for yourself
dou
douOP15mo ago
So true 👍 After digging into type info of tRPC transformer and superjson, it seems quite an quite easy job to do obfuscation 😅

Did you find this page helpful?