saghul / txiki.js

A tiny JavaScript runtime
MIT License
2.55k stars 171 forks source link

support indexedDB implement #385

Open calvin2021y opened 1 year ago

calvin2021y commented 1 year ago

can add indexedDB implement into txiki.js ?

saghul commented 1 year ago

What would it be backed by?

calvin2021y commented 1 year ago

sqlite or levelDB ?

saghul commented 1 year ago

One SQLite is added to the core indexedDB could potentially be shimmed.

saghul commented 1 year ago

SQLite support landed: https://github.com/saghul/txiki.js/pull/395

jimmywarting commented 1 year ago

Think we first need to impl structural clone that can clone complex object to/from arraybuffers or something first. IndexedDB can contain complex types such as TypedArrays Blobs circular refs Object literals regex and much more.

If i remember correctly chrome used sqlite + cbor for storing stuff in? or maybe it was their own impl. of v8.serialize/deserialize... don't remember.

saghul commented 1 year ago

For structuredClone support please follow https://github.com/quickjs-ng/quickjs/issues/16

Once we have it in QuickJS we can update here.

bnoordhuis commented 1 year ago

or maybe it was their own impl. of v8.serialize/deserialize...

I think it's this (or was, at least). I earned a $15k bug bounty last year for a bug in the deserializer that was exploitable across sandboxes. /tangent

saghul commented 4 months ago

For structuredClone support please follow quickjs-ng/quickjs#16

Once we have it in QuickJS we can update here.

FYI, I added structuredClone here. It's pretty small, so I could port it to QuickJS, but in order to be correct we'd need DOMException, which I'm a bit more in doubt about, plus the version we'd ship doesn't work for other clonable things QuickJS doesn't have...

Anyway, if someone wants to give it a try, all the ducks should be in a row now :-)