From 914f8e9d99fdd13f0f4d1447f5e461b3d4508ffc Mon Sep 17 00:00:00 2001 From: Rolands Date: Sun, 8 Jan 2023 14:24:22 +0200 Subject: [PATCH] doc upd --- README.md | 4 ++-- core/README.md | 4 ++-- core/docs.md | 14 +++++++++++++- demos/full-stack_framework/src/hooks.server.ts | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 29c6c8d..52fdc71 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,8 @@ function QueryWrap({ id = undefined, sql = '', params = undefined }:QueryFuncPar //do whatever u need to run the sql on your DB and return its result } -const socsec = new SocioSecurity({ secure_private_key: '...', cipher_iv: '...', verbose:true }) //for decrypting incoming queries -const socserv = new SocioServer({ port: 3000 }, QueryWrap as QueryFunction, { verbose: true, secure: socsec }); //creates localhost:3000 web socket server +const socsec = new SocioSecurity({ secure_private_key: '...', verbose:true }); //for decrypting incoming queries +const socserv = new SocioServer({ port: 3000 }, QueryWrap as QueryFunction, { verbose: true, socio_security: socsec }); //creates localhost:3000 web socket server ``` ```ts diff --git a/core/README.md b/core/README.md index 847725a..2039237 100644 --- a/core/README.md +++ b/core/README.md @@ -38,8 +38,8 @@ function QueryWrap({ id = undefined, sql = '', params = undefined }:QueryFuncPar //do whatever u need to run the sql on your DB and return its result } -const socsec = new SocioSecurity({ secure_private_key: '...', cipher_iv: '...', verbose:true }) //for decrypting incoming queries -const socserv = new SocioServer({ port: 3000 }, QueryWrap as QueryFunction, { verbose: true, secure: socsec }); //creates localhost:3000 web socket server +const socsec = new SocioSecurity({ secure_private_key: '...', verbose:true }); //for decrypting incoming queries +const socserv = new SocioServer({ port: 3000 }, QueryWrap as QueryFunction, { verbose: true, socio_security: socsec }); //creates localhost:3000 web socket server ``` ```ts diff --git a/core/docs.md b/core/docs.md index 466a9c2..163da86 100644 --- a/core/docs.md +++ b/core/docs.md @@ -83,7 +83,19 @@ const success = sc.authenticate({username:'Bob', password:'pass123'}) //success ``` -### Setup of ``SocioSecurityPlugin`` +### Setup of ``SocioSecurity`` and ``SocioSecurityPlugin`` + +```ts +//server code - can be in express or SvelteKit's hooks.server.ts/js file or whatever way you have of running server side code once. +import { SocioServer } from 'socio/core.js' +import type { SocioSession } from 'socio/core-session.js' +import { SocioSecurity } from 'socio/secure'; + +//vite plugin and this instance must share the same private secret key, so perhaps use .env mechanism +const socsec = new SocioSecurity({ secure_private_key: 'skk#$U#Y$7643GJHKGDHJH#$K#$HLI#H$KBKDBDFKU34534', verbose: true }); +const socserv = new SocioServer({ port: ws_port }, QueryWrap as QueryFunction, { verbose: true, socio_security: socsec }); +//by default ecrypts all strings that end with the socio marker, but decryption can be individually turned off for either sql or prop key strings. +``` ```ts //vite.config.ts in a SvelteKit project diff --git a/demos/full-stack_framework/src/hooks.server.ts b/demos/full-stack_framework/src/hooks.server.ts index 33626bc..18432a9 100644 --- a/demos/full-stack_framework/src/hooks.server.ts +++ b/demos/full-stack_framework/src/hooks.server.ts @@ -28,7 +28,7 @@ try{ return (await sequelize.query(sql, { logging: false, raw: true, replacements: params }))[0]; } - const socsec = new SocioSecurity({ secure_private_key: 'skk#$U#Y$7643GJHKGDHJH#$K#$HLI#H$KBKDBDFKU34534', verbose: true }) + const socsec = new SocioSecurity({ secure_private_key: 'skk#$U#Y$7643GJHKGDHJH#$K#$HLI#H$KBKDBDFKU34534', verbose: true }); const socserv = new SocioServer({ port: ws_port }, QueryWrap as QueryFunction, { verbose: true, socio_security: socsec }); done(`Created SocioServer on port`, ws_port);