oracledb 5.3.0 → 5.4.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 (39) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/LICENSE.txt +443 -0
  3. package/NOTICE.txt +1 -0
  4. package/README.md +7 -4
  5. package/THIRD_PARTY_LICENSES.txt +52 -0
  6. package/build/Release/oracledb-5.4.0-darwin-x64.node +0 -0
  7. package/build/Release/oracledb-5.4.0-darwin-x64.node-buildinfo.txt +1 -0
  8. package/build/Release/oracledb-5.4.0-linux-x64.node +0 -0
  9. package/build/Release/oracledb-5.4.0-linux-x64.node-buildinfo.txt +1 -0
  10. package/build/Release/oracledb-5.4.0-win32-x64.node +0 -0
  11. package/build/Release/oracledb-5.4.0-win32-x64.node-buildinfo.txt +1 -0
  12. package/lib/aqDeqOptions.js +1 -1
  13. package/lib/aqEnqOptions.js +1 -1
  14. package/lib/aqMessage.js +1 -1
  15. package/lib/aqQueue.js +1 -1
  16. package/lib/connection.js +28 -3
  17. package/lib/dbObject.js +1 -1
  18. package/lib/lob.js +1 -1
  19. package/lib/oracledb.js +61 -1
  20. package/lib/pool.js +14 -1
  21. package/lib/poolStatistics.js +1 -1
  22. package/lib/queryStream.js +1 -1
  23. package/lib/resultset.js +1 -1
  24. package/lib/sodaCollection.js +1 -1
  25. package/lib/sodaDatabase.js +1 -1
  26. package/lib/sodaDocCursor.js +1 -1
  27. package/lib/sodaDocument.js +1 -1
  28. package/lib/sodaOperation.js +1 -1
  29. package/lib/util.js +14 -4
  30. package/package/install.js +1 -1
  31. package/package/prunebinaries.js +1 -1
  32. package/package.json +2 -2
  33. package/LICENSE.md +0 -2485
  34. package/build/Release/oracledb-5.3.0-darwin-x64.node +0 -0
  35. package/build/Release/oracledb-5.3.0-darwin-x64.node-buildinfo.txt +0 -1
  36. package/build/Release/oracledb-5.3.0-linux-x64.node +0 -0
  37. package/build/Release/oracledb-5.3.0-linux-x64.node-buildinfo.txt +0 -1
  38. package/build/Release/oracledb-5.3.0-win32-x64.node +0 -0
  39. package/build/Release/oracledb-5.3.0-win32-x64.node-buildinfo.txt +0 -1
package/lib/connection.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2016, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -172,7 +172,20 @@ async function close(a1) {
172
172
  nodbUtil.assert(nodbUtil.isObject(a1), 'NJS-005', 1);
173
173
  options = a1;
174
174
  }
