oracledb 5.5.0 → 6.0.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.
- package/CHANGELOG.md +1 -1875
- package/LICENSE.txt +8 -222
- package/NOTICE.txt +1 -1
- package/README.md +38 -30
- package/SECURITY.md +38 -0
- package/build/Release/oracledb-6.0.0-darwin-x64.node +0 -0
- package/build/Release/oracledb-6.0.0-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-6.0.0-js-buildinfo.txt +1 -0
- package/build/Release/oracledb-6.0.0-linux-arm64.node +0 -0
- package/build/Release/oracledb-6.0.0-linux-arm64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-6.0.0-linux-x64.node +0 -0
- package/build/Release/oracledb-6.0.0-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-6.0.0-win32-x64.node +0 -0
- package/build/Release/oracledb-6.0.0-win32-x64.node-buildinfo.txt +1 -0
- package/examples/README.md +113 -0
- package/examples/dbconfig.js +100 -0
- package/examples/example.js +156 -0
- package/index.js +26 -0
- package/lib/aqDeqOptions.js +146 -7
- package/lib/aqEnqOptions.js +59 -7
- package/lib/aqMessage.js +118 -7
- package/lib/aqQueue.js +242 -53
- package/lib/connection.js +1324 -465
- package/lib/constants.js +203 -0
- package/lib/dbObject.js +346 -32
- package/lib/errors.js +781 -0
- package/lib/impl/aqDeqOptions.js +197 -0
- package/lib/impl/aqEnqOptions.js +89 -0
- package/lib/impl/aqMessage.js +134 -0
- package/lib/impl/aqQueue.js +81 -0
- package/lib/impl/connection.js +529 -0
- package/lib/impl/dbObject.js +159 -0
- package/lib/impl/index.js +59 -0
- package/lib/impl/lob.js +85 -0
- package/lib/impl/pool.js +195 -0
- package/lib/impl/resultset.js +223 -0
- package/lib/impl/sodaCollection.js +174 -0
- package/lib/impl/sodaDatabase.js +81 -0
- package/lib/impl/sodaDocCursor.js +63 -0
- package/lib/impl/sodaDocument.js +98 -0
- package/lib/impl/sodaOperation.js +109 -0
- package/lib/lob.js +156 -68
- package/lib/oracledb.js +1047 -345
- package/lib/pool.js +654 -465
- package/lib/poolStatistics.js +23 -9
- package/lib/queryStream.js +14 -7
- package/lib/resultset.js +291 -183
- package/lib/settings.js +191 -0
- package/lib/sodaCollection.js +214 -201
- package/lib/sodaDatabase.js +107 -71
- package/lib/sodaDocCursor.js +44 -32
- package/lib/sodaDocument.js +76 -14
- package/lib/sodaOperation.js +131 -118
- package/lib/thin/connection.js +1038 -0
- package/lib/thin/dbObject.js +629 -0
- package/lib/thin/index.js +40 -0
- package/lib/thin/lob.js +188 -0
- package/lib/thin/pool.js +481 -0
- package/lib/thin/protocol/buffer.js +1040 -0
- package/lib/thin/protocol/capabilities.js +116 -0
- package/lib/thin/protocol/constants.js +764 -0
- package/lib/thin/protocol/encryptDecrypt.js +185 -0
- package/lib/thin/protocol/messages/auth.js +348 -0
- package/lib/thin/protocol/messages/base.js +475 -0
- package/lib/thin/protocol/messages/commit.js +56 -0
- package/lib/thin/protocol/messages/dataType.js +382 -0
- package/lib/thin/protocol/messages/execute.js +312 -0
- package/lib/thin/protocol/messages/fetch.js +60 -0
- package/lib/thin/protocol/messages/index.js +53 -0
- package/lib/thin/protocol/messages/lobOp.js +200 -0
- package/lib/thin/protocol/messages/logOff.js +53 -0
- package/lib/thin/protocol/messages/ping.js +56 -0
- package/lib/thin/protocol/messages/protocol.js +78 -0
- package/lib/thin/protocol/messages/rollback.js +56 -0
- package/lib/thin/protocol/messages/sessionRelease.js +60 -0
- package/lib/thin/protocol/messages/withData.js +811 -0
- package/lib/thin/protocol/oson.js +660 -0
- package/lib/thin/protocol/packet.js +520 -0
- package/lib/thin/protocol/protocol.js +202 -0
- package/lib/thin/protocol/utils.js +88 -0
- package/lib/thin/resultSet.js +122 -0
- package/lib/thin/sqlnet/connStrategy.js +175 -0
- package/lib/thin/sqlnet/constants.js +199 -0
- package/lib/thin/sqlnet/ezConnectResolver.js +488 -0
- package/lib/thin/sqlnet/navNodes.js +870 -0
- package/lib/thin/sqlnet/networkSession.js +620 -0
- package/lib/thin/sqlnet/ntTcp.js +525 -0
- package/lib/thin/sqlnet/nvStrToNvPair.js +783 -0
- package/lib/thin/sqlnet/packet.js +405 -0
- package/lib/thin/sqlnet/paramParser.js +205 -0
- package/lib/thin/sqlnet/sessionAtts.js +160 -0
- package/lib/thin/statement.js +301 -0
- package/lib/thin/util.js +289 -0
- package/lib/transformer.js +250 -0
- package/lib/types.js +357 -0
- package/lib/util.js +194 -110
- package/lib/version.js +36 -0
- package/package/README.md +33 -30
- package/package/install.js +89 -64
- package/package/prunebinaries.js +60 -12
- package/package.json +3 -3
- package/build/Release/oracledb-5.5.0-darwin-x64.node +0 -0
- package/build/Release/oracledb-5.5.0-darwin-x64.node-buildinfo.txt +0 -1
- package/build/Release/oracledb-5.5.0-linux-x64.node +0 -0
- package/build/Release/oracledb-5.5.0-linux-x64.node-buildinfo.txt +0 -1
- package/build/Release/oracledb-5.5.0-win32-x64.node +0 -0
- package/build/Release/oracledb-5.5.0-win32-x64.node-buildinfo.txt +0 -1
package/lib/util.js
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
// Copyright (c) 2016,
|
|
1
|
+
// Copyright (c) 2016, 2023, Oracle and/or its affiliates.
|
|
2
2
|
|
|
3
3
|
//-----------------------------------------------------------------------------
|
|
4
4
|
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
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.
|
|
7
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.
|
|
8
15
|
// You may obtain a copy of the License at
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0.
|
|
10
16
|
//
|
|
11
|
-
//
|
|
12
|
-
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
13
|
-
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
|
14
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.
|
|
15
22
|
// See the License for the specific language governing permissions and
|
|
16
23
|
// limitations under the License.
|
|
17
24
|
//
|
|
@@ -19,67 +26,33 @@
|
|
|
19
26
|
|
|
20
27
|
'use strict';
|
|
21
28
|
|
|
29
|
+
const errors = require('./errors.js');
|
|
22
30
|
const util = require('util');
|
|
31
|
+
const types = require('./types.js');
|
|
23
32
|
|
|
24
33
|
// node-oracledb version number
|
|
25
34
|
let packageJSON;
|
|
26
35
|
try {
|
|
27
36
|
packageJSON = require('../package.json');
|
|
28
37
|
} catch (err) {
|
|
29
|
-
|
|
38
|
+
errors.throwErr(errors.ERR_MISSING_FILE, 'package.json');
|
|
30
39
|
}
|
|
31
40
|
const PACKAGE_JSON_VERSION = packageJSON.version;
|
|
32
|
-
module.exports.PACKAGE_JSON_VERSION = PACKAGE_JSON_VERSION;
|
|
33
41
|
|
|
34
42
|
// Directory containing the node-oracledb add-on binary
|
|
35
43
|
const RELEASE_DIR = 'build/Release';
|
|
36
|
-
module.exports.RELEASE_DIR = RELEASE_DIR;
|
|
37
44
|
|
|
38
45
|
// The default node-oracledb add-on binary filename for this Node.js
|
|
39
46
|
const BINARY_FILE = 'oracledb-' + PACKAGE_JSON_VERSION + '-' + process.platform + '-' + process.arch + '.node';
|
|
40
|
-
module.exports.BINARY_FILE = BINARY_FILE;
|
|
41
47
|
|
|
42
48
|
// Staging directory used by maintainers building the npm package
|
|
43
49
|
const STAGING_DIR = 'package/Staging';
|
|
44
|
-
module.exports.STAGING_DIR = STAGING_DIR;
|
|
45
|
-
|
|
46
|
-
// errorMessages is for NJS error messages used in the JavaScript layer
|
|
47
|
-
const errorMessages = {
|
|
48
|
-
'NJS-002': 'NJS-002: invalid pool',
|
|
49
|
-
'NJS-004': 'NJS-004: invalid value for property %s',
|
|
50
|
-
'NJS-005': 'NJS-005: invalid value for parameter %d',
|
|
51
|
-
'NJS-009': 'NJS-009: invalid number of parameters',
|
|
52
|
-
'NJS-017': 'NJS-017: concurrent operations on ResultSet are not allowed',
|
|
53
|
-
'NJS-023': 'NJS-023: concurrent operations on LOB are not allowed',
|
|
54
|
-
'NJS-037': 'NJS-037: incompatible type of value provided',
|
|
55
|
-
'NJS-040': 'NJS-040: connection request timeout. Request exceeded queueTimeout of %d',
|
|
56
|
-
'NJS-041': 'NJS-041: cannot convert ResultSet to QueryStream after invoking methods',
|
|
57
|
-
'NJS-042': 'NJS-042: cannot invoke ResultSet methods after converting to QueryStream',
|
|
58
|
-
'NJS-043': 'NJS-043: ResultSet already converted to QueryStream',
|
|
59
|
-
'NJS-045': 'NJS-045: cannot load a node-oracledb binary for Node.js ' + process.versions.node + ' (' + process.platform + ' ' + process.arch + ') %s',
|
|
60
|
-
'NJS-046': 'NJS-046: poolAlias "%s" already exists in the connection pool cache',
|
|
61
|
-
'NJS-047': 'NJS-047: poolAlias "%s" not found in the connection pool cache',
|
|
62
|
-
'NJS-064': 'NJS-064: connection pool is closing',
|
|
63
|
-
'NJS-065': 'NJS-065: connection pool was closed',
|
|
64
|
-
'NJS-067': 'NJS-067: a pre-built node-oracledb binary was not found for %s',
|
|
65
|
-
'NJS-069': 'NJS-069: node-oracledb %s requires Node.js %s or later',
|
|
66
|
-
'NJS-076': 'NJS-076: connection request rejected. Pool queue length queueMax %d reached',
|
|
67
|
-
'NJS-081': 'NJS-081: concurrent operations on a connection are disabled',
|
|
68
|
-
'NJS-082': 'NJS-082: connection pool is being reconfigured',
|
|
69
|
-
'NJS-083': 'NJS-083: pool statistics not enabled',
|
|
70
|
-
'NJS-084': 'NJS-084: invalid access token',
|
|
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',
|
|
73
|
-
'NJS-087': 'NJS-087: access token has expired',
|
|
74
|
-
'NJS-088': 'NJS-088: accessTokenCallback cannot be specified when accessToken is a function'
|
|
75
|
-
};
|
|
76
50
|
|
|
77
51
|
// getInstallURL returns a string with installation URL
|
|
78
52
|
function getInstallURL() {
|
|
79
|
-
return ('Node-oracledb installation instructions: https://
|
|
53
|
+
return ('Node-oracledb installation instructions: https://node-oracledb.readthedocs.io/en/latest/user_guide/installation.html');
|
|
80
54
|
}
|
|
81
55
|
|
|
82
|
-
module.exports.getInstallURL = getInstallURL;
|
|
83
56
|
|
|
84
57
|
// getInstallHelp returns a string with installation usage tips that may be helpful
|
|
85
58
|
function getInstallHelp() {
|
|
@@ -96,7 +69,7 @@ function getInstallHelp() {
|
|
|
96
69
|
url = 'https://www.oracle.com/database/technologies/instant-client.html\n';
|
|
97
70
|
arch = process.arch;
|
|
98
71
|
}
|
|
99
|
-
mesg += 'You must have ' + arch + ' Oracle Client libraries configured with ldconfig, or in LD_LIBRARY_PATH.\n';
|
|
72
|
+
mesg += 'You must have Linux ' + arch + ' Oracle Client libraries configured with ldconfig, or in LD_LIBRARY_PATH.\n';
|
|
100
73
|
mesg += 'If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from \n';
|
|
101
74
|
mesg += url;
|
|
102
75
|
} else if (process.platform === 'darwin') {
|
|
@@ -107,7 +80,7 @@ function getInstallHelp() {
|
|
|
107
80
|
url = 'https://www.oracle.com/database/technologies/instant-client.html\n';
|
|
108
81
|
arch = process.arch;
|
|
109
82
|
}
|
|
110
|
-
mesg += 'You must have
|
|
83
|
+
mesg += 'You must have macOS ' + arch + ' Oracle Instant Client Basic or Basic Light package libraries in\n';
|
|
111
84
|
mesg += '/usr/local/lib or set by calling oracledb.initOracleClient({libDir: "/my/instant_client_directory"}).\n';
|
|
112
85
|
mesg += 'Oracle Instant Client can be downloaded from ' + url;
|
|
113
86
|
} else if (process.platform === 'win32') {
|
|
@@ -121,7 +94,7 @@ function getInstallHelp() {
|
|
|
121
94
|
url = 'https://www.oracle.com/database/technologies/instant-client.html\n';
|
|
122
95
|
arch = process.arch;
|
|
123
96
|
}
|
|
124
|
-
mesg += 'You must have ' + arch + ' Oracle Client libraries in your PATH environment variable.\n';
|
|
97
|
+
mesg += 'You must have Windows ' + arch + ' Oracle Client libraries in your PATH environment variable.\n';
|
|
125
98
|
mesg += 'If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from\n';
|
|
126
99
|
mesg += url;
|
|
127
100
|
mesg += 'A Microsoft Visual Studio Redistributable suitable for your Oracle client library version must be available.\n';
|
|
@@ -134,41 +107,6 @@ function getInstallHelp() {
|
|
|
134
107
|
return mesg;
|
|
135
108
|
}
|
|
136
109
|
|
|
137
|
-
module.exports.getInstallHelp = getInstallHelp;
|
|
138
|
-
|
|
139
|
-
// getErrorMessage is used to get and format error messages to make throwing
|
|
140
|
-
// errors a little more convenient.
|
|
141
|
-
function getErrorMessage(errorCode) {
|
|
142
|
-
let args = Array.prototype.slice.call(arguments);
|
|
143
|
-
args[0] = errorMessages[errorCode];
|
|
144
|
-
return util.format.apply(util, args);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
module.exports.getErrorMessage = getErrorMessage;
|
|
148
|
-
|
|
149
|
-
// assert is typically used at the beginning of public functions to assert
|
|
150
|
-
// preconditions for the function to execute. Most commonly it is used to
|
|
151
|
-
// validate the number of arguments and their types and throw an error if they
|
|
152
|
-
// don't match what is expected.
|
|
153
|
-
function assert(condition, errorCode, messageArg1) {
|
|
154
|
-
if (!condition) {
|
|
155
|
-
throw new Error(getErrorMessage(errorCode, messageArg1));
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
module.exports.assert = assert;
|
|
160
|
-
|
|
161
|
-
// checkArgCount is used to validate the number of arguments, particularly with
|
|
162
|
-
// optional parameters (range of number of parameters). If the number of
|
|
163
|
-
// arguments is not within the given range, an error is thrown.
|
|
164
|
-
function checkArgCount(args, minArgCount, maxArgCount) {
|
|
165
|
-
if (args.length < minArgCount || args.length > maxArgCount)
|
|
166
|
-
throw new Error(getErrorMessage('NJS-009'));
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
module.exports.checkArgCount = checkArgCount;
|
|
170
|
-
|
|
171
|
-
|
|
172
110
|
// The callbackify function is used to wrap async methods to add optional
|
|
173
111
|
// callback support. If the last parameter passed to a method is a function,
|
|
174
112
|
// then it is assumed that the callback pattern is being used and the promise
|
|
@@ -180,9 +118,8 @@ function callbackify(func) {
|
|
|
180
118
|
// if last argument is not a function, simply invoke the function as usual
|
|
181
119
|
// and a promise will be returned
|
|
182
120
|
if (typeof arguments[arguments.length - 1] !== 'function') {
|
|
183
|
-
return func.apply(this, arguments).catch(function stackCapture(
|
|
184
|
-
|
|
185
|
-
throw e;
|
|
121
|
+
return func.apply(this, arguments).catch(function stackCapture(err) {
|
|
122
|
+
throw errors.transformErr(err, stackCapture);
|
|
186
123
|
});
|
|
187
124
|
}
|
|
188
125
|
|
|
@@ -191,8 +128,9 @@ function callbackify(func) {
|
|
|
191
128
|
const cb = arguments[arguments.length - 1];
|
|
192
129
|
func.apply(this, args).then(function(result) {
|
|
193
130
|
cb(null, result);
|
|
194
|
-
},
|
|
195
|
-
|
|
131
|
+
}, function stackCapture(err) {
|
|
132
|
+
cb(errors.transformErr(err, stackCapture));
|
|
133
|
+
});
|
|
196
134
|
};
|
|
197
135
|
if (func.name) {
|
|
198
136
|
Object.defineProperty(wrapper, 'name', { value: func.name });
|
|
@@ -200,36 +138,37 @@ function callbackify(func) {
|
|
|
200
138
|
return wrapper;
|
|
201
139
|
}
|
|
202
140
|
|
|
203
|
-
module.exports.callbackify = callbackify;
|
|
204
|
-
|
|
205
141
|
// The serialize function is used to wrap methods to ensure that the connection
|
|
206
142
|
// is not used concurrently by multiple threads
|
|
207
143
|
function serialize(func) {
|
|
208
144
|
return async function() {
|
|
209
145
|
|
|
210
|
-
|
|
211
|
-
const connection = this._getConnection();
|
|
146
|
+
let connImpl;
|
|
212
147
|
|
|
213
|
-
//
|
|
214
|
-
//
|
|
215
|
-
|
|
148
|
+
// determine the connection implementation associated with the object, if
|
|
149
|
+
// one currently exists and acquire the "lock"; this simply checks to see
|
|
150
|
+
// if another operation is in progress, and if so, waits for it to complete
|
|
151
|
+
if (this._impl) {
|
|
152
|
+
connImpl = this._impl._getConnImpl();
|
|
153
|
+
await connImpl._acquireLock();
|
|
154
|
+
}
|
|
216
155
|
|
|
217
156
|
// call the function and ensure that the lock is "released" once the
|
|
218
|
-
// function has completed -- either successfully or in failure
|
|
157
|
+
// function has completed -- either successfully or in failure -- but only
|
|
158
|
+
// if a connection implementation is currently associated with this object
|
|
219
159
|
try {
|
|
220
160
|
return await func.apply(this, arguments);
|
|
221
161
|
} finally {
|
|
222
|
-
|
|
162
|
+
if (connImpl)
|
|
163
|
+
connImpl._releaseLock();
|
|
223
164
|
}
|
|
224
165
|
};
|
|
225
166
|
}
|
|
226
167
|
|
|
227
|
-
module.exports.serialize = serialize;
|
|
228
|
-
|
|
229
168
|
function preventConcurrent(func, errorCode) {
|
|
230
169
|
return async function() {
|
|
231
170
|
if (this._isActive)
|
|
232
|
-
|
|
171
|
+
errors.throwErr(errorCode);
|
|
233
172
|
this._isActive = true;
|
|
234
173
|
try {
|
|
235
174
|
return await func.apply(this, arguments);
|
|
@@ -239,31 +178,176 @@ function preventConcurrent(func, errorCode) {
|
|
|
239
178
|
};
|
|
240
179
|
}
|
|
241
180
|
|
|
242
|
-
|
|
181
|
+
// The wrapFns() function is used to wrap the named methods on the prototype
|
|
182
|
+
// in multiple ways (serialize, preventConcurrent and callbackify); the
|
|
183
|
+
// arguments following the formal arguments contain the names of methods to
|
|
184
|
+
// wrap on the prototype; if the first extra argument is an error code, it is
|
|
185
|
+
// used to wrap to prevent concurrent access
|
|
186
|
+
function wrapFns(proto) {
|
|
187
|
+
let nameIndex = 1;
|
|
188
|
+
let preventConcurrentErrorCode;
|
|
189
|
+
if (typeof arguments[1] === 'number') {
|
|
190
|
+
nameIndex = 2;
|
|
191
|
+
preventConcurrentErrorCode = arguments[1];
|
|
192
|
+
}
|
|
193
|
+
for (let i = nameIndex; i < arguments.length; i++) {
|
|
194
|
+
const name = arguments[i];
|
|
195
|
+
const f = proto[name];
|
|
196
|
+
if (preventConcurrentErrorCode) {
|
|
197
|
+
proto[name] = callbackify(preventConcurrent(serialize(f),
|
|
198
|
+
preventConcurrentErrorCode));
|
|
199
|
+
} else
|
|
200
|
+
proto[name] = callbackify(serialize(f));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function isArrayOfStrings(value) {
|
|
205
|
+
if (!Array.isArray(value))
|
|
206
|
+
return false;
|
|
207
|
+
for (let i = 0; i < value.length; i++) {
|
|
208
|
+
if (typeof value[i] !== 'string')
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
243
213
|
|
|
244
214
|
function isObject(value) {
|
|
245
215
|
return value !== null && typeof value === 'object';
|
|
246
216
|
}
|
|
247
217
|
|
|
248
|
-
module.exports.isObject = isObject;
|
|
249
|
-
|
|
250
218
|
function isObjectOrArray(value) {
|
|
251
219
|
return (value !== null && typeof value === 'object') || Array.isArray(value);
|
|
252
220
|
}
|
|
253
221
|
|
|
254
|
-
|
|
222
|
+
function isShardingKey(value) {
|
|
223
|
+
if (!Array.isArray(value))
|
|
224
|
+
return false;
|
|
225
|
+
for (let i = 0; i < value.length; i++) {
|
|
226
|
+
const element = value[i];
|
|
227
|
+
const ok = typeof element === 'string' ||
|
|
228
|
+
typeof element === 'number' || Buffer.isBuffer(element) ||
|
|
229
|
+
util.isDate(element);
|
|
230
|
+
if (!ok)
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
255
235
|
|
|
256
236
|
function isSodaDocument(value) {
|
|
257
237
|
return (value != null && value._sodaDocumentMarker);
|
|
258
238
|
}
|
|
259
239
|
|
|
260
240
|
function isXid(value) {
|
|
261
|
-
return (isObject(value) &&
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
241
|
+
return (isObject(value) && Number.isInteger(value.formatId) &&
|
|
242
|
+
(Buffer.isBuffer(value.globalTransactionId) ||
|
|
243
|
+
typeof value.globalTransactionId === 'string') &&
|
|
244
|
+
(Buffer.isBuffer(value.branchQualifier) ||
|
|
245
|
+
typeof value.branchQualifier === 'string'));
|
|
265
246
|
}
|
|
266
247
|
|
|
267
|
-
|
|
248
|
+
function verifySodaDoc(content) {
|
|
249
|
+
if (isSodaDocument(content))
|
|
250
|
+
return content._impl;
|
|
251
|
+
errors.assertParamValue(isObject(content), 1);
|
|
252
|
+
return Buffer.from(JSON.stringify(content));
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function isTokenExpired(token) {
|
|
256
|
+
errors.assert(typeof token === 'string', errors.ERR_TOKEN_BASED_AUTH);
|
|
257
|
+
if (token.split('.')[1] === undefined) {
|
|
258
|
+
errors.throwErr(errors.ERR_TOKEN_BASED_AUTH);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const base64Url = token.split('.')[1];
|
|
262
|
+
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
263
|
+
const buff = Buffer.from(base64, 'base64');
|
|
264
|
+
const payloadInit = buff.toString('ascii');
|
|
265
|
+
|
|
266
|
+
let expiry = JSON.parse(payloadInit).exp;
|
|
267
|
+
errors.assert(expiry != undefined, errors.ERR_TOKEN_BASED_AUTH);
|
|
268
|
+
expiry = expiry * 1000;
|
|
269
|
+
|
|
270
|
+
return (new Date().getTime() > expiry);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function isTokenValid(accessToken) {
|
|
274
|
+
switch (typeof accessToken) {
|
|
275
|
+
case 'string':
|
|
276
|
+
if (accessToken === '') {
|
|
277
|
+
errors.throwErr(errors.ERR_TOKEN_BASED_AUTH);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return !isTokenExpired(accessToken);
|
|
281
|
+
case 'object':
|
|
282
|
+
if (accessToken.token === undefined ||
|
|
283
|
+
accessToken.token === '' ||
|
|
284
|
+
accessToken.privateKey === undefined ||
|
|
285
|
+
accessToken.privateKey === '') {
|
|
286
|
+
errors.throwErr(errors.ERR_TOKEN_BASED_AUTH);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return !isTokenExpired(accessToken.token);
|
|
290
|
+
default:
|
|
291
|
+
errors.throwErr(errors.ERR_TOKEN_BASED_AUTH);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
268
294
|
|
|
269
|
-
|
|
295
|
+
function isPrivateKeyValid(accessToken) {
|
|
296
|
+
errors.assert(typeof accessToken.privateKey === 'string',
|
|
297
|
+
errors.ERR_TOKEN_BASED_AUTH);
|
|
298
|
+
|
|
299
|
+
if (accessToken.privateKey.startsWith("-----BEGIN PRIVATE KEY-----") ||
|
|
300
|
+
accessToken.privateKey.endsWith("-----END PRIVATE KEY-----")) {
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
//-----------------------------------------------------------------------------
|
|
308
|
+
// addTypeProperties()
|
|
309
|
+
//
|
|
310
|
+
// Adds derived properties about the type as a convenience to the user.
|
|
311
|
+
// Currently this is only the name of type, which is either the name of the
|
|
312
|
+
// database object type (if the value refers to a database object) or the name
|
|
313
|
+
// of the Oracle database type.
|
|
314
|
+
// -----------------------------------------------------------------------------
|
|
315
|
+
function addTypeProperties(obj, attrName) {
|
|
316
|
+
const clsAttrName = attrName + "Class";
|
|
317
|
+
const nameAttrName = attrName + "Name";
|
|
318
|
+
const cls = obj[clsAttrName];
|
|
319
|
+
let dbType = obj[attrName];
|
|
320
|
+
if (typeof dbType === 'number') {
|
|
321
|
+
dbType = obj[attrName] = types.getTypeByNum(dbType);
|
|
322
|
+
}
|
|
323
|
+
if (cls) {
|
|
324
|
+
obj[nameAttrName] = cls.prototype.fqn;
|
|
325
|
+
} else if (dbType) {
|
|
326
|
+
obj[nameAttrName] = dbType.columnTypeName;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// define exports
|
|
331
|
+
module.exports = {
|
|
332
|
+
BINARY_FILE,
|
|
333
|
+
PACKAGE_JSON_VERSION,
|
|
334
|
+
RELEASE_DIR,
|
|
335
|
+
STAGING_DIR,
|
|
336
|
+
addTypeProperties,
|
|
337
|
+
callbackify,
|
|
338
|
+
getInstallURL,
|
|
339
|
+
getInstallHelp,
|
|
340
|
+
isArrayOfStrings,
|
|
341
|
+
isObject,
|
|
342
|
+
isObjectOrArray,
|
|
343
|
+
isPrivateKeyValid,
|
|
344
|
+
isShardingKey,
|
|
345
|
+
isSodaDocument,
|
|
346
|
+
isTokenExpired,
|
|
347
|
+
isTokenValid,
|
|
348
|
+
isXid,
|
|
349
|
+
preventConcurrent,
|
|
350
|
+
serialize,
|
|
351
|
+
verifySodaDoc,
|
|
352
|
+
wrapFns
|
|
353
|
+
};
|
package/lib/version.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
// Version information.
|
|
28
|
+
// Keep in sync with package.json.
|
|
29
|
+
// Leave the suffix an empty string for production releases.
|
|
30
|
+
|
|
31
|
+
module.exports = {
|
|
32
|
+
VERSION_MAJOR: 6,
|
|
33
|
+
VERSION_MINOR: 0,
|
|
34
|
+
VERSION_PATCH: 0,
|
|
35
|
+
VERSION_SUFFIX: ''
|
|
36
|
+
};
|
package/package/README.md
CHANGED
|
@@ -6,46 +6,49 @@ to create a custom package for hosting on a local server.
|
|
|
6
6
|
|
|
7
7
|
Most users do not need to use anything in this directory.
|
|
8
8
|
|
|
9
|
-
#
|
|
9
|
+
# Building an Install Package
|
|
10
10
|
|
|
11
11
|
In a clone or copy of the repository:
|
|
12
12
|
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
- If you want to build a package that installs node-oracledb with both 'Thin'
|
|
14
|
+
and 'Thick' modes, then run `npm run buildbinary`. This calls
|
|
15
|
+
`buildbinary.js` to create a node-oracledb 'Thick' mode binary for the
|
|
16
|
+
current operating system. Depending on how Node.js was installed, you may
|
|
17
|
+
need to run `npm install node-gyp -g` first.
|
|
16
18
|
|
|
17
19
|
You can run `npm run buildbinary` on each operating system architecture that
|
|
18
|
-
you want to include in your package. Copy the node-oracledb
|
|
19
|
-
related build metadata information files from all
|
|
20
|
-
directories to the `package/Staging` directory on one
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
you want to include in your package. Copy the node-oracledb Thick mode
|
|
21
|
+
binaries and related build metadata information files from all
|
|
22
|
+
`package/Staging` directories to the `package/Staging` directory on one
|
|
23
|
+
machine.
|
|
24
|
+
|
|
25
|
+
- On the machine with any (or no) desired Thick mode binaries in
|
|
26
|
+
`package/Staging`, run `npm run buildpackage`. This calls `buildpackage.js`
|
|
27
|
+
to make the node-oracledb package containing the node-oracledb JavaScript
|
|
28
|
+
files, the available Thick mode binaries, and a `package.json` that has
|
|
29
|
+
`install` and `prune` script targets. The package will be created in the top
|
|
30
|
+
level directory. It can be uploaded to npmjs.com by maintainers of
|
|
31
|
+
node-oracledb, or you can upload to your own local server and then use it as
|
|
32
|
+
a dependency in your projects.
|
|
28
33
|
|
|
29
34
|
# Package Installation
|
|
30
35
|
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
- Running `npm install` with the created package always installs node-oracledb
|
|
37
|
+
Thin mode. The installation script also runs `install.js` to check the
|
|
38
|
+
availability of the optional Thick mode binary module. A warning will be
|
|
39
|
+
displayed if the binary is not found for the current Node.js version and
|
|
40
|
+
operating system architecture.
|
|
34
41
|
|
|
35
|
-
- If
|
|
36
|
-
|
|
42
|
+
- If you are space-conscious, then run `npm run prune` after installation.
|
|
43
|
+
This removes pre-built binaries for all other architectures.
|
|
37
44
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
different version of node-oracledb, Node.js, or different operating system may
|
|
41
|
-
have a suitable pre-built binary available. See
|
|
42
|
-
https://github.com/oracle/node-oracledb/releases for information about Node.js
|
|
43
|
-
versions and pre-built node-oracledb binaries.
|
|
45
|
+
If you only ever want Thin mode, then remove all the Thick mode binaries by
|
|
46
|
+
running `npm run prune all`.
|
|
44
47
|
|
|
45
|
-
|
|
48
|
+
Note the
|
|
46
49
|
[`package.json`](https://github.com/oracle/node-oracledb/blob/main/package.json)
|
|
47
50
|
in GitHub doesn't have an `install` script target by default. This means that
|
|
48
|
-
node-gyp will be invoked to compile node-oracledb
|
|
49
|
-
from GitHub [source
|
|
50
|
-
code](https://
|
|
51
|
-
suitable pre-built binary is available.
|
|
51
|
+
node-gyp will be invoked to compile the optional node-oracledb Thick mode
|
|
52
|
+
binary. This allows installation of Thick mode from GitHub [source
|
|
53
|
+
code](https://node-oracledb.readthedocs.io/en/latest/user_guide/installation.html#github)
|
|
54
|
+
when no suitable pre-built binary is available.
|