oracledb 6.0.2 → 6.1.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.
Files changed (67) hide show
  1. package/README.md +15 -17
  2. package/SECURITY.md +1 -1
  3. package/build/Release/oracledb-6.1.0-darwin-x64.node +0 -0
  4. package/build/Release/oracledb-6.1.0-darwin-x64.node-buildinfo.txt +1 -0
  5. package/build/Release/oracledb-6.1.0-js-buildinfo.txt +1 -0
  6. package/build/Release/oracledb-6.1.0-linux-arm64.node +0 -0
  7. package/build/Release/oracledb-6.1.0-linux-arm64.node-buildinfo.txt +1 -0
  8. package/build/Release/oracledb-6.1.0-linux-x64.node +0 -0
  9. package/build/Release/oracledb-6.1.0-linux-x64.node-buildinfo.txt +1 -0
  10. package/build/Release/oracledb-6.1.0-win32-x64.node +0 -0
  11. package/build/Release/oracledb-6.1.0-win32-x64.node-buildinfo.txt +1 -0
  12. package/examples/example.js +0 -1
  13. package/lib/aqQueue.js +40 -26
  14. package/lib/connection.js +15 -3
  15. package/lib/errors.js +15 -10
  16. package/lib/impl/connection.js +9 -0
  17. package/lib/impl/resultset.js +7 -4
  18. package/lib/oracledb.js +15 -12
  19. package/lib/pool.js +11 -2
  20. package/lib/settings.js +1 -1
  21. package/lib/sodaCollection.js +1 -1
  22. package/lib/thin/connection.js +92 -30
  23. package/lib/thin/dbObject.js +2 -2
  24. package/lib/thin/lob.js +2 -2
  25. package/lib/thin/pool.js +153 -71
  26. package/lib/thin/protocol/buffer.js +24 -6
  27. package/lib/thin/protocol/constants.js +8 -18
  28. package/lib/thin/protocol/encryptDecrypt.js +17 -17
  29. package/lib/thin/protocol/messages/auth.js +27 -31
  30. package/lib/thin/protocol/messages/base.js +30 -53
  31. package/lib/thin/protocol/messages/connectionCookie.js +76 -0
  32. package/lib/thin/protocol/messages/dataType.js +13 -9
  33. package/lib/thin/protocol/messages/execute.js +11 -11
  34. package/lib/thin/protocol/messages/index.js +2 -0
  35. package/lib/thin/protocol/messages/lobOp.js +3 -3
  36. package/lib/thin/protocol/messages/protocol.js +31 -20
  37. package/lib/thin/protocol/messages/withData.js +60 -53
  38. package/lib/thin/protocol/oson.js +4 -4
  39. package/lib/thin/protocol/packet.js +51 -28
  40. package/lib/thin/protocol/protocol.js +12 -7
  41. package/lib/thin/protocol/utils.js +2 -2
  42. package/lib/thin/resultSet.js +6 -6
  43. package/lib/thin/sqlnet/connStrategy.js +134 -7
  44. package/lib/thin/sqlnet/constants.js +2 -0
  45. package/lib/thin/sqlnet/ezConnectResolver.js +29 -24
  46. package/lib/thin/sqlnet/navNodes.js +35 -28
  47. package/lib/thin/sqlnet/networkSession.js +45 -40
  48. package/lib/thin/sqlnet/ntTcp.js +70 -35
  49. package/lib/thin/sqlnet/nvStrToNvPair.js +16 -16
  50. package/lib/thin/sqlnet/packet.js +17 -10
  51. package/lib/thin/sqlnet/paramParser.js +9 -9
  52. package/lib/thin/sqlnet/sessionAtts.js +4 -0
  53. package/lib/thin/statement.js +4 -3
  54. package/lib/thin/util.js +28 -8
  55. package/lib/transformer.js +3 -1
  56. package/lib/util.js +0 -13
  57. package/lib/version.js +2 -2
  58. package/package.json +1 -1
  59. package/build/Release/oracledb-6.0.2-darwin-x64.node +0 -0
  60. package/build/Release/oracledb-6.0.2-darwin-x64.node-buildinfo.txt +0 -1
  61. package/build/Release/oracledb-6.0.2-js-buildinfo.txt +0 -1
  62. package/build/Release/oracledb-6.0.2-linux-arm64.node +0 -0
  63. package/build/Release/oracledb-6.0.2-linux-arm64.node-buildinfo.txt +0 -1
  64. package/build/Release/oracledb-6.0.2-linux-x64.node +0 -0
  65. package/build/Release/oracledb-6.0.2-linux-x64.node-buildinfo.txt +0 -1
  66. package/build/Release/oracledb-6.0.2-win32-x64.node +0 -0
  67. package/build/Release/oracledb-6.0.2-win32-x64.node-buildinfo.txt +0 -1
