oracledb 6.0.3 → 6.2.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 (65) hide show
  1. package/README.md +2 -2
  2. package/build/Release/oracledb-6.2.0-darwin-x64.node +0 -0
  3. package/build/Release/oracledb-6.2.0-darwin-x64.node-buildinfo.txt +1 -0
  4. package/build/Release/oracledb-6.2.0-js-buildinfo.txt +1 -0
  5. package/build/Release/oracledb-6.2.0-linux-arm64.node +0 -0
  6. package/build/Release/oracledb-6.2.0-linux-arm64.node-buildinfo.txt +1 -0
  7. package/build/Release/oracledb-6.2.0-linux-x64.node +0 -0
  8. package/build/Release/oracledb-6.2.0-linux-x64.node-buildinfo.txt +1 -0
  9. package/build/Release/oracledb-6.2.0-win32-x64.node +0 -0
  10. package/build/Release/oracledb-6.2.0-win32-x64.node-buildinfo.txt +1 -0
  11. package/examples/dbconfig.js +7 -14
  12. package/examples/example.js +0 -1
  13. package/lib/aqQueue.js +40 -26
  14. package/lib/connection.js +16 -4
  15. package/lib/dbObject.js +9 -0
  16. package/lib/errors.js +17 -13
  17. package/lib/impl/connection.js +9 -0
  18. package/lib/impl/resultset.js +7 -4
  19. package/lib/oracledb.js +26 -18
  20. package/lib/pool.js +7 -1
  21. package/lib/sodaCollection.js +12 -1
  22. package/lib/sodaOperation.js +16 -0
  23. package/lib/thin/connection.js +229 -182
  24. package/lib/thin/dbObject.js +4 -1
  25. package/lib/thin/pool.js +153 -68
  26. package/lib/thin/protocol/buffer.js +83 -64
  27. package/lib/thin/protocol/constants.js +3 -14
  28. package/lib/thin/protocol/encryptDecrypt.js +17 -17
  29. package/lib/thin/protocol/messages/auth.js +21 -23
  30. package/lib/thin/protocol/messages/base.js +29 -45
  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 +7 -7
  34. package/lib/thin/protocol/messages/index.js +2 -0
  35. package/lib/thin/protocol/messages/protocol.js +31 -20
  36. package/lib/thin/protocol/messages/withData.js +58 -47
  37. package/lib/thin/protocol/oson.js +17 -14
  38. package/lib/thin/protocol/packet.js +36 -14
  39. package/lib/thin/protocol/utils.js +2 -2
  40. package/lib/thin/resultSet.js +6 -6
  41. package/lib/thin/sqlnet/connStrategy.js +130 -5
  42. package/lib/thin/sqlnet/constants.js +2 -0
  43. package/lib/thin/sqlnet/ezConnectResolver.js +29 -61
  44. package/lib/thin/sqlnet/navNodes.js +34 -27
  45. package/lib/thin/sqlnet/networkSession.js +46 -47
  46. package/lib/thin/sqlnet/ntTcp.js +30 -14
  47. package/lib/thin/sqlnet/nvStrToNvPair.js +16 -16
  48. package/lib/thin/sqlnet/packet.js +10 -3
  49. package/lib/thin/sqlnet/paramParser.js +9 -9
  50. package/lib/thin/sqlnet/sessionAtts.js +4 -0
  51. package/lib/thin/statement.js +345 -113
  52. package/lib/thin/util.js +23 -86
  53. package/lib/transformer.js +3 -1
  54. package/lib/util.js +4 -13
  55. package/lib/version.js +2 -2
  56. package/package.json +1 -1
  57. package/build/Release/oracledb-6.0.3-darwin-x64.node +0 -0
  58. package/build/Release/oracledb-6.0.3-darwin-x64.node-buildinfo.txt +0 -1
  59. package/build/Release/oracledb-6.0.3-js-buildinfo.txt +0 -1
  60. package/build/Release/oracledb-6.0.3-linux-arm64.node +0 -0
  61. package/build/Release/oracledb-6.0.3-linux-arm64.node-buildinfo.txt +0 -1
  62. package/build/Release/oracledb-6.0.3-linux-x64.node +0 -0
  63. package/build/Release/oracledb-6.0.3-linux-x64.node-buildinfo.txt +0 -1
  64. package/build/Release/oracledb-6.0.3-win32-x64.node +0 -0
  65. package/build/Release/oracledb-6.0.3-win32-x64.node-buildinfo.txt +0 -1
@@ -34,6 +34,7 @@ const http = require("http");
34
34
  const Timers = require('timers');
35
35
  const constants = require("./constants.js");
