node-firebird 2.3.4 → 2.4.1

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.
Files changed (109) hide show
  1. package/README.md +574 -20
  2. package/lib/callback.d.ts +20 -0
  3. package/lib/callback.js +6 -16
  4. package/lib/firebird.msg.json +1370 -1370
  5. package/lib/gdscodes.d.ts +1519 -1520
  6. package/lib/gdscodes.js +5 -5
  7. package/lib/ieee754-decimal.d.ts +38 -0
  8. package/lib/ieee754-decimal.js +71 -118
  9. package/lib/index.d.ts +37 -338
  10. package/lib/index.js +97 -86
  11. package/lib/messages.d.ts +6 -0
  12. package/lib/messages.js +135 -162
  13. package/lib/pool.d.ts +23 -0
  14. package/lib/pool.js +34 -47
  15. package/lib/srp.d.ts +51 -0
  16. package/lib/srp.js +62 -72
  17. package/lib/types.d.ts +375 -0
  18. package/lib/types.js +22 -0
  19. package/lib/unix-crypt.d.ts +1 -0
  20. package/lib/unix-crypt.js +126 -152
  21. package/lib/utils.d.ts +16 -0
  22. package/lib/utils.js +24 -48
  23. package/lib/wire/connection.d.ts +100 -0
  24. package/lib/wire/connection.js +1029 -1009
  25. package/lib/wire/const.d.ts +567 -0
  26. package/lib/wire/const.js +620 -599
  27. package/lib/wire/database.d.ts +57 -0
  28. package/lib/wire/database.js +111 -108
  29. package/lib/wire/eventConnection.d.ts +16 -0
  30. package/lib/wire/eventConnection.js +29 -31
  31. package/lib/wire/fbEventManager.d.ts +45 -0
  32. package/lib/wire/fbEventManager.js +38 -57
  33. package/lib/wire/serialize.d.ts +97 -0
  34. package/lib/wire/serialize.js +42 -141
  35. package/lib/wire/service.d.ts +66 -0
  36. package/lib/wire/service.js +374 -401
  37. package/lib/wire/socket.d.ts +59 -0
  38. package/lib/wire/socket.js +79 -40
  39. package/lib/wire/statement.d.ts +25 -0
  40. package/lib/wire/statement.js +13 -9
  41. package/lib/wire/transaction.d.ts +21 -0
  42. package/lib/wire/transaction.js +33 -61
  43. package/lib/wire/xsqlvar.d.ts +175 -0
  44. package/lib/wire/xsqlvar.js +169 -269
  45. package/package.json +12 -4
  46. package/src/callback.ts +55 -0
  47. package/{poc/node_modules/node-firebird/lib/gdscodes.js → src/gdscodes.ts} +3 -3
  48. package/{poc/node_modules/node-firebird/lib/ieee754-decimal.js → src/ieee754-decimal.ts} +7 -14
  49. package/src/index.ts +157 -0
  50. package/{poc/node_modules/node-firebird/lib/messages.js → src/messages.ts} +163 -162
  51. package/src/pool.ts +209 -0
  52. package/{poc/node_modules/node-firebird/lib/srp.js → src/srp.ts} +74 -33
  53. package/src/types.ts +419 -0
  54. package/{poc/node_modules/node-firebird/lib/unix-crypt.js → src/unix-crypt.ts} +6 -12
  55. package/{poc/node_modules/node-firebird/lib/utils.js → src/utils.ts} +11 -20
  56. package/{poc/node_modules/node-firebird/lib/wire/connection.js → src/wire/connection.ts} +611 -129
  57. package/{poc/node_modules/node-firebird/lib/wire/const.js → src/wire/const.ts} +96 -9
  58. package/{poc/node_modules/node-firebird/lib/wire/database.js → src/wire/database.ts} +110 -44
  59. package/{poc/node_modules/node-firebird/lib/wire/eventConnection.js → src/wire/eventConnection.ts} +29 -14
  60. package/{poc/node_modules/node-firebird/lib/wire/fbEventManager.js → src/wire/fbEventManager.ts} +39 -30
  61. package/{poc/node_modules/node-firebird/lib/wire/serialize.js → src/wire/serialize.ts} +78 -59
  62. package/{poc/node_modules/node-firebird/lib/wire/service.js → src/wire/service.ts} +90 -88
  63. package/src/wire/socket.ts +262 -0
  64. package/src/wire/statement.ts +71 -0
  65. package/{poc/node_modules/node-firebird/lib/wire/transaction.js → src/wire/transaction.ts} +25 -19
  66. package/{poc/node_modules/node-firebird/lib/wire/xsqlvar.js → src/wire/xsqlvar.ts} +244 -143
  67. package/.eslintrc.json +0 -12
  68. package/.github/workflows/codeql.yml +0 -76
  69. package/.github/workflows/node.js.yml +0 -95
  70. package/BIGINT_MIGRATION.md +0 -374
  71. package/CI_DEBUGGING_GUIDE.md +0 -148
  72. package/ENCRYPTION_CALLBACK.md +0 -152
  73. package/FIREBIRD_LOG_FEATURE.md +0 -145
  74. package/MINIMAL_CHANGES_SUMMARY.md +0 -136
  75. package/PR_SUMMARY.md +0 -96
  76. package/ROADMAP.md +0 -223
  77. package/SRP_PROTOCOL.md +0 -482
  78. package/poc/README.md +0 -160
  79. package/poc/helpers.js +0 -59
  80. package/poc/node_modules/.package-lock.json +0 -14
  81. package/poc/node_modules/node-firebird/.eslintrc.json +0 -12
  82. package/poc/node_modules/node-firebird/.github/workflows/codeql.yml +0 -76
  83. package/poc/node_modules/node-firebird/.github/workflows/node.js.yml +0 -95
  84. package/poc/node_modules/node-firebird/BIGINT_MIGRATION.md +0 -374
  85. package/poc/node_modules/node-firebird/CI_DEBUGGING_GUIDE.md +0 -148
  86. package/poc/node_modules/node-firebird/ENCRYPTION_CALLBACK.md +0 -152
  87. package/poc/node_modules/node-firebird/FIREBIRD_LOG_FEATURE.md +0 -145
  88. package/poc/node_modules/node-firebird/LICENSE +0 -373
  89. package/poc/node_modules/node-firebird/MINIMAL_CHANGES_SUMMARY.md +0 -136
  90. package/poc/node_modules/node-firebird/PR_SUMMARY.md +0 -96
  91. package/poc/node_modules/node-firebird/README.md +0 -794
  92. package/poc/node_modules/node-firebird/ROADMAP.md +0 -223
  93. package/poc/node_modules/node-firebird/SRP_PROTOCOL.md +0 -482
  94. package/poc/node_modules/node-firebird/lib/callback.js +0 -38
  95. package/poc/node_modules/node-firebird/lib/gdscodes.d.ts +0 -1524
  96. package/poc/node_modules/node-firebird/lib/index.d.ts +0 -316
  97. package/poc/node_modules/node-firebird/lib/index.js +0 -128
  98. package/poc/node_modules/node-firebird/lib/pool.js +0 -108
  99. package/poc/node_modules/node-firebird/lib/wire/socket.js +0 -175
  100. package/poc/node_modules/node-firebird/lib/wire/statement.js +0 -48
  101. package/poc/node_modules/node-firebird/package.json +0 -38
  102. package/poc/node_modules/node-firebird/vitest.config.js +0 -24
  103. package/poc/package-lock.json +0 -21
  104. package/poc/package.json +0 -12
  105. package/poc/reproduce-fixed.js +0 -150
  106. package/poc/reproduce.js +0 -133
  107. package/vitest.config.js +0 -27
  108. /package/{poc/node_modules/node-firebird/lib → src}/firebird.msg +0 -0
  109. /package/{poc/node_modules/node-firebird/lib → src}/firebird.msg.json +0 -0
