encrypting and decrypting raw source code

This commit is contained in:
Rolands 2022-10-29 21:47:11 +03:00
parent 5431d37b33
commit fc12f68151
2 changed files with 13 additions and 1 deletions

View file

@ -14,6 +14,13 @@ cd ../demo
npm link ../core
```
## TODOs
* Backend Life-cycle hooks
* Session ID sync with backend webserver sessions
* Keyed SQL queries
* Better SQL dependency distinguisher on queries
* Bundler plugins for securing query strings
* Typescript migration
## Name:
"Socio.js" comes from the latin verb "socio", which means to link or associate. Since this lib syncs your frontend and backend. Its also a play on words for "WebSockets" and "IO".

View file

@ -12,8 +12,13 @@ export class Secure{
this.iv = te.encode(cipher_iv).slice(0, 16)
}
//sql strings must be in single quotes and have an sql single line comment at the end with the name socio - "--socio"
Secure(source_code = '') {
const sql_string_regex = /'(?<sql>[^']+?)--socio'/i
return source_code.split('\n').map(line => {
const m = line.match(sql_string_regex)
return m?.groups?.sql ? line.replace(sql_string_regex, '\'' + this.EncryptString(m.groups.sql) + '\'') : line
}).join('\n')
}
EncryptString(query = '') {