node-firebird 1.1.9 → 2.0.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/node.js.yml +45 -10
- package/ENCRYPTION_CALLBACK.md +152 -0
- package/PR_SUMMARY.md +139 -0
- package/README.md +80 -17
- package/Roadmap.md +80 -0
- package/lib/index.d.ts +16 -2
- package/lib/index.js +1 -1
- package/lib/pool.js +83 -82
- package/lib/srp.js +3 -0
- package/lib/wire/connection.js +1639 -1295
- package/lib/wire/const.js +16 -10
- package/lib/wire/database.js +224 -118
- package/lib/wire/eventConnection.js +94 -92
- package/lib/wire/fbEventManager.js +107 -72
- package/lib/wire/serialize.js +434 -408
- package/lib/wire/service.js +935 -931
- package/lib/wire/socket.js +175 -0
- package/lib/wire/statement.js +32 -31
- package/lib/wire/transaction.js +135 -107
- package/lib/wire/xsqlvar.js +339 -330
- package/package.json +5 -5
- package/srp.js +94 -0
- package/vitest.config.js +13 -0
- package/.travis.yml +0 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-firebird",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Pure JavaScript and Asynchronous Firebird client for Node.js.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"firebird",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"homepage": "https://github.com/hgourvest/node-firebird",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "https://github.com/hgourvest/node-firebird"
|
|
14
|
+
"url": "git+https://github.com/hgourvest/node-firebird.git"
|
|
15
15
|
},
|
|
16
16
|
"author": {
|
|
17
17
|
"name": "Henri Gourvest",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"types": "./lib/index.d.ts",
|
|
26
26
|
"license": "MPL-2.0",
|
|
27
27
|
"scripts": {
|
|
28
|
-
"test": "
|
|
28
|
+
"test": "vitest run"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"big-integer": "^1.6.51",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"coveralls-next": "^4.2.0",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
36
|
+
"nyc": "^15.0.1",
|
|
37
|
+
"vitest": "^4.0.18"
|
|
38
38
|
}
|
|
39
39
|
}
|
package/srp.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const BigInteger = require('big-integer');
|
|
2
|
+
const crypto = require('crypto');
|
|
3
|
+
|
|
4
|
+
console.log('Preparing benchmark...');
|
|
5
|
+
|
|
6
|
+
// Constants from lib/srp.js
|
|
7
|
+
const HEX_N = 'E67D2E994B2F900C3F41F08F5BB2627ED0D49EE1FE767A52EFCD565CD6E768812C3E1E9CE8F0A8BEA6CB13CD29DDEBF7A96D4A93B55D488DF099A15C89DCB0640738EB2CBDD9A8F7BAB561AB1B0DC1C6CDABF303264A08D1BCA932D1F1EE428B619D970F342ABA9A65793B8B2F041AE5364350C16F735F56ECBCA87BD57B29E7';
|
|
8
|
+
const DEC_K = '1277432915985975349439481660349303019122249719989';
|
|
9
|
+
|
|
10
|
+
// --- Library Setup ---
|
|
11
|
+
const lib_N = BigInteger(HEX_N, 16);
|
|
12
|
+
const lib_g = BigInteger(2);
|
|
13
|
+
const lib_k = BigInteger(DEC_K);
|
|
14
|
+
|
|
15
|
+
// --- Native Setup ---
|
|
16
|
+
const native_N = BigInt('0x' + HEX_N);
|
|
17
|
+
const native_g = 2n;
|
|
18
|
+
const native_k = BigInt(DEC_K);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Native BigInt Modular Exponentiation
|
|
22
|
+
* Calculates (base ^ exp) % mod
|
|
23
|
+
*/
|
|
24
|
+
function nativeModPow(base, exp, mod) {
|
|
25
|
+
let result = 1n;
|
|
26
|
+
base = base % mod;
|
|
27
|
+
while (exp > 0n) {
|
|
28
|
+
if (exp & 1n) result = (result * base) % mod;
|
|
29
|
+
base = (base * base) % mod;
|
|
30
|
+
exp >>= 1n;
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// --- Test Data Generation ---
|
|
36
|
+
const ITERATIONS = 2000;
|
|
37
|
+
const inputs = [];
|
|
38
|
+
|
|
39
|
+
for (let i = 0; i < ITERATIONS; i++) {
|
|
40
|
+
// Generate random 32-byte private key (similar to SRP_KEY_SIZE)
|
|
41
|
+
const hex = crypto.randomBytes(32).toString('hex');
|
|
42
|
+
inputs.push({
|
|
43
|
+
lib: BigInteger(hex, 16),
|
|
44
|
+
native: BigInt('0x' + hex)
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// --- Verification ---
|
|
49
|
+
console.log('Verifying implementations match...');
|
|
50
|
+
const vLib = lib_g.modPow(inputs[0].lib, lib_N);
|
|
51
|
+
const vNative = nativeModPow(native_g, inputs[0].native, native_N);
|
|
52
|
+
|
|
53
|
+
if (vLib.toString(16) !== vNative.toString(16)) {
|
|
54
|
+
console.error('MISMATCH!');
|
|
55
|
+
console.error('Lib:', vLib.toString(16));
|
|
56
|
+
console.error('Nat:', vNative.toString(16));
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
console.log('Verification passed.');
|
|
60
|
+
|
|
61
|
+
// --- Benchmark ---
|
|
62
|
+
console.log(`\nStarting benchmark (${ITERATIONS} iterations)...`);
|
|
63
|
+
|
|
64
|
+
// 1. Library Benchmark
|
|
65
|
+
const startLib = process.hrtime.bigint();
|
|
66
|
+
for (let i = 0; i < ITERATIONS; i++) {
|
|
67
|
+
// Simulate: A = g^a % N
|
|
68
|
+
const A = lib_g.modPow(inputs[i].lib, lib_N);
|
|
69
|
+
|
|
70
|
+
// Simulate part of server calc: B = (k*v + g^b) % N
|
|
71
|
+
// We'll just do (k * A) % N + A to simulate the mix of mult/add/mod
|
|
72
|
+
const term = lib_k.multiply(A).mod(lib_N).add(A).mod(lib_N);
|
|
73
|
+
}
|
|
74
|
+
const endLib = process.hrtime.bigint();
|
|
75
|
+
|
|
76
|
+
// 2. Native Benchmark
|
|
77
|
+
const startNative = process.hrtime.bigint();
|
|
78
|
+
for (let i = 0; i < ITERATIONS; i++) {
|
|
79
|
+
// Simulate: A = g^a % N
|
|
80
|
+
const A = nativeModPow(native_g, inputs[i].native, native_N);
|
|
81
|
+
|
|
82
|
+
// Simulate part of server calc: B = (k*v + g^b) % N
|
|
83
|
+
const term = ((native_k * A) % native_N + A) % native_N;
|
|
84
|
+
}
|
|
85
|
+
const endNative = process.hrtime.bigint();
|
|
86
|
+
|
|
87
|
+
// --- Results ---
|
|
88
|
+
const timeLib = Number(endLib - startLib) / 1e6; // ms
|
|
89
|
+
const timeNative = Number(endNative - startNative) / 1e6; // ms
|
|
90
|
+
|
|
91
|
+
console.log('\nResults:');
|
|
92
|
+
console.log(`big-integer (Lib): ${timeLib.toFixed(2)} ms`);
|
|
93
|
+
console.log(`Native BigInt: ${timeNative.toFixed(2)} ms`);
|
|
94
|
+
console.log(`\nSpeedup: ${(timeLib / timeNative).toFixed(2)}x faster`);
|
package/vitest.config.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { defineConfig } = require('vitest/config');
|
|
2
|
+
|
|
3
|
+
module.exports = defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
globals: true,
|
|
6
|
+
testTimeout: 10000,
|
|
7
|
+
hookTimeout: 30000,
|
|
8
|
+
fileParallelism: false,
|
|
9
|
+
maxWorkers: 1,
|
|
10
|
+
isolate: false,
|
|
11
|
+
include: ['test/arc4.js', 'test/protocol.js', 'test/srp.js', 'test/service.js', 'test/utf8-user-identification.js', 'test/index.js', 'test/db-crypt-config.js'],
|
|
12
|
+
},
|
|
13
|
+
});
|
package/.travis.yml
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
language: node_js
|
|
2
|
-
|
|
3
|
-
node_js:
|
|
4
|
-
- lts/*
|
|
5
|
-
- v10
|
|
6
|
-
|
|
7
|
-
notifications:
|
|
8
|
-
email:
|
|
9
|
-
- mapopa@gmail.com
|
|
10
|
-
|
|
11
|
-
env:
|
|
12
|
-
- FIREBIRD_DATA="/var/lib/firebird/2.5/data"
|
|
13
|
-
|
|
14
|
-
before_install:
|
|
15
|
-
- sudo apt-get update -qq
|
|
16
|
-
- sudo DEBIAN_FRONTEND=noninteractive apt-get install -qq firebird2.5-superclassic
|
|
17
|
-
- sudo gsec -modify SYSDBA -pw masterkey
|
|
18
|
-
|
|
19
|
-
script:
|
|
20
|
-
- nyc npm test
|
|
21
|
-
|
|
22
|
-
after_script:
|
|
23
|
-
- nyc report --reporter=text-lcov | coveralls
|