@@ -1,148 +0,0 @@
1
- # CI Debugging Guide
2
-
3
- ## Firebird Log Display on Test Failures
4
-
5
- ### Overview
6
- When tests fail in the CI pipeline, the workflow automatically displays Firebird server logs to help with debugging. This feature was added to make it easier to diagnose connection, authentication, and other Firebird-related issues.
7
-
8
- ### What Gets Displayed
9
-
10
- When a test fails, the following information is automatically shown:
11
-
12
- 1. **Firebird Server Log** (last 100 lines)
13
- - Location: `/firebird/log/firebird.log` inside the Docker container
14
- - Contains Firebird server events, errors, warnings, and diagnostic information
15
- - Useful for diagnosing authentication failures, connection issues, and SQL errors
16
-
17
- 2. **Docker Container Status**
18
- - Shows if the Firebird container is running, stopped, or has exited
19
- - Displays container ID, image, status, and ports
20
- - Command: `docker ps -a`
21
-
22
- 3. **Docker Container Logs** (last 50 lines)
23
- - Shows the stdout/stderr output from the Firebird container
24
- - Includes startup messages and any runtime errors
25
- - Command: `docker logs firebird --tail 50`
26
-
27
- ### How It Works
28
-
29
- The workflow uses GitHub Actions' conditional execution:
30
-
31
- ```yaml
32
- - name: Show Firebird log on failure
33
- if: failure()
34
- run: |
35
- # Display Firebird log
36
- docker exec firebird tail -n 100 /firebird/log/firebird.log || echo "Could not read firebird.log"
37
- # Display container status
38
- docker ps -a
39
- # Display container logs
40
- docker logs firebird --tail 50
41
- ```
42
-
43
- **Key Features:**
44
- - Only runs when previous steps fail (`if: failure()`)
45
- - No performance impact on successful builds
46
- - Gracefully handles missing log file with fallback message
47
- - Works with all Firebird versions (3, 4, 5)
48
-
49
- ### Interpreting the Output
50
-
51
- #### Common Firebird Log Patterns
52
-
53
- **Authentication Failures:**
54
- ```
55
- INET/inet_error: read errno = 104
56
- login by SYSDBA failed (authentication failed)
57
- ```
58
-
59
- **Connection Issues:**
60
- ```
61
- INET/inet_error: connect errno = 111
62
- connection refused
63
- ```
64
-
65
- **Database Errors:**
66
- ```
67
- Database: /firebird/data/test.fdb
68
- validation error
69
- ```
70
-
71
- #### Docker Container Status
72
-
73
- **Running Container:**
74
- ```
75
- CONTAINER ID IMAGE STATUS
76
- abc123... firebirdsql/firebird:5 Up 2 minutes
77
- ```
78
-
79
- **Stopped Container:**
80
- ```
81
- CONTAINER ID IMAGE STATUS
82
- abc123... firebirdsql/firebird:5 Exited (1) 2 minutes ago
83
- ```
84
-
85
- ### Testing Locally
86
-
87
- To test the Firebird log display locally:
88
-
89
- 1. Start Firebird Docker container:
90
- ```bash
91
- docker run -d --name firebird \
92
- -e FIREBIRD_ROOT_PASSWORD="masterkey" \
93
- -p 3050:3050 \
94
- firebirdsql/firebird:5
95
- ```
96
-
97
- 2. View Firebird log:
98
- ```bash
99
- docker exec firebird tail -n 100 /firebird/log/firebird.log
100
- ```
101
-
102
- 3. Check container status:
103
- ```bash
104
- docker ps -a
105
- ```
106
-
107
- 4. View container logs:
108
- ```bash
109
- docker logs firebird --tail 50
110
- ```
111
-
112
- ### Troubleshooting
113
-
114
- **"Could not read firebird.log" message:**
115
- - The log file may not exist yet (Firebird hasn't started)
116
- - The log path may be different (though it's standard across versions 3-5)
117
- - Check the Docker container logs for more information
118
-
119
- **No output shown:**
120
- - Verify the step ran (check GitHub Actions logs)
121
- - Ensure the `if: failure()` condition was triggered
122
- - Check that the Firebird container is running
123
-
124
- **Container not found:**
125
- - The container may have been removed before this step ran
126
- - Check earlier steps in the workflow for container lifecycle issues
127
-
128
- ### Related Documentation
129
-
130
- - [Firebird Documentation](https://firebirdsql.org/en/documentation/)
131
- - [GitHub Actions Conditional Execution](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idif)
132
- - [Docker Logging](https://docs.docker.com/config/containers/logging/)
133
-
134
- ### Contributing
135
-
136
- If you encounter issues with the log display or have suggestions for improvement:
137
-
138
- 1. Check if the Firebird log path has changed in newer versions
139
- 2. Verify the Docker container name matches (`firebird`)
140
- 3. Test with different Firebird versions (3, 4, 5)
141
- 4. Submit an issue or pull request with your findings
142
-
143
- ### Version History
144
-
145
- - **2026-03-23**: Initial implementation
146
- - Added automatic Firebird log display on test failure
147
- - Includes Docker container status and logs
148
- - Works with Firebird 3, 4, and 5
@@ -1,152 +0,0 @@
1
- # Database Encryption Key Callback Implementation
2
-
3
- This document describes the implementation of Firebird protocol 14 and 15 database encryption key callback support in node-firebird.
4
-
5
- ## Overview
6
-
7
- Firebird 3.0.1 introduced protocol version 14 to fix a bug in database encryption key callback, and version 15 (3.0.2) extended this to support database encryption key callback during the connect phase. This allows connections to encrypted databases that serve as their own security database.
8
-
9
- ## Implementation Details
10
-
11
- ### 1. Protocol Support
12
-
13
- The implementation adds support for:
14
- - **Protocol 14**: Database encryption key callback (Firebird 3.0.1+)
15
- - **Protocol 15**: Database encryption key callback in connect phase (Firebird 3.0.2+)
16
-
17
- Both protocols were already defined in the constants but the actual callback mechanism (`op_crypt_key_callback`, opcode 97) was not implemented.
18
-
19
- ### 2. Connection Option
20
-
21
- A new connection option `dbCryptConfig` has been added:
22
-
23
- ```javascript
24
- {
25
- dbCryptConfig: 'base64:bXlTZWNyZXRLZXk=' // Base64-encoded key
26
- // or
27
- dbCryptConfig: 'myPlainTextKey' // Plain text key (UTF-8 encoded)
28
- // or
29
- dbCryptConfig: undefined // Empty response (default)
30
- }
31
- ```
32
-
33
- ### 3. Message Flow
34
-
35
- When connecting to an encrypted database:
36
-
37
- 1. Client sends `op_connect` with supported protocol versions
38
- 2. Server responds with `op_accept`, `op_cond_accept`, or `op_accept_data`
39
- 3. If database is encrypted, server sends `op_crypt_key_callback` (opcode 97)
40
- 4. Client reads server plugin data (currently unused)
41
- 5. Client responds with encryption key from `dbCryptConfig` option
42
- 6. Server validates the key and continues with connection or returns error
43
- 7. Connection proceeds normally if key is valid
44
-
45
- ### 4. Code Changes
46
-
47
- #### lib/wire/connection.js
48
-
49
- - **sendOpCryptKeyCallback()**: New method to send the encryption key callback response
50
- - **parseDbCryptConfig()**: Helper function to parse base64 or plain text keys
51
- - **decodeResponse()**: Added case for `Const.op_crypt_key_callback` to handle the callback
52
-
53
- #### lib/index.d.ts
54
-
55
- - Added `dbCryptConfig?: string` to the `Options` interface
56
-
57
- #### Tests
58
-
59
- - **test/protocol.js**: Added test for `op_crypt_key_callback` opcode definition
60
- - **test/db-crypt-config.js**: New test file with 6 tests for option handling and encoding
61
-
62
- #### Documentation
63
-
64
- - **README.md**: Added documentation and examples for database encryption
65
- - **Roadmap.md**: Updated to mark database encryption callback as implemented
66
-
67
- ## Security Considerations
68
-
69
- 1. **Key Storage**: The encryption key is passed as a connection option. Applications should:
70
- - Store keys securely (environment variables, key management systems)
71
- - Never hardcode keys in source code
72
- - Never commit keys to version control
73
-
74
- 2. **Wire Encryption**: Database encryption keys can be transmitted unencrypted if:
75
- - `wireCrypt` is disabled (`WIRE_CRYPT_DISABLE`)
76
- - Legacy authentication is used
77
- - Server doesn't support wire encryption
78
-
79
- **Recommendation**: Always use `wireCrypt: Firebird.WIRE_CRYPT_ENABLE` (default)
80
-
81
- 3. **Empty Keys**: If `dbCryptConfig` is not provided or is empty, an empty response is sent. Depending on the database encryption plugin, this may:
82
- - Work (if the plugin doesn't require a key)
83
- - Fail with an error
84
- - Silently fail (security risk)
85
-
86
- ## Testing
87
-
88
- All tests pass including:
89
- - Protocol constant definitions
90
- - Option parsing and validation
91
- - Base64 encoding/decoding
92
- - UTF-8 plain text encoding
93
-
94
- ## Reference Implementation
95
-
96
- This implementation is based on the Jaybird JDBC driver:
97
- - Issue: https://github.com/FirebirdSQL/jaybird/issues/561
98
- - Commit: https://github.com/FirebirdSQL/jaybird/commit/df6d50bb07589ef554e6f5fe67c5a561ace979e8
99
-
100
- ## Limitations
101
-
102
- 1. **No Plugin System**: Unlike Jaybird's future-ready plugin architecture, this implementation uses a fixed response mechanism. A plugin system could be added in the future.
103
-
104
- 2. **Protocol 14/15 Only**: Database encryption callback is only available for protocol versions 14 and 15 (Firebird 3.0.1+).
105
-
106
- 3. **No Native Support**: This implementation is for pure JavaScript client only. Native and embedded connections are not supported.
107
-
108
- ## Example Usage
109
-
110
- ### Connecting to an Encrypted Database
111
-
112
- ```javascript
113
- const Firebird = require('node-firebird');
114
-
115
- // Using base64-encoded key
116
- Firebird.attach({
117
- host: 'localhost',
118
- port: 3050,
119
- database: '/path/to/encrypted.fdb',
120
- user: 'SYSDBA',
121
- password: 'masterkey',
122
- dbCryptConfig: 'base64:bXlTZWNyZXRLZXkxMjM0NTY=',
123
- wireCrypt: Firebird.WIRE_CRYPT_ENABLE // Recommended
124
- }, function(err, db) {
125
- if (err) throw err;
126
-
127
- console.log('Connected to encrypted database');
128
- db.query('SELECT * FROM MY_TABLE', function(err, result) {
129
- console.log(result);
130
- db.detach();
131
- });
132
- });
133
-
134
- // Using plain text key
135
- Firebird.attach({
136
- host: 'localhost',
137
- database: '/path/to/encrypted.fdb',
138
- user: 'SYSDBA',
139
- password: 'masterkey',
140
- dbCryptConfig: 'mySecretKey123'
141
- }, function(err, db) {
142
- if (err) throw err;
143
- // ...
144
- });
145
- ```
146
-
147
- ## Future Enhancements
148
-
149
- 1. **Plugin Architecture**: Similar to Jaybird, implement a plugin system for more complex encryption callbacks
150
- 2. **Multiple Callbacks**: Handle cases where the server requests multiple callbacks
151
- 3. **Key Derivation**: Support for key derivation functions (PBKDF2, scrypt, etc.)
152
- 4. **Protocol 16/17**: Add support for Firebird 4.0 protocol versions
@@ -1,145 +0,0 @@
1
- # Firebird Log Display Feature
2
-
3
- ## Quick Reference
4
-
5
- ### What Was Added
6
- Automatic display of Firebird server logs when CI tests fail.
7
-
8
- ### Where
9
- - **Implementation**: `.github/workflows/node.js.yml` (lines 77-93)
10
- - **Documentation**: `CI_DEBUGGING_GUIDE.md`
11
-
12
- ### When It Runs
13
- Only when tests fail in CI (uses `if: failure()` condition)
14
-
15
- ### What It Shows
16
- 1. Last 100 lines of Firebird server log
17
- 2. Docker container status
18
- 3. Last 50 lines of Docker container logs
19
-
20
- ## Quick Commands
21
-
22
- ### View logs locally:
23
- ```bash
24
- # Start Firebird container
25
- docker run -d --name firebird \
26
- -e FIREBIRD_ROOT_PASSWORD="masterkey" \
27
- -p 3050:3050 \
28
- firebirdsql/firebird:5
29
-
30
- # View Firebird log
31
- docker exec firebird tail -n 100 /firebird/log/firebird.log
32
-
33
- # Check container status
34
- docker ps -a
35
-
36
- # View container logs
37
- docker logs firebird --tail 50
38
- ```
39
-
40
- ### Test the workflow locally:
41
- ```bash
42
- # Validate YAML syntax
43
- python3 -c "import yaml; yaml.safe_load(open('.github/workflows/node.js.yml'))"
44
- ```
45
-
46
- ## Implementation Details
47
-
48
- ### GitHub Actions Step
49
- ```yaml
50
- - name: Show Firebird log on failure
51
- if: failure()
52
- run: |
53
- echo "=========================================="
54
- echo "Firebird Server Log (last 100 lines):"
55
- echo "=========================================="
56
- docker exec firebird tail -n 100 /firebird/log/firebird.log || echo "Could not read firebird.log"
57
- echo ""
58
- echo "=========================================="
59
- echo "Docker container status:"
60
- echo "=========================================="
61
- docker ps -a
62
- echo ""
63
- echo "=========================================="
64
- echo "Docker container logs:"
65
- echo "=========================================="
66
- docker logs firebird --tail 50
67
- ```
68
-
69
- ### Key Features
70
- - ✅ Conditional execution (only on failure)
71
- - ✅ Graceful error handling
72
- - ✅ Formatted output with clear sections
73
- - ✅ Works with Firebird 3, 4, and 5
74
- - ✅ Zero performance impact on successful builds
75
-
76
- ## Common Issues & Solutions
77
-
78
- ### Issue: "Could not read firebird.log"
79
- **Solution**: Check Docker container logs, the file might not exist yet
80
-
81
- ### Issue: Container not found
82
- **Solution**: Verify container name is "firebird" and it's still running
83
-
84
- ### Issue: Empty log output
85
- **Solution**: Firebird might not have written logs yet, check startup time
86
-
87
- ## Firebird Log Locations
88
-
89
- ### In Docker Container
90
- - **Log file**: `/firebird/log/firebird.log`
91
- - **Config**: `/firebird/etc/firebird.conf`
92
- - **Install**: `/opt/firebird`
93
-
94
- ### Consistent Across Versions
95
- The log path is the same for:
96
- - Firebird 3.x
97
- - Firebird 4.x
98
- - Firebird 5.x
99
-
100
- ## Maintenance
101
-
102
- ### If log path changes:
103
- 1. Update `.github/workflows/node.js.yml`
104
- 2. Update `CI_DEBUGGING_GUIDE.md`
105
- 3. Test with all Firebird versions
106
-
107
- ### If more lines needed:
108
- - Change `tail -n 100` to desired number
109
- - Change `--tail 50` for Docker logs
110
-
111
- ### If additional diagnostics needed:
112
- Add new echo sections in the workflow step
113
-
114
- ## Related Files
115
-
116
- - `.github/workflows/node.js.yml` - CI workflow with log display
117
- - `CI_DEBUGGING_GUIDE.md` - Comprehensive debugging guide
118
- - `README.md` - Main project documentation
119
-
120
- ## Version History
121
-
122
- - **2026-03-23**: Initial implementation
123
- - Added conditional log display on test failure
124
- - Created comprehensive documentation
125
- - Tested with Firebird 3, 4, 5
126
-
127
- ## Contributing
128
-
129
- To improve this feature:
130
- 1. Test with different Firebird versions
131
- 2. Verify log paths remain consistent
132
- 3. Submit issues or PRs with enhancements
133
- 4. Update documentation as needed
134
-
135
- ## Support
136
-
137
- For questions or issues:
138
- 1. Check `CI_DEBUGGING_GUIDE.md` for troubleshooting
139
- 2. Review GitHub Actions logs for the step execution
140
- 3. Test locally using provided commands
141
- 4. Submit an issue if problems persist
142
-
143
- ---
144
-
145
- **Note**: This feature is designed for CI environments. For local development, use the Docker commands directly.