oracledb 5.5.0 → 6.0.1

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 (107) hide show
  1. package/CHANGELOG.md +1 -1875
  2. package/LICENSE.txt +8 -222
  3. package/NOTICE.txt +1 -1
  4. package/README.md +38 -30
  5. package/SECURITY.md +38 -0
  6. package/build/Release/oracledb-6.0.1-darwin-x64.node +0 -0
  7. package/build/Release/oracledb-6.0.1-darwin-x64.node-buildinfo.txt +1 -0
  8. package/build/Release/oracledb-6.0.1-js-buildinfo.txt +1 -0
  9. package/build/Release/oracledb-6.0.1-linux-arm64.node +0 -0
  10. package/build/Release/oracledb-6.0.1-linux-arm64.node-buildinfo.txt +1 -0
  11. package/build/Release/oracledb-6.0.1-linux-x64.node +0 -0
  12. package/build/Release/oracledb-6.0.1-linux-x64.node-buildinfo.txt +1 -0
  13. package/build/Release/oracledb-6.0.1-win32-x64.node +0 -0
  14. package/build/Release/oracledb-6.0.1-win32-x64.node-buildinfo.txt +1 -0
  15. package/examples/README.md +113 -0
  16. package/examples/dbconfig.js +100 -0
  17. package/examples/example.js +156 -0
  18. package/index.js +26 -0
  19. package/lib/aqDeqOptions.js +148 -8
  20. package/lib/aqEnqOptions.js +59 -7
  21. package/lib/aqMessage.js +118 -7
  22. package/lib/aqQueue.js +243 -53
  23. package/lib/connection.js +1326 -465
  24. package/lib/constants.js +203 -0
  25. package/lib/dbObject.js +346 -32
  26. package/lib/errors.js +785 -0
  27. package/lib/impl/aqDeqOptions.js +197 -0
  28. package/lib/impl/aqEnqOptions.js +89 -0
  29. package/lib/impl/aqMessage.js +134 -0
  30. package/lib/impl/aqQueue.js +81 -0
  31. package/lib/impl/connection.js +529 -0
  32. package/lib/impl/dbObject.js +159 -0
  33. package/lib/impl/index.js +59 -0
  34. package/lib/impl/lob.js +85 -0
  35. package/lib/impl/pool.js +195 -0
  36. package/lib/impl/resultset.js +223 -0
  37. package/lib/impl/sodaCollection.js +174 -0
  38. package/lib/impl/sodaDatabase.js +81 -0
  39. package/lib/impl/sodaDocCursor.js +63 -0
  40. package/lib/impl/sodaDocument.js +98 -0
  41. package/lib/impl/sodaOperation.js +109 -0
  42. package/lib/lob.js +157 -68
  43. package/lib/oracledb.js +1047 -345
  44. package/lib/pool.js +654 -465
  45. package/lib/poolStatistics.js +24 -9
  46. package/lib/queryStream.js +16 -8
  47. package/lib/resultset.js +291 -183
  48. package/lib/settings.js +191 -0
  49. package/lib/sodaCollection.js +214 -201
  50. package/lib/sodaDatabase.js +108 -71
  51. package/lib/sodaDocCursor.js +44 -32
  52. package/lib/sodaDocument.js +76 -14
  53. package/lib/sodaOperation.js +131 -118
  54. package/lib/thin/connection.js +1043 -0
  55. package/lib/thin/dbObject.js +630 -0
  56. package/lib/thin/index.js +40 -0
  57. package/lib/thin/lob.js +189 -0
  58. package/lib/thin/pool.js +481 -0
  59. package/lib/thin/protocol/buffer.js +1043 -0
  60. package/lib/thin/protocol/capabilities.js +121 -0
  61. package/lib/thin/protocol/constants.js +765 -0
  62. package/lib/thin/protocol/encryptDecrypt.js +185 -0
  63. package/lib/thin/protocol/messages/auth.js +349 -0
  64. package/lib/thin/protocol/messages/base.js +476 -0
  65. package/lib/thin/protocol/messages/commit.js +56 -0
  66. package/lib/thin/protocol/messages/dataType.js +391 -0
  67. package/lib/thin/protocol/messages/execute.js +312 -0
  68. package/lib/thin/protocol/messages/fetch.js +60 -0
  69. package/lib/thin/protocol/messages/index.js +53 -0
  70. package/lib/thin/protocol/messages/lobOp.js +201 -0
  71. package/lib/thin/protocol/messages/logOff.js +53 -0
  72. package/lib/thin/protocol/messages/ping.js +56 -0
  73. package/lib/thin/protocol/messages/protocol.js +78 -0
  74. package/lib/thin/protocol/messages/rollback.js +56 -0
  75. package/lib/thin/protocol/messages/sessionRelease.js +60 -0
  76. package/lib/thin/protocol/messages/withData.js +812 -0
  77. package/lib/thin/protocol/oson.js +661 -0
  78. package/lib/thin/protocol/packet.js +519 -0
  79. package/lib/thin/protocol/protocol.js +202 -0
  80. package/lib/thin/protocol/utils.js +89 -0
  81. package/lib/thin/resultSet.js +122 -0
  82. package/lib/thin/sqlnet/connStrategy.js +175 -0
  83. package/lib/thin/sqlnet/constants.js +199 -0
  84. package/lib/thin/sqlnet/ezConnectResolver.js +488 -0
  85. package/lib/thin/sqlnet/navNodes.js +870 -0
  86. package/lib/thin/sqlnet/networkSession.js +621 -0
  87. package/lib/thin/sqlnet/ntTcp.js +527 -0
  88. package/lib/thin/sqlnet/nvStrToNvPair.js +783 -0
  89. package/lib/thin/sqlnet/packet.js +405 -0
  90. package/lib/thin/sqlnet/paramParser.js +206 -0
  91. package/lib/thin/sqlnet/sessionAtts.js +160 -0
  92. package/lib/thin/statement.js +300 -0
  93. package/lib/thin/util.js +289 -0
  94. package/lib/transformer.js +252 -0
  95. package/lib/types.js +357 -0
  96. package/lib/util.js +196 -110
  97. package/lib/version.js +36 -0
  98. package/package/README.md +33 -30
  99. package/package/install.js +89 -64
  100. package/package/prunebinaries.js +60 -12
  101. package/package.json +3 -3
  102. package/build/Release/oracledb-5.5.0-darwin-x64.node +0 -0
  103. package/build/Release/oracledb-5.5.0-darwin-x64.node-buildinfo.txt +0 -1
  104. package/build/Release/oracledb-5.5.0-linux-x64.node +0 -0
  105. package/build/Release/oracledb-5.5.0-linux-x64.node-buildinfo.txt +0 -1
  106. package/build/Release/oracledb-5.5.0-win32-x64.node +0 -0
  107. 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, 2022, Oracle and/or its affiliates.