36
36
  const errors = require("../../errors.js");
37
+ const { findValue } = require("./nvStrToNvPair.js");
37
38
 
38
39
  const PACKET_HEADER_SIZE = 8;
39
40
  const DEFAULT_PORT = 1521;
@@ -67,28 +68,40 @@ class NTTCP {
67
68
  this.largeSDU = false;
68
69
  this.streamNum = streamNum++;
69
70
  this.packetNum = 1;
71
+ this.doDNMatch = true;
70
72
  }
71
73
 
72
74
  /**
73
75
  * DN matching funciton(used with TLS)
74
76
  */
75
77
  dnMatch(serverName, cert) {
76
- if (this.atts.sslServerDNMatch) {
77
- let toObject = str =>str .split(',').map(x => x.split('=').map(y => y.trim())).reduce((a, x) => {
78
+ if (this.atts.sslServerDNMatch && this.doDNMatch) {
79
+ const toObject = str =>str .split(',').map(x => x.split('=').map(y => y.trim())).reduce((a, x) => {
78
80
  a[x[0]] = x[1];
79
81
  return a;
80
82
  }, {});
81
83
  if (this.atts.sslServerCertDN) { /* Full DN Match */
82
- let obj = toObject(this.atts.sslServerCertDN);
83
- for (let key in obj) {
84
- if (obj[key] != cert.subject[key]) {
85
- return (errors.getErr(errors.ERR_TLS_DNMATCH_FAILURE));
84
+ const obj = toObject(this.atts.sslServerCertDN);
85
+ if (Object.keys(obj).length == Object.keys(cert.subject).length) {
86
+ for (const key in obj) {
87
+ if (obj[key] != cert.subject[key]) {
88
+ return (errors.getErr(errors.ERR_TLS_DNMATCH_FAILURE));
89
+ }
86
90
  }
91
+ } else {
92
+ return (errors.getErr(errors.ERR_TLS_DNMATCH_FAILURE));
87
93
  }
88
94
  } else {
89
95
  if (tls.checkServerIdentity(this.hostName, cert) && (!this.originHost || tls.checkServerIdentity(this.originHost, cert))) { /* Hostname match */
90
- const hostName = this.hostName + " " + (this.originHost ? "or " + this.originHost : "");
91
- return (errors.getErr(errors.ERR_TLS_HOSTMATCH_FAILURE, hostName));
96
+ if (this.atts.sslAllowWeakDNMatch) {
97
+ const serviceName = findValue(this.atts.cDataNVPair, ["DESCRIPTION", "CONNECT_DATA", "SERVICE_NAME"]); /* Service Name match */
98
+ if (serviceName != cert.subject.CN) {
99
+ return (errors.getErr(errors.ERR_TLS_DNMATCH_FAILURE));
100
+ }
101
+ } else {
102
+ const hostName = this.hostName + " " + (this.originHost ? "or " + this.originHost : "");
103
+ return (errors.getErr(errors.ERR_TLS_HOSTMATCH_FAILURE, hostName));
104
+ }
92
105
  }
93
106
  }
94
107
  }
@@ -136,7 +149,7 @@ class NTTCP {
136
149
  }
137
150
 
138
151
  let connectErrCause, proxyConnectErrCause, req;
139
- let httpsProxy = address.httpsProxy || this.atts.httpsProxy;
152
+ const httpsProxy = address.httpsProxy || this.atts.httpsProxy;
140
153
  let httpsProxyPort = address.httpsProxyPort || this.atts.httpsProxyPort;
141
154
 
142
155
  await new Promise((resolve) => {
@@ -211,6 +224,8 @@ class NTTCP {
211
224
  if (address.protocol.toUpperCase() == "TCPS") {
212
225
  let secureContext;
213
226
  this.secure = true;
227
+ if (this.atts.sslAllowWeakDNMatch)
228
+ this.doDNMatch = false; //Don't match initial connect
214
229
  try {
215
230
  secureContext = tls.createSecureContext({
216
231
  cert : this.atts.wallet,
@@ -259,7 +274,7 @@ class NTTCP {
259
274
  const block = buffer.slice(i, i + 8);
260
275
  const hexDumpValues = [];
261
276
  const printableValues = [];
262
- for (let hexByte of block) {
277
+ for (const hexByte of block) {
263
278
  hexDumpValues.push(hexByte.toString(16).toUpperCase().padStart(2, '0'));
264
279
  if (hexByte > 0x20 && hexByte < 0x7f) {
265
280
  printableValues.push(String.fromCharCode(hexByte));
@@ -301,7 +316,7 @@ class NTTCP {
301
316
  */
302
317
  checkErr() {
303
318
  if (!this.connected || this.err) {
304
- let err, newErr;
319
+ let err;
305
320
  if (this.savedErr) {
306
321
  err = errors.getErr(errors.ERR_CONNECTION_LOSTCONTACT,
307
322
  this.host, this.port, this.atts.connectionId, this.savedErr.message);
@@ -309,7 +324,7 @@ class NTTCP {
309
324
  err = errors.getErr(errors.ERR_CONNECTION_EOF, this.host, this.port, this.atts.connectionId,);
310
325
  }
311
326
  /* Wrap around NJS-500 */
312
- newErr = errors.getErr(errors.ERR_CONNECTION_CLOSED);
327
+ const newErr = errors.getErr(errors.ERR_CONNECTION_CLOSED);
313
328
  newErr.message = newErr.message + "\n" + err.message;
314
329
  throw (newErr);
315
330
  }
@@ -457,7 +472,8 @@ class NTTCP {
457
472
  async renegTLS() {
458
473
  try {
459
474
  this.checkErr();
460
- let secureContext = tls.createSecureContext({
475
+ this.doDNMatch = true;
476
+ const secureContext = tls.createSecureContext({
461
477
  cert : this.atts.wallet,
462
478
  key : this.atts.wallet,
463
479
  passphrase: this.atts.walletPassword,
@@ -513,7 +529,7 @@ class NTTCP {
513
529
  return (this.packets.length > 0);
514
530
  case constants.REMOTEADDR: /* Remote Address */
515
531
  {
516
- let socket = this.secure ? this.connStream : this.stream;
532
+ const socket = this.secure ? this.connStream : this.stream;
517
533
  return (socket.remoteAddress + ":" + socket.remotePort);
518
534
  }
519
535
  default:
@@ -176,7 +176,7 @@ class NVPair {
176
176
  }
177
177
  } else if (this.listType == LIST_COMMASEP) {
178
178
  for (let i = 0; i < this.getListSize(); i++) {
179
- let listElem = this.getListElement(i);
179
+ const listElem = this.getListElement(i);
180
180
  out = out + listElem.name;
181
181
  if (i != this.getListSize() - 1)
182
182
  out = out + ", ";
@@ -202,7 +202,7 @@ class NVPair {
202
202
  } else if (this.listType == LIST_COMMASEP) {
203
203
  out = out + " (";
204
204
  for (let i = 0; i < this.getListSize(); i++) {
205
- let listElem = this.getListElement(i);
205
+ const listElem = this.getListElement(i);
206
206
  out = out + listElem.name;
207
207
 
208
208
  if (i != this.getListSize() - 1)
@@ -308,7 +308,7 @@ class NVTokens {
308
308
  * function to trim leading and trailing spaces from a literal.
309
309
  */
310
310
  _trimWhiteSpace(it) {
311
- let length = it.length;
311
+ const length = it.length;
312
312
  let start = 0;
313
313
  let end = length;
314
314
 
@@ -337,7 +337,7 @@ class NVTokens {
337
337
  this.tkType = new Array();
338
338
  this.tkValue = new Array();
339
339
 
340
- let len = nvString.length;
340
+ const len = nvString.length;
341
341
  let eql_seen = false;
342
342
  // convert NVString to character array for easier access
343
343
  let input = new Array();
@@ -560,7 +560,7 @@ class NVTokens {
560
560
  * @param nvString the nvString to parse
561
561
  */
562
562
  function createNVPair(nvString) {
563
- let nvt = new NVTokens();
563
+ const nvt = new NVTokens();
564
564
  nvt.parseTokens(nvString);
565
565
  return readTopLevelNVPair(nvt);
566
566
  }
@@ -579,7 +579,7 @@ function readTopLevelNVPair(nvt) {
579
579
  }
580
580
 
581
581
  let name = readNVLiteral(nvt);
582
- let nvp = new NVPair(name);
582
+ const nvp = new NVPair(name);
583
583
 
584
584
  if ((tk = nvt.getToken()) == TKN_COMMA) {
585
585
  // read comma'ed names as one name
@@ -601,14 +601,14 @@ function readTopLevelNVPair(nvt) {
601
601
  */
602
602
  function readNVPair(nvt) {
603
603
  // Opening ( or , for NVPair
604
- let tk = nvt.getToken();
604
+ const tk = nvt.getToken();
605
605
  nvt.eatToken();
606
606
  if (!((tk == TKN_LPAREN) || (tk == TKN_COMMA))) {
607
607
  errors.throwErr(errors.ERR_INVALID_CONNECT_STRING_SYNTAX);
608
608
  }
609
609
 
610
- let name = readNVLiteral(nvt);
611
- let nvp = new NVPair(name);
610
+ const name = readNVLiteral(nvt);
611
+ const nvp = new NVPair(name);
612
612
 
613
613
  return readRightHandSide(nvp, nvt);
614
614
  }
@@ -628,7 +628,7 @@ function readRightHandSide(nvp, nvt) {
628
628
  // otherwise read an NVList.
629
629
  tk = nvt.getToken();
630
630
  if (tk == TKN_LITERAL) {
631
- let value = readNVLiteral(nvt);
631
+ const value = readNVLiteral(nvt);
632
632
  nvp.setAtom = value;
633
633
  } else {
634
634
  // NVList is responsible for adding child NVPairs to this parent
@@ -663,7 +663,7 @@ function readRightHandSide(nvp, nvt) {
663
663
  * function which returns the next literal from NVTokens.
664
664
  */
665
665
  function readNVLiteral(nvt) {
666
- let tk = nvt.getToken();
666
+ const tk = nvt.getToken();
667
667
  if (tk != TKN_LITERAL) {
668
668
  errors.throwErr(errors.ERR_INVALID_CONNECT_STRING_SYNTAX);
669
669
  }
@@ -677,12 +677,12 @@ function readNVLiteral(nvt) {
677
677
  function readNVList(nvt, parent) {
678
678
  // if next token is "(" or ",", then read an NVPair
679
679
  // otherwise, assume epsilon
680
- let tk = nvt.getToken();
680
+ const tk = nvt.getToken();
681
681
  if (!(tk == TKN_LPAREN || tk == TKN_COMMA)) {
682
682
  return; // didn't read an nvpair
683
683
  }
684
684
 
685
- let child = readNVPair(nvt);
685
+ const child = readNVPair(nvt);
686
686
 
687
687
  // read a good NVPair
688
688
  parent.addListElement(child);
@@ -715,7 +715,7 @@ function findNVPairRecurse(nvp, name) {
715
715
 
716
716
  /* Loop thru the list of children and searching each child for name. */
717
717
  for (let i = 0; i < nvp.getListSize(); i++) {
718
- let child = findNVPairRecurse(nvp.getListElement(i), name);
718
+ const child = findNVPairRecurse(nvp.getListElement(i), name);
719
719
 
720
720
  /* Did we find "name"? */
721
721
  if (child !== null)
@@ -742,7 +742,7 @@ function findNVPair(nvp, name) {
742
742
 
743
743
  /* Loop thru the list of children and searching each child for name. */
744
744
  for (let i = 0; i < nvp.getListSize(); i++) {
745
- let child = nvp.getListElement(i);
745
+ const child = nvp.getListElement(i);
746
746
  if (name.toUpperCase() == (child.name).toUpperCase())
747
747
  return child;
748
748
  }
@@ -764,7 +764,7 @@ function findValue(nvp, names) {
764
764
  return null;
765
765
 
766
766
  let output = nvp;
767
- let sze = names.length;
767
+ const sze = names.length;
768
768
 
769
769
  for (let i = 1; i < sze; i++) {
770
770
  output = findNVPair(output, names[i]);
@@ -42,7 +42,7 @@ function ConnectPacket(connectData, sAtts, flags = 0) {
42
42
  this.connectDataLen = connectData.length;
43
43
  this.overflow = false;
44
44
 
45
- let size, options;
45
+ let size;
46
46
 
47
47
  if (this.connectDataLen <= MAX_CDATA_LEN) {
48
48
  size = NSPCNL + this.connectDataLen;
@@ -69,7 +69,7 @@ function ConnectPacket(connectData, sAtts, flags = 0) {
69
69
  /* Options:
70
70
  Note : Node JS does not support TCP Out-of-band so not setting NSGSENDATTN or NSGRECVATTN
71
71
  */
72
- options = constants.NSGDONTCARE;
72
+ const options = constants.NSGDONTCARE;
73
73
  //options = options | constants.NSGUSEVIO /* Vectored I/O support.Uncomment when support is added */
74
74
  this.buf.writeUInt16BE(options, constants.NSPCNOPT);
75
75
 
@@ -245,6 +245,13 @@ function AcceptPacket(packet, sAtts) {
245
245
  /* Accept flags */
246
246
  this.flag0 = packet.buf.readUInt8(constants.NSPACFL0);
247
247
  this.flag1 = packet.buf.readUInt8(constants.NSPACFL1);
248
+
249
+ /* UUID - CDB Instance ID */
250
+ if (sAtts.version >= constants.TNS_VERSION_MIN_UUID) {
251
+ packet.dbUUID = packet.buf.subarray(constants.TNS_UUID_OFFSET,
252
+ constants.TNS_UUID_OFFSET + 16);
253
+ packet.dbUUID = packet.dbUUID.toString('base64');
254
+ }
248
255
  }
249
256
 
250
257
  /**
@@ -292,7 +299,7 @@ function RedirectPacket(packet) {
292
299
  */
293
300
  function MarkerPacket(isLargeSDU) {
294
301
  this.len = constants.NSPMKDAT + 1; /* Packet length */
295
- this.buf = Buffer.alloc(constants.NSPMKDAT + 1); /* Packet Buffer */
302
+ this.buf = Buffer.allocUnsafe(constants.NSPMKDAT + 1); /* Packet Buffer */
296
303
 
297
304
  if (isLargeSDU) {
298
305
  this.buf.writeUInt32BE(this.len, constants.NSPHDLEN);
@@ -37,7 +37,7 @@ const errors = require("../../errors.js");
37
37
  */
38
38
  function tnsnamesFilePath(configDir) {
39
39
  let filePathVal = null;
40
- let tnsAdminVal = process.env.TNS_ADMIN;
40
+ const tnsAdminVal = process.env.TNS_ADMIN;
41
41
  if (configDir) {
42
42
  filePathVal = configDir + '/tnsnames.ora';
43
43
  if (fs.existsSync(filePathVal)) {
@@ -69,7 +69,7 @@ class NLParamParser {
69
69
  * @returns {Promise}
70
70
  */
71
71
  async initializeNlpa(file_path) {
72
- let stat = fs.statSync(file_path);
72
+ const stat = fs.statSync(file_path);
73
73
 
74
74
  if (!(stat.mtime - prevmtime)) {
75
75
  /* File has been read */
@@ -139,10 +139,10 @@ class NLParamParser {
139
139
  * @return String The modified String returned
140
140
  */
141
141
  checkNLPforComments(str) {
142
- let str1 = new Array(str.length);
142
+ const str1 = new Array(str.length);
143
143
 
144
144
  for (let i = 0; i < str.length; i++) {
145
- let current_char = str[i];
145
+ const current_char = str[i];
146
146
  if (current_char == '#') {
147
147
  if (i != 0) {
148
148
  break; // No need to continue. Return the line
@@ -160,14 +160,14 @@ class NLParamParser {
160
160
  * @param {string} ibuf
161
161
  */
162
162
  addNLPListElement(ibuf) {
163
- let res = ibuf.split(/\r?\n/).filter(element => element);
163
+ const res = ibuf.split(/\r?\n/).filter(element => element);
164
164
  for (let i = 0; i < res.length; i++) {
165
165
  if (res[i].charAt(0) != '(') {
166
166
  res[i] = '(' + res[i] + ')';
167
167
  }
168
- let nvp = createNVPair(res[i]);
169
- let name = nvp.name;
170
- let uname = name.toUpperCase();
168
+ const nvp = createNVPair(res[i]);
169
+ const name = nvp.name;
170
+ const uname = name.toUpperCase();
171
171
  nvp.name = uname;
172
172
  const unames = uname.split(","); //multiple aliases (alias1, alias2, alias3)
173
173
  for (let i = 0; i < unames.length; i++) {
@@ -191,7 +191,7 @@ class NLParamParser {
191
191
  * @returns {string}
192
192
  */
193
193
  findValueOf(key) {
194
- let myarr = key.split('/');
194
+ const myarr = key.split('/');
195
195
  return (findValue(this.ht.get(myarr[0].toUpperCase()), myarr));
196
196
  }
197
197
 
@@ -59,6 +59,7 @@ class SessionAtts {
59
59
  this.nt.tcpNoDelay = true;
60
60
  this.uuid = uuid;
61
61
  this.nt.sslServerDNMatch = true;
62
+ this.nt.sslAllowWeakDNMatch = false;
62
63
  }
63
64
 
64
65
  /**
@@ -100,6 +101,9 @@ class SessionAtts {
100
101
  if (typeof params.sslServerDNMatch === 'boolean') {
101
102
  this.nt.sslServerDNMatch = params.sslServerDNMatch;
102
103
  }
104
+ if (typeof params.sslAllowWeakDNMatch === 'boolean') {
105
+ this.nt.sslAllowWeakDNMatch = params.sslAllowWeakDNMatch;
106
+ }
103
107
  if (typeof params.sslServerCertDN === 'string') {
104
108
  this.nt.sslServerCertDN = params.sslServerCertDN;
105
109
  }