You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: upgrade bundled SQLCipher and restore source-build fallback
- update the vendored SQLCipher amalgamation to 4.14.0 / SQLite 3.51.3
- add required SQLCipher init/shutdown build defines
- switch macOS builds from vendored OpenSSL to CommonCrypto
- restore runtime fallback from prebuilt binaries to local source builds
- publish the native sources needed for downstream rebuilds
- reduce published binaries to N-API 6 and trim legacy CI/docs
Copy file name to clipboardExpand all lines: README.md
+21-20Lines changed: 21 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
1
Fork of [node-sqlite3](https://github.com/mapbox/node-sqlite3), modified to use [SQLCipher](https://www.zetetic.net/sqlcipher/).
2
2
3
-
While the `node-sqlite3` project does include support for compiling against sqlcipher, it requires manual work, and does not work out-of-the-box on Electron on Windows. This fork changes the default configuration to bundle SQLCipher directly, as well as OpenSSL where required.
3
+
This fork bundles SQLCipher directly and now supports rebuilding from source again when no matching prebuilt binary is available.
4
4
5
5
## Supported platforms
6
6
7
-
Binaries are built against N-API 3 and 6, on MacOS, Windows (ia32 and x64) and Linux (x64).
7
+
Published binaries are built against N-API 6.
8
8
9
-
Node 10+ and Electron 6+ is supported.
9
+
Older N-API 3 binaries are no longer published.
10
10
11
-
Other platforms/architectures may work by building from source - see the section below.
11
+
If no matching binary is available for your platform or runtime, the published package includes the native sources needed to rebuild from source.
12
12
13
13
# Installation
14
14
@@ -49,25 +49,27 @@ db.close();
49
49
50
50
# SQLCipher
51
51
52
-
A copy of the source for SQLCipher 4.4.2 is bundled, which is based on SQLite 3.33.0.
52
+
A copy of the source for SQLCipher 4.14.0 is bundled, which is based on SQLite 3.51.3.
53
53
54
54
## Building from source.
55
55
56
-
Building from source when installing the package is only supported up to version 5.2.0.
56
+
Building from source when installing the package is supported again.
57
57
58
-
The two pre-built versions (N-API 3 and N-API 6) cover all electron and node versions, so building from source should
59
-
not be required.
58
+
The published tarball includes `binding.gyp`, `deps/`, and `src/` so that `npm install --build-from-source`, `node-gyp rebuild`, and rebuild tools such as `electron-rebuild` can compile the addon when needed.
59
+
60
+
Platform notes:
61
+
62
+
1. macOS uses SQLCipher's CommonCrypto provider via `Security.framework` and does not require Homebrew `openssl@1.1`.
63
+
2. Linux links against the system `libcrypto`.
64
+
3. Windows release binaries continue to use vendored static OpenSSL artifacts from `deps/`.
60
65
61
66
## Usage with electron-forge / electron-rebuild
62
67
63
-
[electron-forge](https://www.electronforge.io/) uses [electron-rebuild](https://github.com/electron/electron-rebuild) and attempts to rebuild this library from source by default, in a way
64
-
that is _not_ compatible with the way `node-pre-gyp` is used here.
68
+
[electron-forge](https://www.electronforge.io/) uses [electron-rebuild](https://github.com/electron/electron-rebuild) and will rebuild native modules from source by default.
69
+
70
+
That rebuild path is now supported by the published package. If a matching prebuilt binary exists you can still skip rebuilding this module to speed up install times, but it is no longer required as a workaround.
65
71
66
-
The workaround is to disable the rebuilding:
67
-
1. If using Electron 11+, use a node version that supports N-API 6+ (v10.20.0+ / v12.17.0+ / v14.0.0).
68
-
2. After `npm install` / `yarn install`, make sure that the folder `node_modules/@journeyapps/sqlcipher/lib/binding/napi-v6-linux-x64` exists.
69
-
If not, check the previous step again, remove the `node_modules` folder, and try again.
70
-
3. Disable rebuilding of this library using the `onlyModules` option of `electron-rebuild` in your `package.json`:
72
+
To skip rebuilding when a matching prebuilt binary is already present, disable rebuilding of this library using the `onlyModules` option of `electron-rebuild` in your `package.json`:
71
73
72
74
"config": {
73
75
"forge": {
@@ -77,18 +79,17 @@ The workaround is to disable the rebuilding:
77
79
}
78
80
}
79
81
80
-
Note: [electron-builder](https://www.electron.build/) does not appear to have this issue, and should work directly.
81
-
Similarly, using electron directly should just work, but do check that a compatible node version is used (see above).
82
+
Note: [electron-builder](https://www.electron.build/) should continue to work directly.
82
83
83
84
## OpenSSL
84
85
85
86
SQLCipher depends on OpenSSL.
86
87
87
-
For Windows, we bundle OpenSSL 1.1.1i. Binaries are generated using [vckpg](https://github.com/microsoft/vcpkg) (e.g., `.\vcpkg\vcpkg install openssl:x64-windows-static`).
88
+
On macOS we use CommonCrypto instead of a vendored OpenSSL build.
88
89
89
-
On Mac we bundle OpenSSL 1.1.1l.
90
+
On Linux we dynamically link against the system OpenSSL / `libcrypto`.
90
91
91
-
On Linux we dynamically link against the system OpenSSL.
92
+
For Windows release binaries we keep static OpenSSL artifacts in `deps/`. These can be refreshed with [vcpkg](https://github.com/microsoft/vcpkg) via `deps/openssl-windows.bat`.
cp sqlite3.c sqlite3.h shell.c sqlite3ext.h VERSION sqlcipher-amalgamation-$VERSION/
18
15
```
19
16
20
-
The above produces 4 files of interest:
17
+
The build produces the files we vendor in `deps/sqlcipher-amalgamation`:
21
18
22
19
```
23
20
sqlite3.c
@@ -27,33 +24,31 @@ sqlite3ext.h
27
24
VERSION # rename to VERSION.txt
28
25
```
29
26
30
-
Copy these files to:`deps/sqlcipher-amalgamation`.
27
+
Copy these files into`deps/sqlcipher-amalgamation`, renaming `VERSION` to `VERSION.txt`.
31
28
32
29
## Step 2: Get OpenSSL libraries
33
30
34
-
NodeJS typically includes OpenSSL. However, to support Electron, we statically link against libcrypto from OpenSSL.
31
+
macOS no longer vendors OpenSSL in this repository. It uses SQLCipher's CommonCrypto provider through `Security.framework`.
32
+
33
+
Linux links against the system `libcrypto`.
34
+
35
+
Windows release binaries still vendor static OpenSSL artifacts because they are needed at compile time for rebuilds and published prebuilds.
35
36
36
-
Run the following commands to generate the latest OpenSSL libs for Windows:
37
+
Run the following command on Windows to regenerate the vendored headers and static libraries:
37
38
38
39
```
39
40
cd deps
40
41
.\openssl-windows.bat
41
42
```
42
43
43
-
... this will output the libs in `deps/` (OpenSSL-WinXX), including the header files in `deps/openssl-include`. Every arch-specific folder includes these binaries:
44
-
45
-
```
46
-
libcrypto.lib
47
-
libssl.lib
48
-
ossl_static.pdb
49
-
```
44
+
This will refresh the files in `deps/OpenSSL-Win32`, `deps/OpenSSL-Win64`, `deps/OpenSSL-Win64-ARM`, and `deps/openssl-include`.
If you want to verify the source-build fallback path specifically, temporarily move the matching prebuilt binary out of `lib/binding/` and rerun the tests.
61
+
65
62
66
63
# Notes
67
64
68
-
The OpenSSL files are specifically required for Electron, which doesn't bundle OpenSSL like NodeJS does. The header and .lib files are required at compile-time. We bundle a statically-linked version of OpenSSL with the library, so the user does not need to manually install OpenSSL.
65
+
This repository now builds SQLCipher with:
66
+
67
+
*`SQLITE_HAS_CODEC`
68
+
*`SQLITE_EXTRA_INIT=sqlcipher_extra_init`
69
+
*`SQLITE_EXTRA_SHUTDOWN=sqlcipher_extra_shutdown`
70
+
*`SQLITE_TEMP_STORE=2`
69
71
70
72
`deps/sqlite3.gyp` has been modified from the original node-sqlite3 one to:
71
-
* Use the bundled OpenSSL on Windows and MacOS.
73
+
* Use CommonCrypto on macOS.
74
+
* Use the vendored Windows OpenSSL headers and static libraries for Windows release binaries.
72
75
* Add additional define statements required by SQLCipher.
0 commit comments