1
+ // Copyright (c) 2016, 2023, Oracle and/or its affiliates.
2
2
 
3
3
  //-----------------------------------------------------------------------------
4
4
  //
5
- // You may not use the identified files except in compliance with the Apache
6
- // License, Version 2.0 (the "License.")
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
- // Unless required by applicable law or agreed to in writing, software
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,35 @@
19
26
 
20
27
  'use strict';
21
28
 
29
+ const { Buffer } = require('buffer');
30
+ const errors = require('./errors.js');
31
+ const process = require('process');
22
32
  const util = require('util');
33
+ const types = require('./types.js');
23
34
 
24
35
  // node-oracledb version number
25
36
  let packageJSON;
26
37
  try {
27
38
  packageJSON = require('../package.json');
28
39
  } catch (err) {
29
- throw new Error('package.json is missing');
40
+ errors.throwErr(errors.ERR_MISSING_FILE, 'package.json');
30
41
  }
31
42
  const PACKAGE_JSON_VERSION = packageJSON.version;
32
- module.exports.PACKAGE_JSON_VERSION = PACKAGE_JSON_VERSION;
33
43
 
34
44
  // Directory containing the node-oracledb add-on binary
35
45
  const RELEASE_DIR = 'build/Release';
36
- module.exports.RELEASE_DIR = RELEASE_DIR;
37
46
 
