sqlite3 wasm docs

The SQLite Encryption Extension (SEE)
Login

The JavaScript/WASM build can be created using a copy of the SQLite Encryption Extension (SEE), but doing so comes with some caveats:

Creating an SEE-capable WASM Build

Creating an SEE-capable build is identical to the canonical builds except for one detail: when invoking make we have to tell it which sqlite3.c to use:

$ make sqlite3.c=/path/to/sqlite3-see.c  # needs to be an absolute path

See the canonical builds for info about the various build targets, optimization levels, and descriptions of the build's output files.

Assuming all goes well, the output of the build will start with something like:

$ make
using emcc version [4.0.12]
This is an SEE build.
...

If that "SEE" line (or something equivalent) does not appear, the build is not SEE-capable. It is also possible to inspect the resulting JS sources to determine whether it's an SEE build:

$ grep -w sqlite3_key_v2 jswasm/sqlite3.js

If that produces any output then the resulting build is SEE-capable.

When alternating between SEE- and non-SEE builds it is necessary to run make distclean between each build, followed by re-running configure from the top of the tree, to ensure that the version information which gets baked into the JS files is pulled from the proper copy of sqlite3.c.

Using the SEE Build

The SEE build is used identically to the main distribution, but also includes the various sqlite3 API functions related to encryption, such as sqlite3_key_v2(). Those functions are not required for using encryption, as each such API is also accessible via pragmas, as documented in the SEE docs. The existence of the SEE-specific functions in a JS/WASM build can be used to distinguish it from a non-SEE build.

As of version 3.46, the oo1 API supports SEE in the form of an optional argument to the constructors of the DB class and its subclasses.