GithubHelp home page GithubHelp logo

l15k4 / scalajs-rx-idb Goto Github PK

View Code? Open in Web Editor NEW
9.0 4.0 2.0 104 KB

DBMS for IndexedDB engine, based on Rx principles (type safety, resilience, backpressure, user friendly (reduces all Idb CRUD features to 4 API methods)

License: MIT License

Scala 100.00%
legacy-code

scalajs-rx-idb's Issues

enable structured cloning

Any class that extends js.Any can be serialised to IndexDB, as pointed out by @sjrd on the scalajs mailing list Structured Cloning thread.

upickle is quite inefficient regarding structured cloning at present, and is problematic for serialising special objects like opaque objects produced by WebCrypto: see issue 127 of upickle and issue #3 in this rep. It seems unlikely that upickle will be changed soon to change that, as it would require quite a lot of rewrite of the macro library, which is not easy to do.

One answer is to only allow JS classes to be serialised to disk, that is classes that extend js.Any. That would reduce the dependence on upickle, and make the code a lot simpler. For a programmer that may mean building special classes for serialisation or writing a mapper to map scala classes (ie. ones that do not extend js.Any) The programmer could then choose what library to use: upickle being in many cases a very good choice.

saving CryptoKeyPair

Hi I need to use IndexDB to save a CryptoKeyPair which I am in the process of submitting a patch to org.scalajs.dom for.

Before I spend a lot of time setting everything up, I wanted to make sure I could save a pure JS object using scalajs-rx-idb. Reading your README I can't tell if you only save case classes. This is a particular object because if you make it setting extractable to false in the generateKey method as here:

GlobalCrypto.crypto.subtle.generateKey(
       RsaHashedKeyGenParams("RSASSA-PKCS1-v1_5",
         2048,
         new BigInteger(js.Array[Short](1, 0, 1)), //65537
         HashAlgorithm.`SHA-256`).asInstanceOf[KeyAlgorithmIdentifier],
      false, // <---- setting extractable to false
      js.Array(KeyUsage.sign)
    )

Then I think the private key is not readable.

While access to the underlying cryptographic key material may be restricted, based upon the extractable attribute, once a key is shared with a destination origin, the source origin can not later restrict or revoke access to the key.

This blog post "Saving Cryptographic Keys in the Browser" explains that one has to save them in IndexDB:

Because CryptoKey objects are opaque they can’t be placed in localStorage, which only supports simple types. Instead the key store will use IndexedDB, which can clone and store opaque variables. IndexedDB is more complex than localStorage, so dealing with it will be take up much of this post.

If this is possible it might be worth adding that to the README. I know it's a pretty unusual case, but that is why I thought I'd ask.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.