175
- await this._close(options);
175
+
176
+ // If already in the process of closing, throw an error instead of doing
177
+ // a roundtrip
178
+ if (this._closing) {
179
+ throw new Error (nodbUtil.getErrorMessage('NJS-003'));
180
+ }
181
+
182
+ this._closing = true;
183
+ try {
184
+ await this._close(options);
185
+ } finally {
186
+ this._closing = false;
187
+ }
188
+
176
189
  for (const cls of Object.values(this._dbObjectClasses)) {
177
190
  cls.prototype.constructor = Object;
178
191
  cls.prototype = null;
@@ -453,7 +466,6 @@ async function tpcRollback(xid) {
453
466
  }
454
467
 
455
468
 
456
-
457
469
  // define class
458
470
  class Connection extends EventEmitter {
459
471
 
@@ -462,6 +474,7 @@ class Connection extends EventEmitter {
462
474
  this._dbObjectClasses = {};
463
475
  this._requestQueue = [];
464
476
  this._inProgress = false;
477
+ this._closing = false;
465
478
  }
466
479
 
467
480
  // extend class with promisified functions
@@ -541,6 +554,18 @@ class Connection extends EventEmitter {
541
554
  return (this._getSodaDatabase());
542
555
  }
543
556
 
557
+ //--------------------------------------------------------------------------
558
+ // isHealthy()
559
+ // To get the health status of the connection.
560
+ // NOTE: if this function returns false, the application must close the
561
+ // connection obect.
562
+ // This is a synchronous call.
563
+ //---------------------------------------------------------------------------
564
+ isHealthy() {
565
+ return (!this._closing && this._isHealthy());
566
+ }
567
+
568
+
544
569
  // The queryStream function is similar to execute except that it immediately
545
570
  // returns a QueryStream.
546
571
  queryStream(sql, binding, options) {
package/lib/dbObject.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
1
+ // Copyright (c) 2019, 2022, Oracle and/or its affiliates.
2
2
  //
3
3
  //----------------------------------------------------------------------------
4
4
  //
package/lib/lob.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2016, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
package/lib/oracledb.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2015, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -105,6 +105,7 @@ class OracleDb {
105
105
  this.createPool = nodbUtil.callbackify(createPool).bind(_oracledb);
106
106
  this.shutdown = nodbUtil.callbackify(shutdown).bind(_oracledb);
107
107
  this.startup = nodbUtil.callbackify(startup).bind(_oracledb);
108
+ this.initOracleClient = this.initOracleClient.bind(_oracledb);
108
109
  }
109
110
 
110
111
  // temporary method for determining if an object is a date until
@@ -198,6 +199,39 @@ async function createPool(poolAttrs) {
198
199
  tempUsedPoolAliases[poolAlias] = true;
199
200
  }
200
201
 
202
+ if (adjustedPoolAttrs.accessToken !== undefined) {
203
+ // token and privateKey must be set for token based
204
+ // authentication
205
+ if (adjustedPoolAttrs.accessToken.token === undefined ||
206
+ adjustedPoolAttrs.accessToken.token === '' ||
207
+ adjustedPoolAttrs.accessToken.privateKey === undefined ||
208
+ adjustedPoolAttrs.accessToken.privateKey === '') {
209
+ throw new Error(nodbUtil.getErrorMessage('NJS-084'));
210
+ }
211
+
212
+ // cannot set username or password for token based authentication
213
+ if (adjustedPoolAttrs.user !== undefined ||
214
+ adjustedPoolAttrs.password !== undefined) {
215
+ throw new Error(nodbUtil.getErrorMessage('NJS-084'));
216
+ }
217
+
218
+ // homogeneous and externalAuth must be set to true for token based
219
+ // authentication
220
+ if (adjustedPoolAttrs.homogeneous === false ||
221
+ adjustedPoolAttrs.externalAuth === false) {
222
+ throw new Error(nodbUtil.getErrorMessage('NJS-085'));
223
+ }
224
+
225
+ adjustedPoolAttrs.token = adjustedPoolAttrs.accessToken.token;
226
+ adjustedPoolAttrs.privateKey =
227
+ adjustedPoolAttrs.accessToken.privateKey;
228
+ }
229
+
230
+ if (adjustedPoolAttrs.accessToken === undefined &&
231
+ adjustedPoolAttrs.accessTokenCallback !== undefined) {
232
+ throw new Error(nodbUtil.getErrorMessage('NJS-084'));
233
+ }
234
+
201
235
  try {
202
236
  const pool = await this._createPool(adjustedPoolAttrs);
203
237
 
@@ -270,6 +304,32 @@ async function getConnection(a1) {
270
304
 
271
305
  // otherwise, create a new standalone connection
272
306
  } else {
307
+ if (connAttrs.accessToken !== undefined) {
308
+ // token and privateKey must be set for token based
309
+ // authentication
310
+ if (connAttrs.accessToken.token === undefined ||
311
+ connAttrs.accessToken.token === '' ||
312
+ connAttrs.accessToken.privateKey === undefined ||
313
+ connAttrs.accessToken.privateKey === '') {
314
+ throw new Error(nodbUtil.getErrorMessage('NJS-084'));
315
+ }
316
+
317
+ // cannot set username or password for token based authentication
318
+ if (connAttrs.user !== undefined ||
319
+ connAttrs.password !== undefined) {
320
+ throw new Error(nodbUtil.getErrorMessage('NJS-084'));
321
+ }
322
+
323
+ // externalAuth must be set to true for token based authentication
324
+ if (connAttrs.externalAuth === false) {
325
+ throw new Error(nodbUtil.getErrorMessage('NJS-086'));
326
+ }
327
+
328
+ connAttrs.token = connAttrs.accessToken.token;
329
+ connAttrs.privateKey =
330
+ connAttrs.accessToken.privateKey;
331
+ }
332
+
273
333
  try {
274
334
  return await this._getConnection(connAttrs);
275
335
  } catch (err) {
package/lib/pool.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2016, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -488,6 +488,18 @@ function _setup(poolAttrs, poolAlias, oracledb) {
488
488
  }
489
489
 
490
490
 
491
+ //-----------------------------------------------------------------------------
492
+ // setAccessToken()
493
+ // set parameters for token based authentication
494
+ //-----------------------------------------------------------------------------
495
+ async function setAccessToken(options) {
496
+ // check arguments
497
+ nodbUtil.checkArgCount(arguments, 1, 1);
498
+ nodbUtil.assert(nodbUtil.isObject(options), 'NJS-005', 1);
499
+ await this._setAccessToken(options);
500
+ }
501
+
502
+
491
503
  class Pool extends EventEmitter {
492
504
 
493
505
  _extend(oracledb) {
@@ -497,6 +509,7 @@ class Pool extends EventEmitter {
497
509
  this.close = nodbUtil.callbackify(close);
498
510
  this.getConnection = nodbUtil.callbackify(getConnection);
499
511
  this.reconfigure = nodbUtil.callbackify(reconfigure);
512
+ this.setAccessToken = nodbUtil.callbackify(setAccessToken);
500
513
  this.logStatistics = logStatistics;
501
514
  this.getStatistics = getStatistics;
502
515
  this.terminate = this.close;
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2021, 2022, Oracle and/or its affiliates.
2
2
  //-----------------------------------------------------------------------------
3
3
  //
4
4
  // You may not use the identified files except in compliance with the Apache
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2015, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
package/lib/resultset.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2016, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2018, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2018, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2018, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2018, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2018, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
package/lib/util.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved
1
+ // Copyright (c) 2016, 2022, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
@@ -66,7 +66,10 @@ const errorMessages = {
66
66
  'NJS-076': 'NJS-076: connection request rejected. Pool queue length queueMax %d reached',
67
67
  'NJS-081': 'NJS-081: concurrent operations on a connection are disabled',
68
68
  'NJS-082': 'NJS-082: connection pool is being reconfigured',
69
- 'NJS-083': 'NJS-083: pool statistics not enabled'
69
+ 'NJS-083': 'NJS-083: pool statistics not enabled',
70
+ 'NJS-084': 'NJS-084: invalid or missing parameter with token based authentication. The token and privateKey attributes must contain values. Other credentials cannot be specified',
71
+ 'NJS-085': 'NJS-085: invalid connection pool configuration with token based authentication. The homogeneous and externalAuth attributes must be set to true',
72
+ 'NJS-086': 'NJS-086: invalid standalone configuration with token based authentication. The externalAuth attribute must be set to true'
70
73
  };
71
74
 
72
75
  // getInstallURL returns a string with installation URL
@@ -170,12 +173,15 @@ module.exports.checkArgCount = checkArgCount;
170
173
  // is resolved or rejected and the callback invoked; otherwise, the function is
171
174
  // called unchanged and a promise is returned
172
175
  function callbackify(func) {
173
- return function() {
176
+ const wrapper = function() {
174
177
 
175
178
  // if last argument is not a function, simply invoke the function as usual
176
179
  // and a promise will be returned
177
180
  if (typeof arguments[arguments.length - 1] !== 'function') {
178
- return func.apply(this, arguments);
181
+ return func.apply(this, arguments).catch(function stackCapture(e) {
182
+ Error.captureStackTrace(e, stackCapture);
183
+ throw e;
184
+ });
179
185
  }
180
186
 
181
187
  // otherwise, resolve or reject the promise and invoke the callback
@@ -186,6 +192,10 @@ function callbackify(func) {
186
192
  }, cb);
187
193
 
188
194
  };
195
+ if (func.name) {
196
+ Object.defineProperty(wrapper, 'name', { value: func.name });
197
+ }
198
+ return wrapper;
189
199
  }
190
200
 
191
201
  module.exports.callbackify = callbackify;
@@ -1,4 +1,4 @@
1
- /* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. */
1
+ /* Copyright (c) 2017, 2022, Oracle and/or its affiliates. */
2
2
 
3
3
  /******************************************************************************
4
4
  *
@@ -1,4 +1,4 @@
1
- /* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. */
1
+ /* Copyright (c) 2019, 2022, Oracle and/or its affiliates. */
2
2
 
3
3
  /******************************************************************************
4
4
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "oracledb",
3
- "version": "5.3.0",
4
- "description": "A Node.js module for Oracle Database access",
3
+ "version": "5.4.0",
4
+ "description": "A Node.js module for Oracle Database access from JavaScript and TypeScript",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "http://oracle.github.io/node-oracledb/",
7
7
  "keywords": [