Going directly to the DB from the client doesn't sound as a good idea from a security point of view. How do you protect connection strings on the client?
BLAZOR + STORAGE TABLES = TRUE SERVERLESS (UNLIMITED SCALABILITY)
Blazor Web Assembly is a True Client Application, EVERYTHING is done in the Client Side, SCALABILITY is UNLIMITED! period.
But.......
Everything you do in Azure Functions can be done in Blazor at the client level, but When I try to do that I get "System.Security.Cryptography" API not suported on Blazor Web Assembly.
I could not imagine the Potencial that Blazor could directly call Databases. (without going to azure functions). True Serverless, unlimited Scalability!!!
How can I do that?, How can I circumvent this issue?
I was thinking to get SQLlite source code and add two functions, one function will produce a Token, and after that every request for insert, select, update and delete will required a token, that will be checked. I believe that will be a very popular database for Blazor web assembly developers.
But then I will need to install a Cryptography packet on Blazor web Assembly, that may not exist.
Anyone can give me any suggestions or guidance on this?
Thanks in Advance,
Pablo Arthur Rodger.
2 answers
Sort by: Most helpful
-
-
Bruce (SqlWork.com) 58,936 Reputation points
2021-11-16T18:59:16.797+00:00 You can not do what you want.
please note that Blazor client (or any WASM) runs in a sandbox and can not access the network, filesystem, timer or true thread support (WASM is single threaded). For example HttpClient uses javascript interop to make a network call.
the only local database you can access is one hosted by the browser. you access this via Javascript interop. You can create a C# wrapper for this:
https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
just as there are javascript databases that use local storage (see polyfil for above), you could write one in C# that was in-memory only and used local storage via javascript as a backing store. You could write a WASM database in C/C++, Rust, etc and load in its own WASM. You would need a javascript wrapper to load, and perform I/o and communications to javascript or other WASMs
the issue with a crypto library with Blazor client is the management of the keys. You can call a javascript crypto routine or find a standalone C# version.
note: SQLite is the most common database library used to implement IndexDB api. The storage is tied to the site, just like cookie storage.