better-sqlite3-multiple-ciphers 7.4.7-beta.0 → 7.5.1-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/README.md +8 -6
- package/deps/download.sh +111 -108
- package/deps/setup.ps1 +10 -12
- package/deps/sqlite3/sqlite3.c +272560 -0
- package/deps/sqlite3/sqlite3.h +12770 -0
- package/deps/sqlite3/sqlite3ext.h +675 -0
- package/deps/sqlite3.gyp +17 -7
- package/deps/symlink.js +7 -4
- package/lib/database.js +17 -6
- package/lib/sqlite-error.js +1 -2
- package/package.json +11 -5
- package/src/better_sqlite3.cpp +46 -35
- package/src/better_sqlite3.hpp +40 -38
- package/.gitattributes +0 -1
- package/.github/workflows/prebuild.yml +0 -49
- package/.github/workflows/test.yml +0 -59
- package/benchmark/benchmark.js +0 -31
- package/benchmark/drivers.js +0 -21
- package/benchmark/index.js +0 -83
- package/benchmark/seed.js +0 -47
- package/benchmark/trials.js +0 -65
- package/benchmark/types/insert.js +0 -16
- package/benchmark/types/select-all.js +0 -14
- package/benchmark/types/select-iterate.js +0 -23
- package/benchmark/types/select.js +0 -14
- package/benchmark/types/transaction.js +0 -40
- package/deps/extract.js +0 -16
- package/deps/sqlite3.tar.gz +0 -0
- package/docs/api.md +0 -645
- package/docs/benchmark.md +0 -38
- package/docs/compilation.md +0 -76
- package/docs/integer.md +0 -79
- package/docs/performance.md +0 -39
- package/docs/threads.md +0 -97
- package/docs/tips.md +0 -35
- package/docs/troubleshooting.md +0 -23
- package/docs/unsafe.md +0 -16
- package/src/better_sqlite3.lzz +0 -88
- package/src/objects/backup.lzz +0 -138
- package/src/objects/database.lzz +0 -468
- package/src/objects/statement-iterator.lzz +0 -138
- package/src/objects/statement.lzz +0 -323
- package/src/util/bind-map.lzz +0 -73
- package/src/util/binder.lzz +0 -190
- package/src/util/constants.lzz +0 -151
- package/src/util/custom-aggregate.lzz +0 -121
- package/src/util/custom-function.lzz +0 -59
- package/src/util/custom-table.lzz +0 -397
- package/src/util/data-converter.lzz +0 -17
- package/src/util/data.lzz +0 -145
- package/src/util/macros.lzz +0 -159
- package/src/util/query-macros.lzz +0 -71
- package/test/00.setup.js +0 -25
- package/test/01.sqlite-error.js +0 -27
- package/test/10.database.open.js +0 -159
- package/test/11.database.close.js +0 -68
- package/test/12.database.pragma.js +0 -65
- package/test/13.database.prepare.js +0 -60
- package/test/14.database.exec.js +0 -46
- package/test/20.statement.run.js +0 -170
- package/test/21.statement.get.js +0 -109
- package/test/22.statement.all.js +0 -129
- package/test/23.statement.iterate.js +0 -223
- package/test/24.statement.bind.js +0 -107
- package/test/25.statement.columns.js +0 -46
- package/test/30.database.transaction.js +0 -157
- package/test/31.database.checkpoint.js +0 -62
- package/test/32.database.function.js +0 -211
- package/test/33.database.aggregate.js +0 -603
- package/test/34.database.table.js +0 -671
- package/test/35.database.load-extension.js +0 -75
- package/test/36.database.backup.js +0 -240
- package/test/37.database.serialize.js +0 -81
- package/test/40.bigints.js +0 -145
- package/test/41.at-exit.js +0 -52
- package/test/42.integrity.js +0 -531
- package/test/43.verbose.js +0 -100
- package/test/44.worker-threads.js +0 -66
- package/test/45.unsafe-mode.js +0 -52
- package/test/46.encryption.js +0 -69
- package/test/50.misc.js +0 -44
package/test/45.unsafe-mode.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const Database = require('../.');
|
|
3
|
-
|
|
4
|
-
describe('Database#unsafeMode()', function () {
|
|
5
|
-
beforeEach(function () {
|
|
6
|
-
this.db = new Database(util.next());
|
|
7
|
-
this.db.exec('create table foo (x)');
|
|
8
|
-
this.read = this.db.prepare('select 5');
|
|
9
|
-
this.write = this.db.prepare('insert into foo values (0)');
|
|
10
|
-
});
|
|
11
|
-
afterEach(function () {
|
|
12
|
-
this.db.close();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('should not allow unsafe operations by default', function () {
|
|
16
|
-
let hadRow = false;
|
|
17
|
-
for (const row of this.read.iterate()) {
|
|
18
|
-
expect(() => this.write.run()).to.throw(TypeError);
|
|
19
|
-
expect(() => this.db.exec('select 5')).to.throw(TypeError);
|
|
20
|
-
expect(() => this.db.pragma('cache_size')).to.throw(TypeError);
|
|
21
|
-
hadRow = true;
|
|
22
|
-
}
|
|
23
|
-
expect(hadRow).to.be.true;
|
|
24
|
-
|
|
25
|
-
this.db.pragma('journal_mode = OFF');
|
|
26
|
-
this.db.pragma('writable_schema = ON');
|
|
27
|
-
expect(this.db.pragma('journal_mode', { simple: true })).to.equal('delete');
|
|
28
|
-
expect(() => this.db.exec("update sqlite_master set name = 'bar' where name = 'foo'")).to.throw(Database.SqliteError);
|
|
29
|
-
});
|
|
30
|
-
it('should allow unsafe operations when toggled on', function () {
|
|
31
|
-
this.db.unsafeMode();
|
|
32
|
-
|
|
33
|
-
let hadRow = false;
|
|
34
|
-
for (const row of this.read.iterate()) {
|
|
35
|
-
this.write.run();
|
|
36
|
-
this.db.exec('select 5');
|
|
37
|
-
this.db.pragma('cache_size');
|
|
38
|
-
hadRow = true;
|
|
39
|
-
}
|
|
40
|
-
expect(hadRow).to.be.true;
|
|
41
|
-
|
|
42
|
-
this.db.pragma('journal_mode = OFF');
|
|
43
|
-
this.db.pragma('writable_schema = ON');
|
|
44
|
-
expect(this.db.pragma('journal_mode', { simple: true })).to.equal('off');
|
|
45
|
-
this.db.exec("update sqlite_master set name = 'bar' where name = 'foo'");
|
|
46
|
-
|
|
47
|
-
this.db.unsafeMode(false);
|
|
48
|
-
expect(() => this.db.exec("update sqlite_master set name = 'foo' where name = 'bar'")).to.throw(Database.SqliteError);
|
|
49
|
-
this.db.unsafeMode(true);
|
|
50
|
-
this.db.exec("update sqlite_master set name = 'foo' where name = 'bar'");
|
|
51
|
-
});
|
|
52
|
-
});
|
package/test/46.encryption.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const Database = require('../.');
|
|
3
|
-
|
|
4
|
-
describe('Encryption using default cipher (Sqleet)', () => {
|
|
5
|
-
afterEach(() => {
|
|
6
|
-
this.db.close();
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it('should create an encrypted database', () => {
|
|
10
|
-
this.db = new Database(util.next());
|
|
11
|
-
this.db.pragma(`rekey='passphrase'`);
|
|
12
|
-
this.db.prepare('CREATE TABLE user ("name" TEXT)').run();
|
|
13
|
-
this.db.prepare("INSERT INTO user (name) VALUES ('octocat')").run();
|
|
14
|
-
this.db.prepare('VACUUM').run();
|
|
15
|
-
});
|
|
16
|
-
it('should not allow access without decryption', () => {
|
|
17
|
-
this.db = new Database(util.current());
|
|
18
|
-
expect(() => this.db.prepare('SELECT * FROM user')).to.throw(Database.SqliteError);
|
|
19
|
-
});
|
|
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
|
-
});
|
|
25
|
-
it('should allow access with the correct passphrase', () => {
|
|
26
|
-
this.db = new Database(util.current());
|
|
27
|
-
this.db.pragma(`key='passphrase'`);
|
|
28
|
-
const stmt = this.db.prepare('SELECT * FROM user');
|
|
29
|
-
expect(stmt.get()).to.deep.equal({name: 'octocat'});
|
|
30
|
-
});
|
|
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
|
-
});
|
package/test/50.misc.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const Database = require('../.');
|
|
3
|
-
|
|
4
|
-
describe('miscellaneous', function () {
|
|
5
|
-
beforeEach(function () {
|
|
6
|
-
this.db = new Database(util.next());
|
|
7
|
-
});
|
|
8
|
-
afterEach(function () {
|
|
9
|
-
this.db.close();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('persists non-trivial quantities of reads and writes', function () {
|
|
13
|
-
const runDuration = 1000;
|
|
14
|
-
const runUntil = Date.now() + runDuration;
|
|
15
|
-
this.slow(runDuration * 10);
|
|
16
|
-
this.timeout(runDuration * 3);
|
|
17
|
-
this.db.pragma("journal_mode = WAL");
|
|
18
|
-
this.db.prepare("CREATE TABLE foo (a INTEGER, b TEXT, c REAL)").run();
|
|
19
|
-
|
|
20
|
-
let i = 1;
|
|
21
|
-
const r = 0.141592654;
|
|
22
|
-
const insert = this.db.prepare("INSERT INTO foo VALUES (?, ?, ?)");
|
|
23
|
-
const insertMany = this.db.transaction((count) => {
|
|
24
|
-
for (const end = i + count; i < end; ++i) {
|
|
25
|
-
expect(insert.run(i, String(i), i + r))
|
|
26
|
-
.to.deep.equal({ changes: 1, lastInsertRowid: i });
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// Batched transactions of 100 inserts.
|
|
31
|
-
while (Date.now() < runUntil) insertMany(100);
|
|
32
|
-
|
|
33
|
-
// Expect 10K~50K on reasonable machines.
|
|
34
|
-
expect(i).to.be.above(1000);
|
|
35
|
-
|
|
36
|
-
const select = this.db.prepare("SELECT * FROM foo ORDER BY a DESC");
|
|
37
|
-
for (const row of select.iterate()) {
|
|
38
|
-
i -= 1;
|
|
39
|
-
expect(row).to.deep.equal({ a: i, b: String(i), c: i + r });
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
expect(i).to.equal(1);
|
|
43
|
-
});
|
|
44
|
-
});
|