Skip to content

Commit c2db4ae

Browse files
committed
Release 5.4.0
1 parent 2aadf73 commit c2db4ae

21 files changed

+138
-28
lines changed

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
# node-oracledb-prebuilt-for-lambda
22

33
- This module is forked from the currently un-maintained [node-oracledb-for-lambda](https://github.com/nalbion/node-oracledb-for-lambda).
4-
- Core oracledb libraries are derived from [node-oracledb](https://github.com/oracle/node-oracledb) v5.3.0
5-
- 5.3.0: Prebuilt for use with AWS Lambda nodejs12.x Runtime (Built using nodejsv12.18.3)
4+
- Core oracledb libraries are derived from [node-oracledb](https://github.com/oracle/node-oracledb) v5.4.0
5+
- 5.4.0: Prebuilt for use with AWS Lambda nodejs12.x Runtime (Built using nodejsv12.18.3)
66
- Also tested to work with AWS Lambda nodejs14.x Runtime
77

88
The scripts to reproduce the build process can be found at [node-oracledb-lambda-test](https://github.com/romanbalayan/node-oracledb-lambda-test).
99

1010
# Usage
1111

1212
```bash
13-
npm install --save oracledb-prebuilt-for-lambda@5.3.0
13+
npm install --save oracledb-prebuilt-for-lambda@5.4.0
1414
```
1515

1616
# Versioning
1717
- Changed release version to match that of underlying node-oracledb version.
18-
- i.e. for release based on oracledb 5.3.0, release will be oracledb-prebuilt-for-lambda@5.3.0
18+
- i.e. for release based on oracledb 5.4.0, release will be oracledb-prebuilt-for-lambda@5.4.0
1919

2020

2121
# Releases
2222
| node-oracledb | oracledb-prebuilt-for-lambda |
2323
| ------------------- | ---------- |
24+
| 5.4.0 | 5.4.0 |
2425
| 5.3.0 | 5.3.0 |
2526
| 5.2.0 | 5.2.0 |
2627
| 5.1.0 | 5.1.0 |
@@ -31,6 +32,7 @@ npm install --save [email protected]
3132

3233

3334
# Changelog
35+
- v5.4.0: [node-oracledb v5.4.0 changelog](https://github.com/oracle/node-oracledb/blob/main/CHANGELOG.md#node-oracledb-v540-9-jun-2022)
3436
- v5.3.0: [node-oracledb v5.3.0 changelog](https://github.com/oracle/node-oracledb/blob/main/CHANGELOG.md#node-oracledb-v530-22-oct-2021)
3537
- v5.2.0: [node-oracledb v5.2.0 changelog](https://github.com/oracle/node-oracledb/blob/main/CHANGELOG.md#node-oracledb-v520-7-jun-2021)
3638
- v5.1.0: [node-oracledb v5.1.0 changelog](https://github.com/oracle/node-oracledb/blob/master/CHANGELOG.md#node-oracledb-v510-8-dec-2020)

build/Release/oracledb.node

9.47 KB
Binary file not shown.

lib/aqDeqOptions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved
1+
// Copyright (c) 2019, 2022, Oracle and/or its affiliates.
22

33
//-----------------------------------------------------------------------------
44
//

lib/aqEnqOptions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved
1+
// Copyright (c) 2019, 2022, Oracle and/or its affiliates.
22

33
//-----------------------------------------------------------------------------
44
//

lib/aqMessage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved
1+
// Copyright (c) 2019, 2022, Oracle and/or its affiliates.
22

33
//-----------------------------------------------------------------------------
44
//

lib/aqQueue.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -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.
22

33
//-----------------------------------------------------------------------------
44
//

lib/connection.js

+28-3
Original file line numberDiff line numberDiff line change
@@ -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.
22

33
//-----------------------------------------------------------------------------
44
//
@@ -172,7 +172,20 @@ async function close(a1) {
172172
nodbUtil.assert(nodbUtil.isObject(a1), 'NJS-005', 1);
173173
options = a1;
174174
}
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+
176189
for (const cls of Object.values(this._dbObjectClasses)) {
177190
cls.prototype.constructor = Object;
178191
cls.prototype = null;
@@ -453,7 +466,6 @@ async function tpcRollback(xid) {
453466
}
454467

455468

456-
457469
// define class
458470
class Connection extends EventEmitter {
459471

@@ -462,6 +474,7 @@ class Connection extends EventEmitter {
462474
this._dbObjectClasses = {};
463475
this._requestQueue = [];
464476
this._inProgress = false;
477+
this._closing = false;
465478
}
466479

467480
// extend class with promisified functions
@@ -541,6 +554,18 @@ class Connection extends EventEmitter {
541554
return (this._getSodaDatabase());
542555
}
543556

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+
544569
// The queryStream function is similar to execute except that it immediately
545570
// returns a QueryStream.
546571
queryStream(sql, binding, options) {

lib/dbObject.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -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.
22
//
33
//----------------------------------------------------------------------------
44
//

lib/lob.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -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.
22

33
//-----------------------------------------------------------------------------
44
//

lib/oracledb.js

+61-1
Original file line numberDiff line numberDiff line change
@@ -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.
22

33
//-----------------------------------------------------------------------------
44
//
@@ -105,6 +105,7 @@ class OracleDb {
105105
this.createPool = nodbUtil.callbackify(createPool).bind(_oracledb);
106106
this.shutdown = nodbUtil.callbackify(shutdown).bind(_oracledb);
107107
this.startup = nodbUtil.callbackify(startup).bind(_oracledb);
108+
this.initOracleClient = this.initOracleClient.bind(_oracledb);
108109
}
109110

110111
// temporary method for determining if an object is a date until
@@ -198,6 +199,39 @@ async function createPool(poolAttrs) {
198199
tempUsedPoolAliases[poolAlias] = true;
199200
}
200201

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+
201235
try {
202236
const pool = await this._createPool(adjustedPoolAttrs);
203237

@@ -270,6 +304,32 @@ async function getConnection(a1) {
270304

271305
// otherwise, create a new standalone connection
272306
} 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+
273333
try {
274334
return await this._getConnection(connAttrs);
275335
} catch (err) {

lib/pool.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -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.
22

33
//-----------------------------------------------------------------------------
44
//
@@ -488,6 +488,18 @@ function _setup(poolAttrs, poolAlias, oracledb) {
488488
}
489489

490490

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+
491503
class Pool extends EventEmitter {
492504

493505
_extend(oracledb) {
@@ -497,6 +509,7 @@ class Pool extends EventEmitter {
497509
this.close = nodbUtil.callbackify(close);
498510
this.getConnection = nodbUtil.callbackify(getConnection);
499511
this.reconfigure = nodbUtil.callbackify(reconfigure);
512+
this.setAccessToken = nodbUtil.callbackify(setAccessToken);
500513
this.logStatistics = logStatistics;
501514
this.getStatistics = getStatistics;
502515
this.terminate = this.close;

lib/poolStatistics.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -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.
22
//-----------------------------------------------------------------------------
33
//
44
// You may not use the identified files except in compliance with the Apache

lib/queryStream.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -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.
22

33
//-----------------------------------------------------------------------------
44
//

lib/resultset.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -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.
22

33
//-----------------------------------------------------------------------------
44
//

lib/sodaCollection.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -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.
22

33
//-----------------------------------------------------------------------------
44
//

lib/sodaDatabase.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -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.
22

33
//-----------------------------------------------------------------------------
44
//

lib/sodaDocCursor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -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.
22

33
//-----------------------------------------------------------------------------
44
//

lib/sodaDocument.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -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.
22

33
//-----------------------------------------------------------------------------
44
//

lib/sodaOperation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -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.
22

33
//-----------------------------------------------------------------------------
44
//

lib/util.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -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.
22

33
//-----------------------------------------------------------------------------
44
//
@@ -66,7 +66,10 @@ const errorMessages = {
6666
'NJS-076': 'NJS-076: connection request rejected. Pool queue length queueMax %d reached',
6767
'NJS-081': 'NJS-081: concurrent operations on a connection are disabled',
6868
'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'
7073
};
7174

7275
// getInstallURL returns a string with installation URL
@@ -170,12 +173,15 @@ module.exports.checkArgCount = checkArgCount;
170173
// is resolved or rejected and the callback invoked; otherwise, the function is
171174
// called unchanged and a promise is returned
172175
function callbackify(func) {
173-
return function() {
176+
const wrapper = function() {
174177

175178
// if last argument is not a function, simply invoke the function as usual
176179
// and a promise will be returned
177180
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+
});
179185
}
180186

181187
// otherwise, resolve or reject the promise and invoke the callback
@@ -186,6 +192,10 @@ function callbackify(func) {
186192
}, cb);
187193

188194
};
195+
if (func.name) {
196+
Object.defineProperty(wrapper, 'name', { value: func.name });
197+
}
198+
return wrapper;
189199
}
190200

191201
module.exports.callbackify = callbackify;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oracledb-prebuilt-for-lambda",
3-
"version": "5.3.0",
3+
"version": "5.4.0",
44
"description": "Node OracleDB Client, pre-built for AWS Lambda",
55
"main": "index.js",
66
"directories": {

0 commit comments

Comments
 (0)