better-sqlite3-multiple-ciphers 7.4.5-beta.0 → 7.4.7-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/prebuild.yml +12 -0
- package/.github/workflows/test.yml +13 -0
- package/README.md +22 -15
- package/deps/setup.ps1 +1 -1
- package/deps/sqlite3.gyp +4 -0
- package/deps/sqlite3.tar.gz +0 -0
- package/docs/compilation.md +6 -6
- package/package.json +10 -10
- package/test/46.encryption.js +44 -11
|
@@ -35,3 +35,15 @@ jobs:
|
|
|
35
35
|
- run: apk add build-base git python3 --update-cache
|
|
36
36
|
- run: npm install --ignore-scripts
|
|
37
37
|
- run: npx --no-install prebuild -r node -t 10.20.0 -t 12.0.0 -t 14.0.0 -t 16.0.0 --include-regex 'better_sqlite3.node$' -u ${{ secrets.GITHUB_TOKEN }}
|
|
38
|
+
|
|
39
|
+
prebuild-alpine-arm64:
|
|
40
|
+
name: Prebuild on alpine (arm64)
|
|
41
|
+
runs-on: ubuntu-latest
|
|
42
|
+
steps:
|
|
43
|
+
- uses: docker/setup-qemu-action@v1
|
|
44
|
+
- run: |
|
|
45
|
+
docker run --rm --entrypoint /bin/sh --platform linux/arm64 node:16-alpine -c "apk add build-base git python3 --update-cache && \
|
|
46
|
+
git clone ${{ github.event.repository.clone_url }} && \
|
|
47
|
+
cd ${{ github.event.repository.name }} && \
|
|
48
|
+
npm install --ignore-scripts && \
|
|
49
|
+
npx --no-install prebuild -r node -t 10.20.0 -t 12.0.0 -t 14.0.0 -t 16.0.0 --include-regex 'better_sqlite3.node$' -u ${{ secrets.GITHUB_TOKEN }}"
|
|
@@ -44,3 +44,16 @@ jobs:
|
|
|
44
44
|
- run: npm install --ignore-scripts
|
|
45
45
|
- run: npm run build-debug
|
|
46
46
|
- run: npm test
|
|
47
|
+
|
|
48
|
+
test-alpine-arm64:
|
|
49
|
+
name: Testing Node 16 on apline (arm64)
|
|
50
|
+
runs-on: ubuntu-latest
|
|
51
|
+
steps:
|
|
52
|
+
- uses: docker/setup-qemu-action@v1
|
|
53
|
+
- run: |
|
|
54
|
+
docker run --rm --entrypoint /bin/sh --platform linux/arm64 node:16-alpine -c "apk add build-base git python3 --update-cache && \
|
|
55
|
+
git clone ${{ github.event.repository.clone_url }} && \
|
|
56
|
+
cd ${{ github.event.repository.name }} && \
|
|
57
|
+
npm install --ignore-scripts && \
|
|
58
|
+
npm run build-debug && \
|
|
59
|
+
npm test"
|
package/README.md
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
# better-sqlite3-multiple-ciphers
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<a href="https://www.npmjs.com/package/better-sqlite3-multiple-ciphers">
|
|
7
|
-
<img src="https://img.shields.io/npm/dt/better-sqlite3-multiple-ciphers?logo=DocuSign&logoColor=FFF&color=2757c4&style=for-the-badge" alt="Downloads">
|
|
8
|
-
</a>
|
|
9
|
-
|
|
10
|
-
####
|
|
3
|
+
[](https://www.npmjs.com/package/better-sqlite3-multiple-ciphers)
|
|
4
|
+
[](https://www.npmjs.com/package/better-sqlite3-multiple-ciphers)
|
|
5
|
+
[](https://github.com/m4heshd/better-sqlite3-multiple-ciphers/actions/workflows/test.yml)
|
|
11
6
|
|
|
12
7
|
The fastest and simplest library for SQLite3 in Node.js. This particular fork supports multiple-cipher encryption using [SQLite3MultipleCiphers](https://github.com/utelle/SQLite3MultipleCiphers). Check [usage](#usage) to learn more.
|
|
13
8
|
|
|
@@ -17,18 +12,19 @@ The fastest and simplest library for SQLite3 in Node.js. This particular fork su
|
|
|
17
12
|
- Support for user-defined functions, aggregates, virtual tables, and extensions
|
|
18
13
|
- 64-bit integers *(invisible until you need them)*
|
|
19
14
|
- Worker thread support *(for large/slow queries)*
|
|
15
|
+
- Encryption support using multiple algorithms
|
|
20
16
|
|
|
21
17
|
## Current versions
|
|
22
18
|
|
|
23
19
|
- ### Stable
|
|
24
|
-
- **better-sqlite3-multiple-ciphers** - `7.4.4
|
|
25
|
-
- **SQLite** - `3.
|
|
26
|
-
- **SQLite3 Multiple Ciphers** - `1.3.
|
|
20
|
+
- **better-sqlite3-multiple-ciphers** - [`7.4.6`](https://www.npmjs.com/package/better-sqlite3-multiple-ciphers/v/7.4.6)
|
|
21
|
+
- **SQLite** - `3.37.0`
|
|
22
|
+
- **SQLite3 Multiple Ciphers** - `1.3.5`
|
|
27
23
|
|
|
28
24
|
- ### Beta
|
|
29
|
-
- **better-sqlite3-multiple-ciphers** - [`7.4.
|
|
30
|
-
- **SQLite** - `3.
|
|
31
|
-
- **SQLite3 Multiple Ciphers** - `1.3.
|
|
25
|
+
- **better-sqlite3-multiple-ciphers** - [`7.4.7-beta.0`](https://www.npmjs.com/package/better-sqlite3-multiple-ciphers/v/7.4.7-beta.0)
|
|
26
|
+
- **SQLite** - `3.37.1`
|
|
27
|
+
- **SQLite3 Multiple Ciphers** - `1.3.6`
|
|
32
28
|
|
|
33
29
|
## Help this project stay strong! 💪
|
|
34
30
|
|
|
@@ -40,6 +36,10 @@ The fastest and simplest library for SQLite3 in Node.js. This particular fork su
|
|
|
40
36
|
|
|
41
37
|
Also head over to [SQLite3MultipleCiphers](https://github.com/utelle/SQLite3MultipleCiphers) repo and give some support to the developer to keep this very useful extension alive.
|
|
42
38
|
|
|
39
|
+
You can also support me (the maintainer of this fork) by buying me a coffee. 😊
|
|
40
|
+
|
|
41
|
+
[](https://ko-fi.com/m4heshd)
|
|
42
|
+
|
|
43
43
|
## How other libraries compare
|
|
44
44
|
|
|
45
45
|
| |select 1 row `get()` |select 100 rows `all()` |select 100 rows `iterate()` 1-by-1|insert 1 row `run()`|insert 100 rows in a transaction|
|
|
@@ -63,7 +63,7 @@ npm install better-sqlite3-multiple-ciphers
|
|
|
63
63
|
npm install better-sqlite3-multiple-ciphers@beta
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
> You must be using Node.js v10.20.1 or above. Prebuilt binaries are available for Node.js [LTS versions](https://nodejs.org/en/about/releases/) and Electron.
|
|
66
|
+
> You must be using Node.js v10.20.1 or above. Prebuilt binaries are available for Node.js [LTS versions](https://nodejs.org/en/about/releases/) and Electron. If you have trouble installing, check the [troubleshooting guide](./docs/troubleshooting.md).
|
|
67
67
|
|
|
68
68
|
> If you have trouble installing, check the [troubleshooting guide](./docs/troubleshooting.md).
|
|
69
69
|
|
|
@@ -76,6 +76,13 @@ const row = db.prepare('SELECT * FROM users WHERE id = ?').get(userId);
|
|
|
76
76
|
console.log(row.firstName, row.lastName, row.email);
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
+
##### In ES6 module notation:
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
import Database from 'better-sqlite3-multiple-ciphers';
|
|
83
|
+
const db = new Database('foobar.db', options);
|
|
84
|
+
```
|
|
85
|
+
|
|
79
86
|
### Encryption
|
|
80
87
|
|
|
81
88
|
A database can be encrypted and decrypted simply using `key` and `rekey` `PRAGMA` statements.
|
package/deps/setup.ps1
CHANGED
package/deps/sqlite3.gyp
CHANGED
package/deps/sqlite3.tar.gz
CHANGED
|
Binary file
|
package/docs/compilation.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# Custom configuration
|
|
2
2
|
|
|
3
|
-
If you want to use a customized version of [SQLite3](https://www.sqlite.org) with `better-sqlite3`, you can do so by specifying the directory of your [custom amalgamation](https://www.sqlite.org/amalgamation.html) during installation.
|
|
3
|
+
If you want to use a customized version of [SQLite3](https://www.sqlite.org) with `better-sqlite3-multiple-ciphers`, you can do so by specifying the directory of your [custom amalgamation](https://www.sqlite.org/amalgamation.html) during installation.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
npm install better-sqlite3 --build-from-source --sqlite3=/path/to/sqlite-amalgamation
|
|
6
|
+
npm install better-sqlite3-multiple-ciphers --build-from-source --sqlite3=/path/to/sqlite-amalgamation
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
However, if you simply run `npm install` while `better-sqlite3` is listed as a dependency in your `package.json`, the required flags above will *not* be applied. Therefore, it's recommended that you remove `better-sqlite3` from your dependency list, and instead add a [`preinstall` script](https://docs.npmjs.com/misc/scripts) like the one shown below.
|
|
9
|
+
However, if you simply run `npm install` while `better-sqlite3-multiple-ciphers` is listed as a dependency in your `package.json`, the required flags above will *not* be applied. Therefore, it's recommended that you remove `better-sqlite3-multiple-ciphers` from your dependency list, and instead add a [`preinstall` script](https://docs.npmjs.com/misc/scripts) like the one shown below.
|
|
10
10
|
|
|
11
11
|
```json
|
|
12
12
|
{
|
|
13
13
|
"scripts": {
|
|
14
|
-
"preinstall": "npm install better-sqlite3@'^7.0.0' --no-save --build-from-source --sqlite3=\"$(pwd)/sqlite-amalgamation\""
|
|
14
|
+
"preinstall": "npm install better-sqlite3-multiple-ciphers@'^7.0.0' --no-save --build-from-source --sqlite3=\"$(pwd)/sqlite-amalgamation\""
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
```
|
|
@@ -20,7 +20,7 @@ Your amalgamation directory must contain `sqlite3.c` and `sqlite3.h`. Any desire
|
|
|
20
20
|
|
|
21
21
|
### Step by step example
|
|
22
22
|
|
|
23
|
-
If you're creating a package that relies on a custom build of `better-sqlite3`, you can follow these steps to get started.
|
|
23
|
+
If you're creating a package that relies on a custom build of `better-sqlite3-multiple-ciphers`, you can follow these steps to get started.
|
|
24
24
|
|
|
25
25
|
1. Download the SQLite3 source code from [their website](https://sqlite.com/download.html) (e.g., `sqlite-amalgamation-1234567.zip`)
|
|
26
26
|
2. Unzip the compressed archive
|
|
@@ -34,7 +34,7 @@ If you're using a SQLite3 encryption extension that is a drop-in replacement for
|
|
|
34
34
|
|
|
35
35
|
# Bundled configuration
|
|
36
36
|
|
|
37
|
-
By default, this distribution currently uses SQLite3 **version 3.
|
|
37
|
+
By default, this distribution currently uses SQLite3 **version 3.37.1** with the following [compilation options](https://www.sqlite.org/compile.html):
|
|
38
38
|
|
|
39
39
|
```
|
|
40
40
|
SQLITE_DQS=0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-sqlite3-multiple-ciphers",
|
|
3
|
-
"version": "7.4.
|
|
3
|
+
"version": "7.4.7-beta.0",
|
|
4
4
|
"description": "better-sqlite3 with multiple-cipher encryption support",
|
|
5
5
|
"homepage": "https://github.com/m4heshd/better-sqlite3-multiple-ciphers",
|
|
6
6
|
"author": "Mahesh Bandara Wijerathna (m4heshd) <m4heshd@gmail.com>",
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
"download": "bash ./deps/download.sh",
|
|
36
36
|
"setup": "powershell ./deps/setup.ps1",
|
|
37
37
|
"lzz": "lzz -hx hpp -sx cpp -k BETTER_SQLITE3 -d -hl -sl -e ./src/better_sqlite3.lzz",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
38
|
+
"bump:patch": "npm --no-git-tag-version version patch",
|
|
39
|
+
"bump:minor": "npm --no-git-tag-version version minor",
|
|
40
|
+
"bump:major": "npm --no-git-tag-version version major",
|
|
41
|
+
"bump:patch:beta": "npm --no-git-tag-version --preid=beta version prepatch",
|
|
42
|
+
"bump:minor:beta": "npm --no-git-tag-version --preid=beta version preminor",
|
|
43
|
+
"bump:major:beta": "npm --no-git-tag-version --preid=beta version premajor",
|
|
44
|
+
"bump:prerelease:beta": "npm --no-git-tag-version --preid=beta version prerelease",
|
|
45
|
+
"release": "npm publish",
|
|
46
|
+
"release:beta": "npm publish --tag beta"
|
|
47
47
|
},
|
|
48
48
|
"license": "MIT",
|
|
49
49
|
"keywords": [
|
package/test/46.encryption.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const Database = require('../.');
|
|
3
3
|
|
|
4
|
-
describe('Encryption using default
|
|
4
|
+
describe('Encryption using default cipher (Sqleet)', () => {
|
|
5
5
|
afterEach(() => {
|
|
6
6
|
this.db.close();
|
|
7
7
|
});
|
|
@@ -17,16 +17,11 @@ describe('Encryption using default method (Sqleet)', () => {
|
|
|
17
17
|
this.db = new Database(util.current());
|
|
18
18
|
expect(() => this.db.prepare('SELECT * FROM user')).to.throw(Database.SqliteError);
|
|
19
19
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// it('should not allow access with an incorrect passphrase', () => {
|
|
26
|
-
// this.db = new Database(util.current());
|
|
27
|
-
// this.db.pragma(`key='false_passphrase'`);
|
|
28
|
-
// expect(() => this.db.prepare('SELECT * FROM user')).to.throw(Database.SqliteError);
|
|
29
|
-
// });
|
|
20
|
+
it('should not allow access with an incorrect passphrase', () => {
|
|
21
|
+
this.db = new Database(util.current());
|
|
22
|
+
this.db.pragma(`key='false_passphrase'`);
|
|
23
|
+
expect(() => this.db.prepare('SELECT * FROM user')).to.throw(Database.SqliteError);
|
|
24
|
+
});
|
|
30
25
|
it('should allow access with the correct passphrase', () => {
|
|
31
26
|
this.db = new Database(util.current());
|
|
32
27
|
this.db.pragma(`key='passphrase'`);
|
|
@@ -34,3 +29,41 @@ describe('Encryption using default method (Sqleet)', () => {
|
|
|
34
29
|
expect(stmt.get()).to.deep.equal({name: 'octocat'});
|
|
35
30
|
});
|
|
36
31
|
});
|
|
32
|
+
|
|
33
|
+
describe('Encryption using SQLCiper', () => {
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
this.db.close();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should create an encrypted database', () => {
|
|
39
|
+
this.db = new Database(util.next());
|
|
40
|
+
this.db.pragma(`cipher='sqlcipher'`);
|
|
41
|
+
this.db.pragma(`rekey='passphrase'`);
|
|
42
|
+
this.db.prepare('CREATE TABLE user ("name" TEXT)').run();
|
|
43
|
+
this.db.prepare("INSERT INTO user (name) VALUES ('octocat')").run();
|
|
44
|
+
this.db.prepare('VACUUM').run();
|
|
45
|
+
});
|
|
46
|
+
it('should not allow access without decryption', () => {
|
|
47
|
+
this.db = new Database(util.current());
|
|
48
|
+
this.db.pragma(`cipher='sqlcipher'`);
|
|
49
|
+
expect(() => this.db.prepare('SELECT * FROM user')).to.throw(Database.SqliteError);
|
|
50
|
+
});
|
|
51
|
+
it('should not allow access with an incorrect passphrase', () => {
|
|
52
|
+
this.db = new Database(util.current());
|
|
53
|
+
this.db.pragma(`cipher='sqlcipher'`);
|
|
54
|
+
this.db.pragma(`key='false_passphrase'`);
|
|
55
|
+
expect(() => this.db.prepare('SELECT * FROM user')).to.throw(Database.SqliteError);
|
|
56
|
+
});
|
|
57
|
+
it('should not allow access with a different cipher', () => {
|
|
58
|
+
this.db = new Database(util.current());
|
|
59
|
+
this.db.pragma(`key='passphrase'`);
|
|
60
|
+
expect(() => this.db.prepare('SELECT * FROM user')).to.throw(Database.SqliteError);
|
|
61
|
+
});
|
|
62
|
+
it('should allow access with the correct passphrase and cipher', () => {
|
|
63
|
+
this.db = new Database(util.current());
|
|
64
|
+
this.db.pragma(`cipher='sqlcipher'`);
|
|
65
|
+
this.db.pragma(`key='passphrase'`);
|
|
66
|
+
const stmt = this.db.prepare('SELECT * FROM user');
|
|
67
|
+
expect(stmt.get()).to.deep.equal({name: 'octocat'});
|
|
68
|
+
});
|
|
69
|
+
});
|