@@ -40,7 +40,12 @@ module.exports = {
40
40
  constants.VERSION_MAJOR << 24 |
41
41
  constants.VERSION_MINOR << 20 |
42
42
  constants.VERSION_PATCH << 12,
43
+ CSFRM_IMPLICIT: constants.CSFRM_IMPLICIT,
44
+ CSFRM_NCHAR: constants.CSFRM_NCHAR,
43
45
  DRIVER_NAME: constants.DEFAULT_DRIVER_NAME + ' thn',
46
+ PURITY_DEFAULT: constants.PURITY_DEFAULT,
47
+ PURITY_NEW: constants.PURITY_NEW,
48
+ PURITY_SELF: constants.PURITY_SELF,
44
49
  SYSASM: constants.SYSASM,
45
50
  SYSBKP: constants.SYSBKP,
46
51
  SYSDBA: constants.SYSDBA,
@@ -84,14 +89,6 @@ module.exports = {
84
89
  TNS_PACKET_TYPE_MARKER: 12,
85
90
  TNS_PACKET_TYPE_CONTROL: 14,
86
91
 
87
- // marker types
88
- TNS_MARKER_TYPE_BREAK: 1,
89
- TNS_MARKER_TYPE_RESET: 2,
90
-
91
- // charset forms
92
- TNS_CS_IMPLICIT: 1,
93
- TNS_CS_NCHAR: 2,
94
-
95
92
  // data types
96
93
  TNS_DATA_TYPE_DEFAULT: 0,
97
94
  TNS_DATA_TYPE_VARCHAR: 1,
@@ -428,8 +425,10 @@ module.exports = {
428
425
  TNS_MSG_TYPE_FLUSH_OUT_BINDS: 19,
429
426
  TNS_MSG_TYPE_BIT_VECTOR: 21,
430
427
  TNS_MSG_TYPE_SERVER_SIDE_PIGGYBACK: 23,
431
- TNS_MSG_TYPE_IMPLICIT_RESULTSET: 27,
432
428
  TNS_MSG_TYPE_ONEWAY_FN: 26,
429
+ TNS_MSG_TYPE_IMPLICIT_RESULTSET: 27,
430
+ TNS_MSG_TYPE_RENEGOTIATE: 28,
431
+ TNS_MSG_TYPE_COOKIE: 30,
433
432
 
434
433
  // parameter keyword numbers,
435
434
  TNS_KEYWORD_NUM_CURRENT_SCHEMA: 168,
@@ -556,18 +555,9 @@ module.exports = {
556
555
  TNS_END_TO_END_MODULE: 0x0008,
557
556
 
558
557
  // versions
559
- TNS_VERSION_DESIRED: 316,
560
- TNS_VERSION_MINIMUM: 300,
561
558
  TNS_VERSION_MIN_ACCEPTED: 315,
562
559
  TNS_VERSION_MIN_LARGE_SDU: 315,
563
560
 
564
- // other connection constants
565
- TNS_SERVICE_OPTIONS: 0xc01,
566
- TNS_PROTOCOL_CHARACTERISTICS: 0x4f98,
567
- TNS_CONNECT_FLAGS: 0x8080,
568
- TNS_CAN_RECV_ATTENTION: 0x0400,
569
- TNS_CHECK_OOB: 0x01,
570
-
571
561
  // TTC functions
572
562
  TNS_FUNC_AUTH_PHASE_ONE: 118,
573
563
  TNS_FUNC_AUTH_PHASE_TWO: 115,
@@ -50,9 +50,9 @@ class EncryptDecrypt {
50
50
  }
51
51
 
52
52
  _encrypt(key, val, padding) {
53
- let block_size = 16;
53
+ const block_size = 16;
54
54
  const iv = Buffer.alloc(block_size, 0);
55
- let n = block_size - (val.length % block_size);
55
+ const n = block_size - (val.length % block_size);
56
56
  const nv = Buffer.alloc(n, n);
57
57
  if (n > 0) {
58
58
  if (padding) {
@@ -73,15 +73,15 @@ class EncryptDecrypt {
73
73
 
74
74
  // Encrypt password and newPassword using comboKey
75
75
  _setEncryptedPasswordBuffers(passwordBytes, newPasswordBytes, comboKey, authObj) {
76
- let salt = Buffer.alloc(16);
76
+ const salt = Buffer.alloc(16);
77
77
  crypto.randomFillSync(salt, 0, 16);
78
- let temp = Buffer.concat([salt, passwordBytes]);
78
+ const temp = Buffer.concat([salt, passwordBytes]);
79
79
  authObj.encodedPassword = this._encrypt(comboKey, temp);
80
80
  temp.fill(0);
81
81
  authObj.encodedPassword = authObj.encodedPassword.slice().toString('hex').toUpperCase();
82
82
 
83
83
  if (newPasswordBytes) {
84
- let newPasswordWithSalt = Buffer.concat([salt, newPasswordBytes]);
84
+ const newPasswordWithSalt = Buffer.concat([salt, newPasswordBytes]);
85
85
  authObj.encodedNewPassword = this._encrypt(comboKey, newPasswordWithSalt);
86
86
  newPasswordWithSalt.fill(0);
87
87
  authObj.encodedNewPassword = authObj.encodedNewPassword.slice().toString('hex').toUpperCase();
@@ -106,10 +106,10 @@ class EncryptDecrypt {
106
106
  let keyLen = 32;
107
107
  let hashAlg = 'sha512';
108
108
 
109
- let verifierData = Buffer.from(sessionData['AUTH_VFR_DATA'], 'hex');
110
- let encodedServerKey = Buffer.from(sessionData['AUTH_SESSKEY'], 'hex');
109
+ const verifierData = Buffer.from(sessionData['AUTH_VFR_DATA'], 'hex');
110
+ const encodedServerKey = Buffer.from(sessionData['AUTH_SESSKEY'], 'hex');
111
111
  let iterations = Number(sessionData['AUTH_PBKDF2_VGEN_COUNT']);
112
- let passwordBytes = Buffer.from(password, 'utf8');
112
+ const passwordBytes = Buffer.from(password, 'utf8');
113
113
  let passwordHash;
114
114
  let passwordKey;
115
115
 
@@ -117,18 +117,18 @@ class EncryptDecrypt {
117
117
  algorithm = 'aes-192-cbc';
118
118
  keyLen = 24;
119
119
  hashAlg = 'sha1';
120
- let h = crypto.createHash(hashAlg);
120
+ const h = crypto.createHash(hashAlg);
121
121
  h.update(passwordBytes);
122
122
  h.update(verifierData);
123
- let ph = h.digest();
123
+ const ph = h.digest();
124
124
  passwordHash = Buffer.alloc(ph.length + 4);
125
125
  ph.copy(passwordHash, 0, 0, ph.length);
126
126
  } else {
127
127
  algorithm = 'aes-256-cbc';
128
- let temp = Buffer.from('AUTH_PBKDF2_SPEEDY_KEY', 'utf8');
129
- let salt = Buffer.concat([verifierData, temp]);
128
+ const temp = Buffer.from('AUTH_PBKDF2_SPEEDY_KEY', 'utf8');
129
+ const salt = Buffer.concat([verifierData, temp]);
130
130
  passwordKey = crypto.pbkdf2Sync(passwordBytes, salt, iterations, 64, 'sha512');
131
- let h = crypto.createHash(hashAlg);
131
+ const h = crypto.createHash(hashAlg);
132
132
  h.update(passwordKey);
133
133
  h.update(verifierData);
134
134
  passwordHash = h.digest().slice(0, keyLen);
@@ -163,10 +163,10 @@ class EncryptDecrypt {
163
163
  iterations, keyLen, 'sha512');
164
164
  }
165
165
 
166
- let salt = Buffer.alloc(16);
166
+ const salt = Buffer.alloc(16);
167
167
  if (!verifier11G) {
168
168
  crypto.randomFillSync(salt, 0, 16);
169
- let temp = Buffer.concat([salt, passwordKey]);
169
+ const temp = Buffer.concat([salt, passwordKey]);
170
170
  authObj.speedyKey = this._encrypt(authObj.comboKey, temp);
171
171
  authObj.speedyKey = authObj.speedyKey.slice(0, 80).toString('hex').toUpperCase();
172
172
  }
@@ -184,7 +184,7 @@ class EncryptDecrypt {
184
184
  }
185
185
 
186
186
  updatePasswordsWithComboKey(password, newPassword, comboKey, authObj) {
187
- let passwordBytes = Buffer.from(password, 'utf8');
187
+ const passwordBytes = Buffer.from(password, 'utf8');
188
188
  let newPasswordBytes;
189
189
  if (newPassword) {
190
190
  newPasswordBytes = Buffer.from(newPassword, 'utf8');
@@ -193,5 +193,5 @@ class EncryptDecrypt {
193
193
  }
194
194
  }
195
195
 
196
- let encryptDecryptInst = new EncryptDecrypt();
196
+ const encryptDecryptInst = new EncryptDecrypt();
197
197
  module.exports = encryptDecryptInst;
@@ -29,12 +29,11 @@
29
29
  const { Buffer } = require('buffer');
30
30
  const constants = require("../constants.js");
31
31
  const errors = require("../../../errors.js");
32
- const os = require("os");
33
32
  const process = require("process");
34
33
  const ED = require("../encryptDecrypt.js");
35
34
  const Message = require("./base.js");
36
35
  const util = require("../../util.js");
37
-
36
+ const cInfo = util.CLIENT_INFO;
38
37
  const crypto = require('crypto');
39
38
 
40
39
  /**
@@ -104,32 +103,32 @@ class AuthMessage extends Message {
104
103
  }
105
104
  this.serviceName = this.conn.serviceName;
106
105
  this.remoteAddress = this.conn.remoteAddress;
107
- this.setAuthMode();
106
+ this.setAuthMode(config);
108
107
  }
109
108
 
110
- setAuthMode() {
109
+ setAuthMode(config) {
111
110
  if (!this.newPassword) {
112
111
  this.authMode = constants.TNS_AUTH_MODE_LOGON;
113
112
  }
114
- if (this.conn.privilege & constants.SYSDBA) {
113
+ if (config.privilege & constants.SYSDBA) {
115
114
  this.authMode |= constants.TNS_AUTH_MODE_SYSDBA;
116
115
  }
117
- if (this.conn.privilege & constants.SYSOPER) {
116
+ if (config.privilege & constants.SYSOPER) {
118
117
  this.authMode |= constants.TNS_AUTH_MODE_SYSOPER;
119
118
  }
120
- if (this.conn.privilege & constants.SYSASM) {
119
+ if (config.privilege & constants.SYSASM) {
121
120
  this.authMode |= constants.TNS_AUTH_MODE_SYSASM;
122
121
  }
123
- if (this.conn.privilege & constants.SYSBKP) {
122
+ if (config.privilege & constants.SYSBKP) {
124
123
  this.authMode |= constants.TNS_AUTH_MODE_SYSBKP;
125
124
  }
126
- if (this.conn.privilege & constants.SYSDG) {
125
+ if (config.privilege & constants.SYSDG) {
127
126
  this.authMode |= constants.TNS_AUTH_MODE_SYSDGD;
128
127
  }
129
- if (this.conn.privilege & constants.SYSKM) {
128
+ if (config.privilege & constants.SYSKM) {
130
129
  this.authMode |= constants.TNS_AUTH_MODE_SYSKMT;
131
130
  }
132
- if (this.conn.privilege & constants.SYSRAC) {
131
+ if (config.privilege & constants.SYSRAC) {
133
132
  this.authMode |= constants.TNS_AUTH_MODE_SYSRAC;
134
133
  }
135
134
  if (this.privateKey) {
@@ -184,11 +183,10 @@ class AuthMessage extends Message {
184
183
  buf.writeBytesWithLength(Buffer.from(this.username));
185
184
  }
186
185
  buf.writeKeyValue("AUTH_TERMINAL", "unknown");
187
- buf.writeKeyValue("AUTH_PROGRAM_NM", process.argv0);
188
- buf.writeKeyValue("AUTH_MACHINE", os.hostname());
189
- buf.writeKeyValue("AUTH_PID", process.pid.toString());
190
- buf.writeKeyValue("AUTH_SID", os.userInfo().username);
191
-
186
+ buf.writeKeyValue("AUTH_PROGRAM_NM", cInfo.program);
187
+ buf.writeKeyValue("AUTH_MACHINE", cInfo.hostName);
188
+ buf.writeKeyValue("AUTH_PID", cInfo.pid);
189
+ buf.writeKeyValue("AUTH_SID", cInfo.userName);
192
190
  } else {
193
191
  let numPairs = 0;
194
192
 
@@ -223,7 +221,7 @@ class AuthMessage extends Message {
223
221
  if (this.privateKey) {
224
222
  numPairs += 2;
225
223
  }
226
- if (this.conn.connClass) {
224
+ if (this.conn.connectionClass) {
227
225
  numPairs += 1;
228
226
  }
229
227
  if (this.conn.purity) {
@@ -270,8 +268,8 @@ class AuthMessage extends Message {
270
268
  if (this.encodedNewPassword) {
271
269
  buf.writeKeyValue("AUTH_NEWPASSWORD", this.encodedNewPassword);
272
270
  }
273
- if (this.conn.connClass) {
274
- buf.writeKeyValue("AUTH_KPPL_CONN_CLASS", this.conn.connClass);
271
+ if (this.conn.connectionClass) {
272
+ buf.writeKeyValue("AUTH_KPPL_CONN_CLASS", this.conn.connectionClass);
275
273
  }
276
274
  if (this.conn.purity) {
277
275
  buf.writeKeyValue("AUTH_KPPL_PURITY", '' + this.conn.purity);
@@ -280,11 +278,11 @@ class AuthMessage extends Message {
280
278
  const currentDate = new Date();
281
279
  const currentDateFormatted = currentDate.toGMTString();
282
280
 
283
- let header = "date: " + currentDateFormatted + "\n" +
281
+ const header = "date: " + currentDateFormatted + "\n" +
284
282
  "(request-target): " + this.serviceName + "\n" +
285
283
  "host: " + this.remoteAddress;
286
284
 
287
- let signature = crypto.createSign('RSA-SHA256')
285
+ const signature = crypto.createSign('RSA-SHA256')
288
286
  .update(header)
289
287
  .sign(this.privateKey, 'base64');
290
288
 
@@ -299,16 +297,16 @@ class AuthMessage extends Message {
299
297
  }
300
298
 
301
299
  processReturnParameter(buf) {
302
- let numParams = buf.readUB2();
300
+ const numParams = buf.readUB2();
303
301
  for (let i = 0; i < numParams;i++) {
304
302
  buf.skipUB4();
305
- let key = buf.readStr(constants.TNS_CS_IMPLICIT);
303
+ const key = buf.readStr(constants.CSFRM_IMPLICIT);
306
304
  let value = "";
307
- let numBytes = buf.readUB4();
305
+ const numBytes = buf.readUB4();
308
306
  if (numBytes > 0) {
309
- value = buf.readStr(constants.TNS_CS_IMPLICIT);
307
+ value = buf.readStr(constants.CSFRM_IMPLICIT);
310
308
  }
311
- let flag = buf.readUB4();
309
+ const flag = buf.readUB4();
312
310
  if (key === "AUTH_VFR_DATA") {
313
311
  this.verifierType = flag;
314
312
  }
@@ -318,16 +316,14 @@ class AuthMessage extends Message {
318
316
  if (this.functionCode === constants.TNS_FUNC_AUTH_PHASE_ONE) {
319
317
  this.functionCode = constants.TNS_FUNC_AUTH_PHASE_TWO;
320
318
  } else {
321
- let versionNum;
322
319
  let releaseNum;
323
320
  let updateNum;
324
321
  let portReleaseNum;
325
322
  let portUpdateNum;
326
323
 
327
- this.conn.sessionID = this.sessionData['AUTH_SESSION_ID'];
328
- this.conn.serialNum = this.sessionData['AUTH_SERIAL_NUM'];
329
- let fullVersionNum = Number(this.sessionData['AUTH_VERSION_NO']);
330
- versionNum = (fullVersionNum >> 24) & 0xFF;
324
+ this.conn.instanceName = this.sessionData['AUTH_INSTANCENAME'];
325
+ const fullVersionNum = Number(this.sessionData['AUTH_VERSION_NO']);
326
+ const versionNum = (fullVersionNum >> 24) & 0xFF;
331
327
  if (buf.caps.ttcFieldVersion >= constants.TNS_CCAP_FIELD_VERSION_18_1_EXT_1) {
332
328
  releaseNum = (fullVersionNum >> 16) & 0xFF;
333
329
  updateNum = (fullVersionNum >> 12) & 0x0F;
@@ -30,37 +30,13 @@ const { Buffer } = require('buffer');
30
30
  const constants = require("../constants.js");
31
31
  const errors = require("../../../errors.js");
32
32
 
33
- class OracleErrorInfo {
34
- constructor() {
35
- this.num = 0;
36
- this.cursorId = 0;
37
- this.pos = 0;
38
- this.rowCount = 0;
39
- this.message = "";
40
- this.rowID = null;
41
- this.batchErrors;
42
- }
43
- }
44
-
45
- class Error {
46
- constructor(num, message = "", context = "", isRecoverable = false, isWarning = false, code = 0, offset = 0) {
47
- this.num = num;
48
- this.message = message;
49
- this.context = context;
50
- this.isRecoverable = isRecoverable;
51
- this.isWarning = isWarning;
52
- this.code = code;
53
- this.offset = offset;
54
- }
55
- }
56
-
57
33
  /**
58
34
  *
59
35
  * Base class for all the RPC messages to support encode/decode functions
60
36
  */
61
37
  class Message {
62
38
  constructor(connection) {
63
- this.errorInfo = new OracleErrorInfo();
39
+ this.errorInfo = {};
64
40
  this.connection = connection;
65
41
  this.messageType = constants.TNS_MSG_TYPE_FUNCTION;
66
42
  this.functionCode = 0;
@@ -106,7 +82,7 @@ class Message {
106
82
  buf.skipUB1(); // call number
107
83
  buf.skipUB2(); // padding
108
84
  buf.skipUB4(); // success iters
109
- let numBytes = buf.readUB4(); // oerrdd (logical rowid)
85
+ const numBytes = buf.readUB4(); // oerrdd (logical rowid)
110
86
  if (numBytes > 0) {
111
87
  buf.skipBytesChunked();
112
88
  }
@@ -114,12 +90,12 @@ class Message {
114
90
  let numEntries = buf.readUB2(); // batch error codes array
115
91
  if (numEntries > 0) {
116
92
  this.errorInfo.batchErrors = [];
117
- let firstByte = buf.readUInt8();
93
+ const firstByte = buf.readUInt8();
118
94
  for (let i = 0; i < numEntries; i++) {
119
95
  if (firstByte === constants.TNS_LONG_LENGTH_INDICATOR) {
120
96
  buf.skipUB4(); // chunk length ignored
121
97
  }
122
- let errorCode = buf.readUB2();
98
+ const errorCode = buf.readUB2();
123
99
  this.errorInfo.batchErrors.push(new Error(errorCode));
124
100
  }
125
101
  if (firstByte === constants.TNS_LONG_LENGTH_INDICATOR) {
@@ -130,7 +106,7 @@ class Message {
130
106
  // batch error offset
131
107
  numEntries = buf.readUB2(); // batch error row offset array
132
108
  if (numEntries > 0) {
133
- let firstByte = buf.readUInt8();
109
+ const firstByte = buf.readUInt8();
134
110
  for (let i = 0; i < numEntries; i++) {
135
111
  if (firstByte === constants.TNS_LONG_LENGTH_INDICATOR) {
136
112
  buf.skipUB4(); // chunk length ignored
@@ -149,7 +125,7 @@ class Message {
149
125
  for (let i = 0; i < numEntries; i++) {
150
126
  buf.skipUB2(); // skip chunk length
151
127
 
152
- this.errorInfo.batchErrors[i].message = buf.readStr(constants.TNS_CS_IMPLICIT);
128
+ this.errorInfo.batchErrors[i].message = buf.readStr(constants.CSFRM_IMPLICIT);
153
129
  buf.skipBytes(2); // ignore end marker
154
130
  }
155
131
  }
@@ -158,7 +134,7 @@ class Message {
158
134
  this.errorInfo.rowCount = buf.readUB8(); // row number (extended)
159
135
  if (this.errorInfo.num !== 0) {
160
136
  this.errorOccurred = true;
161
- this.errorInfo.message = buf.readStr(constants.TNS_CS_IMPLICIT);
137
+ this.errorInfo.message = buf.readStr(constants.CSFRM_IMPLICIT);
162
138
  /*
163
139
  * Remove ending newline from ORA error message
164
140
  */
@@ -172,10 +148,10 @@ class Message {
172
148
 
173
149
  processWarningInfo(buf) {
174
150
  this.errorInfo.num = buf.readUB2(); // error number
175
- let numBytes = buf.readUB2(); // length of error message
151
+ const numBytes = buf.readUB2(); // length of error message
176
152
  buf.skipUB2(); // flags
177
153
  if (this.errorInfo.num != 0 && numBytes > 0) {
178
- this.errorInfo.message = buf.readStr(constants.TNS_CS_IMPLICIT);
154
+ this.errorInfo.message = buf.readStr(constants.CSFRM_IMPLICIT);
179
155
  }
180
156
  this.errorInfo.isWarning = true;
181
157
  }
@@ -215,7 +191,7 @@ class Message {
215
191
  } else if (messageType === constants.TNS_MSG_TYPE_SERVER_SIDE_PIGGYBACK) {
216
192
  this.processServerSidePiggyBack(buf);
217
193
  } else {
218
- errors.throwErr(errors.ERR_UNEXPECTED_MESSAGE_TYPE, messageType);
194
+ errors.throwErr(errors.ERR_UNEXPECTED_MESSAGE_TYPE, messageType, buf.pos, buf.packetNum);
219
195
  }
220
196
  }
221
197
 
@@ -224,43 +200,44 @@ class Message {
224
200
  if (opcode === constants.TNS_SERVER_PIGGYBACK_LTXID) {
225
201
  const num_bytes = buf.readUB4();
226
202
  if (num_bytes > 0) {
227
- buf.skipBytes(num_bytes);
203
+ buf.skipBytesChunked();
228
204
  }
229
205
  } else if ((opcode === constants.TNS_SERVER_PIGGYBACK_QUERY_CACHE_INVALIDATION)
230
206
  || (opcode === constants.TNS_SERVER_PIGGYBACK_TRACE_EVENT)) {
231
207
  // pass
232
208
  } else if (opcode === constants.TNS_SERVER_PIGGYBACK_OS_PID_MTS) {
233
- const nb = buf.readUB2();
234
- buf.skipBytes(nb + 1);
209
+ const numDtys = buf.readUB2();
210
+ buf.skipUB1();
211
+ buf.skipBytes(numDtys);
235
212
  } else if (opcode === constants.TNS_SERVER_PIGGYBACK_SYNC) {
236
213
  buf.skipUB2(); // skip number of DTYs
237
214
  buf.skipUB1(); // skip length of DTYs
238
- const num_elements = buf.readUB2();
215
+ const num_elements = buf.readUB4();
239
216
  buf.skipBytes(1); // skip length
240
217
  for (let i = 0; i < num_elements; i++) {
241
218
  let temp16 = buf.readUB2();
242
219
  if (temp16 > 0) { // skip key
243
- buf.skipBytes(temp16 + 1);
220
+ buf.skipBytesChunked();
244
221
  }
245
222
  temp16 = buf.readUB2();
246
223
  if (temp16 > 0) { // skip value
247
- buf.skipBytes(temp16 + 1);
224
+ buf.skipBytesChunked();
248
225
  }
249
226
  buf.skipUB2(); // skip flags
250
- buf.skipUB4(); // skip overall flags
251
227
  }
228
+ buf.skipUB4(); // skip overall flags
252
229
  } else if (opcode === constants.TNS_SERVER_PIGGYBACK_EXT_SYNC) {
253
230
  buf.skipUB2();
254
231
  buf.skipUB1();
255
232
  } else if (opcode === constants.TNS_SERVER_PIGGYBACK_AC_REPLAY_CONTEXT) {
256
233
  buf.skipUB2(); // skip number of DTYs
257
- buf.skipUB1(1); // skip length of DTYs
234
+ buf.skipUB1(); // skip length of DTYs
258
235
  buf.skipUB4(); // skip flags
259
236
  buf.skipUB4(); // skip error code
260
237
  buf.skipUB1(); // skip queue
261
238
  const num_bytes = buf.readUB4(); // skip replay context
262
239
  if (num_bytes > 0) {
263
- buf.skipBytes(num_bytes);
240
+ buf.skipBytesChunked();
264
241
  }
265
242
  } else if (opcode === constants.TNS_SERVER_PIGGYBACK_SESS_RET) {
266
243
  buf.skipUB2();
@@ -271,11 +248,11 @@ class Message {
271
248
  for (let i = 0; i < num_elements; ++i) {
272
249
  let temp16 = buf.readUB2();
273
250
  if (temp16 > 0) { // skip key
274
- buf.skipBytes(temp16 + 1);
251
+ buf.skipBytesChunked();
275
252
  }
276
253
  temp16 = buf.readUB2();
277
254
  if (temp16 > 0) { // skip value
278
- buf.skipBytes(temp16 + 1);
255
+ buf.skipBytesChunked();
279
256
  }
280
257
  buf.skipUB2(); // skip flags
281
258
  }
@@ -283,7 +260,7 @@ class Message {
283
260
  const flags = buf.readUB4(); // session flags
284
261
  if (flags & constants.TNS_SESSGET_SESSION_CHANGED) {
285
262
  if (this.connection._drcpEstablishSession) {
286
- this.connection.resetStatmentCache();
263
+ this.connection.resetStatementCache();
287
264
  }
288
265
  }
289
266
  this.connection._drcpEstablishSession = false;
@@ -335,8 +312,8 @@ class Message {
335
312
  }
336
313
 
337
314
  writeCloseTempLobsPiggyback(buf) {
338
- let lobsToClose = this.connection._tempLobsToClose;
339
- let opCode = constants.TNS_LOB_OP_FREE_TEMP | constants.TNS_LOB_OP_ARRAY;
315
+ const lobsToClose = this.connection._tempLobsToClose;
316
+ const opCode = constants.TNS_LOB_OP_FREE_TEMP | constants.TNS_LOB_OP_ARRAY;
340
317
 
341
318
  this.writePiggybackHeader(buf, constants.TNS_FUNC_LOB_OP);
342
319
 
@@ -406,9 +383,9 @@ class Message {
406
383
  buf.writeUInt8(0); // pointer (cidser)
407
384
  buf.writeUB4(flags);
408
385
 
409
- let clientIdentifierBytes = this.writeEndEndTraceValue(buf, this.connection._clientIdentifier, this.connection._clientIdentifierModified);
410
- let moduleBytes = this.writeEndEndTraceValue(buf, this.connection._module, this.connection._moduleModified);
411
- let actionBytes = this.writeEndEndTraceValue(buf, this.connection._action, this.connection._actionModified);
386
+ const clientIdentifierBytes = this.writeEndEndTraceValue(buf, this.connection._clientIdentifier, this.connection._clientIdentifierModified);
387
+ const moduleBytes = this.writeEndEndTraceValue(buf, this.connection._module, this.connection._moduleModified);
388
+ const actionBytes = this.writeEndEndTraceValue(buf, this.connection._action, this.connection._actionModified);
412
389
 
413
390
  // write unsupported bits
414
391
  buf.writeUInt8(0); // pointer (cideci)
@@ -416,13 +393,13 @@ class Message {
416
393
  buf.writeUInt8(0); // cidcct
417
394
  buf.writeUB4(0); // cidecs
418
395
 
419
- let clientInfoBytes = this.writeEndEndTraceValue(buf, this.connection._clientInfo, this.connection._clientInfoModified);
396
+ const clientInfoBytes = this.writeEndEndTraceValue(buf, this.connection._clientInfo, this.connection._clientInfoModified);
420
397
  // write unsupported bits
421
398
  buf.writeUInt8(0); // pointer (cideci)
422
399
  buf.writeUB4(0); // length (cideci)
423
400
  buf.writeUInt8(0); // cidcct
424
401
  buf.writeUB4(0); // cidecs
425
- let dbOpBytes = this.writeEndEndTraceValue(buf, this.connection._dbOp, this.connection._dbOpModified);
402
+ const dbOpBytes = this.writeEndEndTraceValue(buf, this.connection._dbOp, this.connection._dbOpModified);
426
403
 
427
404
  // write strings
428
405
  if (this.connection._clientIdentifierModified && this.connection._clientIdentifier) {
@@ -0,0 +1,76 @@
1
+ // Copyright (c) 2023 Oracle and/or its affiliates.
2
+
3
+ //-----------------------------------------------------------------------------
4
+ //
5
+ // This software is dual-licensed to you under the Universal Permissive License
6
+ // (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
7
+ // 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose
8
+ // either license.
9
+ //
10
+ // If you elect to accept the software under the Apache License, Version 2.0,
11
+ // the following applies:
12
+ //
13
+ // Licensed under the Apache License, Version 2.0 (the "License");
14
+ // you may not use this file except in compliance with the License.
15
+ // You may obtain a copy of the License at
16
+ //
17
+ // https://www.apache.org/licenses/LICENSE-2.0
18
+ //
19
+ // Unless required by applicable law or agreed to in writing, software
20
+ // distributed under the License is distributed on an "AS IS" BASIS,
21
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
+ // See the License for the specific language governing permissions and
23
+ // limitations under the License.
24
+ //
25
+ //-----------------------------------------------------------------------------
26
+
27
+ 'use strict';
28
+
29
+ const constants = require("../constants.js");
30
+ const Message = require("./base.js");
31
+
32
+ /**
33
+ * Executes a Fast Negotiation RPC function.
34
+ * It sends Protocol Negotiation, Cookie Message, Datatype Negotiation
35
+ * and OSESS Key RPC in single round trip.
36
+ *
37
+ * @class ConnectionCookieMessage
38
+ * @extends {Message}
39
+ */
40
+ class ConnectionCookieMessage extends Message {
41
+
42
+ /**
43
+ * Serializes the ConnectionCookieMessage function arguments
44
+ *
45
+ * @param {object} buf input arguments
46
+ */
47
+ encode(buf) {
48
+ this.protocolMessage.encode(buf);
49
+ buf.writeUInt8(constants.TNS_MSG_TYPE_COOKIE);
50
+ buf.writeUInt8(1); // cookie version
51
+ buf.writeUInt8(this.cookie.protocolVersion);
52
+ buf.writeUInt16LE(this.cookie.charsetID);
53
+ buf.writeUInt8(this.cookie.flags);
54
+ buf.writeUInt16LE(this.cookie.ncharsetID);
55
+ buf.writeBytesWithLength(this.cookie.serverBanner);
56
+ buf.writeBytesWithLength(this.cookie.compileCaps);
57
+ buf.writeBytesWithLength(this.cookie.runtimeCaps);
58
+ this.dataTypeMessage.encode(buf);
59
+ this.authMessage.encode(buf);
60
+ }
61
+
62
+ processMessage(buf, messageType) {
63
+ if (messageType === constants.TNS_MSG_TYPE_RENEGOTIATE) {
64
+ this.cookie.populated = false;
65
+ } else if (messageType === constants.TNS_MSG_TYPE_PROTOCOL) {
66
+ this.protocolMessage.processMessage(buf, messageType);
67
+ } else if (messageType === constants.TNS_MSG_TYPE_DATA_TYPES) {
68
+ this.dataTypeMessage.processMessage(buf, messageType);
69
+ } else {
70
+ this.authMessage.processMessage(buf, messageType);
71
+ }
72
+ }
73
+
74
+ }
75
+
76
+ module.exports = ConnectionCookieMessage;
@@ -38,14 +38,18 @@ const Message = require("./base.js");
38
38
  */
39
39
  class DataTypeMessage extends Message {
40
40
 
41
- processMessage(buf) {
42
- while (true) { // eslint-disable-line
43
- const dataType = buf.readUInt16BE();
44
- if (dataType === 0)
45
- break;
46
- const convDataType = buf.readUInt16BE();
47
- if (convDataType !== 0)
48
- buf.skipBytes(4);
41
+ processMessage(buf, messageType) {
42
+ if (messageType === constants.TNS_MSG_TYPE_DATA_TYPES) {
43
+ while (true) { // eslint-disable-line
44
+ const dataType = buf.readUInt16BE();
45
+ if (dataType === 0)
46
+ break;
47
+ const convDataType = buf.readUInt16BE();
48
+ if (convDataType !== 0)
49
+ buf.skipBytes(4);
50
+ }
51
+ } else {
52
+ super.processMessage(buf, messageType);
49
53
  }
50
54
  }
51
55
 
@@ -57,7 +61,7 @@ class DataTypeMessage extends Message {
57
61
  constants.TNS_ENCODING_CONV_LENGTH);
58
62
  buf.writeBytesWithLength(buf.caps.compileCaps);
59
63
  buf.writeBytesWithLength(buf.caps.runtimeCaps);
60
- for (let val of dataTypes) {
64
+ for (const val of dataTypes) {
61
65
  buf.writeUInt16BE(val[0]);
62
66
  buf.writeUInt16BE(val[1]);
63
67
  buf.writeUInt16BE(val[2]);