38
47
  // The default node-oracledb add-on binary filename for this Node.js
39
48
  const BINARY_FILE = 'oracledb-' + PACKAGE_JSON_VERSION + '-' + process.platform + '-' + process.arch + '.node';
40
- module.exports.BINARY_FILE = BINARY_FILE;
41
49
 
42
50
  // Staging directory used by maintainers building the npm package
43
51
  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
52
 
77
53
  // getInstallURL returns a string with installation URL
78
54
  function getInstallURL() {
79
- return ('Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html');
55
+ return ('Node-oracledb installation instructions: https://node-oracledb.readthedocs.io/en/latest/user_guide/installation.html');
80
56
  }
81
57
 
82
- module.exports.getInstallURL = getInstallURL;
83
58
 
84
59
  // getInstallHelp returns a string with installation usage tips that may be helpful
85
60
  function getInstallHelp() {
@@ -96,7 +71,7 @@ function getInstallHelp() {
96
71
  url = 'https://www.oracle.com/database/technologies/instant-client.html\n';
97
72
  arch = process.arch;
98
73
  }
99
- mesg += 'You must have ' + arch + ' Oracle Client libraries configured with ldconfig, or in LD_LIBRARY_PATH.\n';
74
+ mesg += 'You must have Linux ' + arch + ' Oracle Client libraries configured with ldconfig, or in LD_LIBRARY_PATH.\n';
100
75
  mesg += 'If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from \n';
101
76
  mesg += url;
102
77
  } else if (process.platform === 'darwin') {
@@ -107,7 +82,7 @@ function getInstallHelp() {
107
82
  url = 'https://www.oracle.com/database/technologies/instant-client.html\n';
108
83
  arch = process.arch;
109
84
  }
110
- mesg += 'You must have the ' + arch + ' Oracle Instant Client Basic or Basic Light package libraries in\n';
85
+ mesg += 'You must have macOS ' + arch + ' Oracle Instant Client Basic or Basic Light package libraries in\n';
111
86
  mesg += '/usr/local/lib or set by calling oracledb.initOracleClient({libDir: "/my/instant_client_directory"}).\n';
112
87
  mesg += 'Oracle Instant Client can be downloaded from ' + url;
113
88
  } else if (process.platform === 'win32') {
@@ -121,7 +96,7 @@ function getInstallHelp() {
121
96
  url = 'https://www.oracle.com/database/technologies/instant-client.html\n';
122
97
  arch = process.arch;
123
98
  }
124
- mesg += 'You must have ' + arch + ' Oracle Client libraries in your PATH environment variable.\n';
99
+ mesg += 'You must have Windows ' + arch + ' Oracle Client libraries in your PATH environment variable.\n';
125
100
  mesg += 'If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from\n';
126
101
  mesg += url;
127
102
  mesg += 'A Microsoft Visual Studio Redistributable suitable for your Oracle client library version must be available.\n';
@@ -134,41 +109,6 @@ function getInstallHelp() {
134
109
  return mesg;
135
110
  }
136
111
 
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
112
  // The callbackify function is used to wrap async methods to add optional
173
113
  // callback support. If the last parameter passed to a method is a function,
174
114
  // then it is assumed that the callback pattern is being used and the promise
@@ -180,9 +120,8 @@ function callbackify(func) {
180
120
  // if last argument is not a function, simply invoke the function as usual
181
121
  // and a promise will be returned
182
122
  if (typeof arguments[arguments.length - 1] !== 'function') {
183
- return func.apply(this, arguments).catch(function stackCapture(e) {
184
- Error.captureStackTrace(e, stackCapture);
185
- throw e;
123
+ return func.apply(this, arguments).catch(function stackCapture(err) {
124
+ throw errors.transformErr(err, stackCapture);
186
125
  });
187
126
  }
188
127
 
@@ -191,8 +130,9 @@ function callbackify(func) {
191
130
  const cb = arguments[arguments.length - 1];
192
131
  func.apply(this, args).then(function(result) {
193
132
  cb(null, result);
194
- }, cb);
195
-
133
+ }, function stackCapture(err) {
134
+ cb(errors.transformErr(err, stackCapture));
135
+ });
196
136
  };
197
137
  if (func.name) {
198
138
  Object.defineProperty(wrapper, 'name', { value: func.name });
@@ -200,36 +140,37 @@ function callbackify(func) {
200
140
  return wrapper;
201
141
  }
202
142
 
203
- module.exports.callbackify = callbackify;
204
-
205
143
  // The serialize function is used to wrap methods to ensure that the connection
206
144
  // is not used concurrently by multiple threads
207
145
  function serialize(func) {
208
146
  return async function() {
209
147
 
210
- // determine the connection associated with the object
211
- const connection = this._getConnection();
148
+ let connImpl;
212
149
 
213
- // acquire the "lock"; this simply checks to see if another operation is in
214
- // progress, and if so, waits for it to complete
215
- await connection._acquireLock();
150
+ // determine the connection implementation associated with the object, if
151
+ // one currently exists and acquire the "lock"; this simply checks to see
152
+ // if another operation is in progress, and if so, waits for it to complete
153
+ if (this._impl) {
154
+ connImpl = this._impl._getConnImpl();
155
+ await connImpl._acquireLock();
156
+ }
216
157
 
217
158
  // call the function and ensure that the lock is "released" once the
218
- // function has completed -- either successfully or in failure
159
+ // function has completed -- either successfully or in failure -- but only
160
+ // if a connection implementation is currently associated with this object
219
161
  try {
220
162
  return await func.apply(this, arguments);
221
163
  } finally {
222
- connection._releaseLock();
164
+ if (connImpl)
165
+ connImpl._releaseLock();
223
166
  }
224
167
  };
225
168
  }
226
169
 
227
- module.exports.serialize = serialize;
228
-
229
170
  function preventConcurrent(func, errorCode) {
230
171
  return async function() {
231
172
  if (this._isActive)
232
- throw new Error(getErrorMessage(errorCode));
173
+ errors.throwErr(errorCode);
233
174
  this._isActive = true;
234
175
  try {
235
176
  return await func.apply(this, arguments);
@@ -239,31 +180,176 @@ function preventConcurrent(func, errorCode) {
239
180
  };
240
181
  }
241
182
 
242
- module.exports.preventConcurrent = preventConcurrent;
183
+ // The wrapFns() function is used to wrap the named methods on the prototype
184
+ // in multiple ways (serialize, preventConcurrent and callbackify); the
185
+ // arguments following the formal arguments contain the names of methods to
186
+ // wrap on the prototype; if the first extra argument is an error code, it is
187
+ // used to wrap to prevent concurrent access
188
+ function wrapFns(proto) {
189
+ let nameIndex = 1;
190
+ let preventConcurrentErrorCode;
191
+ if (typeof arguments[1] === 'number') {
192
+ nameIndex = 2;
193
+ preventConcurrentErrorCode = arguments[1];
194
+ }
195
+ for (let i = nameIndex; i < arguments.length; i++) {
196
+ const name = arguments[i];
197
+ const f = proto[name];
198
+ if (preventConcurrentErrorCode) {
199
+ proto[name] = callbackify(preventConcurrent(serialize(f),
200
+ preventConcurrentErrorCode));
201
+ } else
202
+ proto[name] = callbackify(serialize(f));
203
+ }
204
+ }
205
+
206
+ function isArrayOfStrings(value) {
207
+ if (!Array.isArray(value))
208
+ return false;
209
+ for (let i = 0; i < value.length; i++) {
210
+ if (typeof value[i] !== 'string')
211
+ return false;
212
+ }
213
+ return true;
214
+ }
243
215
 
244
216
  function isObject(value) {
245
217
  return value !== null && typeof value === 'object';
246
218
  }
247
219
 
248
- module.exports.isObject = isObject;
249
-
250
220
  function isObjectOrArray(value) {
251
221
  return (value !== null && typeof value === 'object') || Array.isArray(value);
252
222
  }
253
223
 
254
- module.exports.isObjectOrArray = isObjectOrArray;
224
+ function isShardingKey(value) {
225
+ if (!Array.isArray(value))
226
+ return false;
227
+ for (let i = 0; i < value.length; i++) {
228
+ const element = value[i];
229
+ const ok = typeof element === 'string' ||
230
+ typeof element === 'number' || Buffer.isBuffer(element) ||
231
+ util.isDate(element);
232
+ if (!ok)
233
+ return false;
234
+ }
235
+ return true;
236
+ }
255
237
 
256
238
  function isSodaDocument(value) {
257
239
  return (value != null && value._sodaDocumentMarker);
258
240
  }
259
241
 
260
242
  function isXid(value) {
261
- return (isObject(value) &&
262
- (value.formatId !== undefined) &&
263
- (value.globalTransactionId !== undefined) &&
264
- (value.branchQualifier !== undefined));
243
+ return (isObject(value) && Number.isInteger(value.formatId) &&
244
+ (Buffer.isBuffer(value.globalTransactionId) ||
245
+ typeof value.globalTransactionId === 'string') &&
246
+ (Buffer.isBuffer(value.branchQualifier) ||
247
+ typeof value.branchQualifier === 'string'));
265
248
  }
266
249
 
267
- module.exports.isXid = isXid;
250
+ function verifySodaDoc(content) {
251
+ if (isSodaDocument(content))
252
+ return content._impl;
253
+ errors.assertParamValue(isObject(content), 1);
254
+ return Buffer.from(JSON.stringify(content));
255
+ }
256
+
257
+ function isTokenExpired(token) {
258
+ errors.assert(typeof token === 'string', errors.ERR_TOKEN_BASED_AUTH);
259
+ if (token.split('.')[1] === undefined) {
260
+ errors.throwErr(errors.ERR_TOKEN_BASED_AUTH);
261
+ }
262
+
263
+ const base64Url = token.split('.')[1];
264
+ const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
265
+ const buff = Buffer.from(base64, 'base64');
266
+ const payloadInit = buff.toString('ascii');
267
+
268
+ let expiry = JSON.parse(payloadInit).exp;
269
+ errors.assert(expiry != undefined, errors.ERR_TOKEN_BASED_AUTH);
270
+ expiry = expiry * 1000;
271
+
272
+ return (new Date().getTime() > expiry);
273
+ }
274
+
275
+ function isTokenValid(accessToken) {
276
+ switch (typeof accessToken) {
277
+ case 'string':
278
+ if (accessToken === '') {
279
+ errors.throwErr(errors.ERR_TOKEN_BASED_AUTH);
280
+ }
281
+
282
+ return !isTokenExpired(accessToken);
283
+ case 'object':
284
+ if (accessToken.token === undefined ||
285
+ accessToken.token === '' ||
286
+ accessToken.privateKey === undefined ||
287
+ accessToken.privateKey === '') {
288
+ errors.throwErr(errors.ERR_TOKEN_BASED_AUTH);
289
+ }
290
+
291
+ return !isTokenExpired(accessToken.token);
292
+ default:
293
+ errors.throwErr(errors.ERR_TOKEN_BASED_AUTH);
294
+ }
295
+ }
268
296
 
269
- module.exports.isSodaDocument = isSodaDocument;
297
+ function isPrivateKeyValid(accessToken) {
298
+ errors.assert(typeof accessToken.privateKey === 'string',
299
+ errors.ERR_TOKEN_BASED_AUTH);
300
+
301
+ if (accessToken.privateKey.startsWith("-----BEGIN PRIVATE KEY-----") ||
302
+ accessToken.privateKey.endsWith("-----END PRIVATE KEY-----")) {
303
+ return false;
304
+ }
305
+
306
+ return true;
307
+ }
308
+
309
+ //-----------------------------------------------------------------------------
310
+ // addTypeProperties()
311
+ //
312
+ // Adds derived properties about the type as a convenience to the user.
313
+ // Currently this is only the name of type, which is either the name of the
314
+ // database object type (if the value refers to a database object) or the name
315
+ // of the Oracle database type.
316
+ // -----------------------------------------------------------------------------
317
+ function addTypeProperties(obj, attrName) {
318
+ const clsAttrName = attrName + "Class";
319
+ const nameAttrName = attrName + "Name";
320
+ const cls = obj[clsAttrName];
321
+ let dbType = obj[attrName];
322
+ if (typeof dbType === 'number') {
323
+ dbType = obj[attrName] = types.getTypeByNum(dbType);
324
+ }
325
+ if (cls) {
326
+ obj[nameAttrName] = cls.prototype.fqn;
327
+ } else if (dbType) {
328
+ obj[nameAttrName] = dbType.columnTypeName;
329
+ }
330
+ }
331
+
332
+ // define exports
333
+ module.exports = {
334
+ BINARY_FILE,
335
+ PACKAGE_JSON_VERSION,
336
+ RELEASE_DIR,
337
+ STAGING_DIR,
338
+ addTypeProperties,
339
+ callbackify,
340
+ getInstallURL,
341
+ getInstallHelp,
342
+ isArrayOfStrings,
343
+ isObject,
344
+ isObjectOrArray,
345
+ isPrivateKeyValid,
346
+ isShardingKey,
347
+ isSodaDocument,
348
+ isTokenExpired,
349
+ isTokenValid,
350
+ isXid,
351
+ preventConcurrent,
352
+ serialize,
353
+ verifySodaDoc,
354
+ wrapFns
355
+ };
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: 1,
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
- # Maintainers
9
+ # Building an Install Package
10
10
 
11
11
  In a clone or copy of the repository:
12
12
 
13
- - Run `npm run buildbinary`. This calls `buildbinary.js` to create a
14
- node-oracledb binary for the current operating system. Depending how Node.js
15
- was installed, you may need to run `npm install node-gyp -g` first.
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 binaries and
19
- related build metadata information files from all `package/Staging`
20
- directories to the `package/Staging` directory on one machine.
21
-
22
- - Run `npm run buildpackage`. This calls `buildpackage.js` to make the
23
- node-oracledb package containing the node-oracledb JavaScript files, the
24
- available binaries, and a `package.json` that has `install` and `prune` script
25
- targets. The package will be created in the top level directory. It can be
26
- uploaded to npmjs.com, or to your own local server, and then used as a
27
- dependency in your projects.
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
- - When running `npm install` with the created package, the `package.json`
32
- install script runs `install.js` to check the availability of a binary module
33
- for the current Node.js version and operating system architecture.
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 installation succeeds, space conscious users can then run `npm run prune`
36
- which removes pre-built binaries for all other architectures.
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
- - If `npm install` fails because a suitable binary is not available, users must
39
- then compile node-oracledb using source code from GitHub. Alternatively a
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
- The
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. This allows installation
49
- from GitHub [source
50
- code](https://oracle.github.io/node-oracledb/INSTALL.html#github) when no
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.