Skip to content

Commit b8cd4f6

Browse files
committed
Sanitize code, add documentation and tests for 6.9 features
1 parent 7d6c8b2 commit b8cd4f6

File tree

12 files changed

+845
-29
lines changed

12 files changed

+845
-29
lines changed

doc/src/api_manual/oracledb.rst

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3969,6 +3969,57 @@ Oracledb Methods
39693969
path, such as from running ``ldconfig`` or set in the environment
39703970
variable ``LD_LIBRARY_PATH``.
39713971

3972+
.. method:: oracledb.registerConfigurationProviderHook()
3973+
3974+
.. versionadded:: 6.9
3975+
3976+
::
3977+
3978+
registerConfigurationProviderHook(String configProvider, Function fn)
3979+
3980+
Registers the :ref:`centralized configuration provider
3981+
<configproviderplugins>` extension modules. These registered modules will
3982+
be called and executed during standalone and pool connection creation.
3983+
3984+
If you have defined your own extension module for any particular
3985+
centralized configuration provider, you need to register it using this
3986+
method in your code.
3987+
3988+
The parameters of the ``oracledb.registerConfigurationProviderHook()`` method
3989+
are:
3990+
3991+
.. _registerconfigurationproviderhookattrs:
3992+
3993+
.. list-table-with-summary:: oracledb.registerConfigurationProviderHook() Parameters
3994+
:header-rows: 1
3995+
:class: wy-table-responsive
3996+
:align: center
3997+
:widths: 10 10 30
3998+
:width: 100%
3999+
:summary: The first column displays the parameter. The second column
4000+
displays the data type of the parameter. The third column displays
4001+
the description of the parameter.
4002+
4003+
* - Parameter
4004+
- Data Type
4005+
- Description
4006+
* - ``configProvider``
4007+
- String
4008+
- The centralized configuration provider extension that needs to be
4009+
accessed. The value can be the string "ociobject", "ocivault",
4010+
"azure", or "azurevault" which are the pre-supplied node-oracledb
4011+
configuration provider extensions.
4012+
* - ``fn``
4013+
- Function
4014+
- The hook function that needs to be registered. This hook
4015+
function will be invoked when :meth:`oracledb.getConnection()` or
4016+
:meth:`oracledb.createPool()` are called. The user hook function
4017+
is expected to return the configuration information from the
4018+
configuration provider specified in the ``configProvider``
4019+
parameter.
4020+
4021+
See :ref:`configproviderhookfn`.
4022+
39724023
.. method:: oracledb.registerProcessConfigurationHook()
39734024

39744025
.. versionadded:: 6.8

doc/src/release_notes.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ Common Changes
3535
<ocivault>`, and :ref:`Microsoft Azure Key Vault configuration provider
3636
<azurekeyvault>`.
3737

38+
#) Moved centralized configuration provider support to be part of the
39+
:ref:`plugins <configproviderplugins>` to prevent package build errors
40+
with external bundlers such as webpack and esbuild.
41+
See `Issue #1791 <https://github.com/oracle/node-oracledb/issues/1791>`__.
42+
3843
#) Added support for
3944
:ref:`instance principal authentication <_create_pool_oci_properties>`
4045
in :ref:`native IAM token-based authentication <cloudnativeauthoci>`
@@ -66,11 +71,6 @@ Common Changes
6671
Thin Mode Changes
6772
+++++++++++++++++
6873

69-
#) Moved centralized configuration provider support to be part of the
70-
plugins to prevent package build errors with external bundlers like
71-
webpack and esbuild. See:
72-
`Issue #1791 <https://github.com/oracle/node-oracledb/issues/1791>`__.
73-
7474
#) Fixed bug which forced node-oracledb to resolve the database host name
7575
even if a proxy was specified in the connect string. Now the proxy
7676
specified in the connect string will resolve the database host name.

doc/src/user_guide/connection_handling.rst

Lines changed: 72 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,10 @@ To use an OCI Object Storage Centralized Configuration Provider, you must:
670670

671671
2. Install the required OCI modules. See :ref:`ocimodules`.
672672

673-
3. :ref:`Use an OCI Object Storage connection string URL <connstringoci>`
673+
3. Load the :ref:`ociobject <ociobjectplugin>` plugin in your application using
674+
``require('oracledb/plugins/configProviders/ociobject')``.
675+
676+
4. :ref:`Use an OCI Object Storage connection string URL <connstringoci>`
674677
in the ``connectString`` property of connection and pool creation methods.
675678

676679
Note that node-oracledb caches configurations by default, see
@@ -806,7 +809,10 @@ To use an OCI Vault Centralized Configuration Provider, you must:
806809

807810
2. Install the required OCI modules. See :ref:`ocivaultmodules`.
808811

809-
3. :ref:`Use an OCI Vault connection string URL <connstringocivault>` in the
812+
3. Load the :ref:`ocivault <ocivaultplugin>` plugin in your application using
813+
``require('oracledb/plugins/configProviders/ocivault')``.
814+
815+
4. :ref:`Use an OCI Vault connection string URL <connstringocivault>` in the
810816
``connectString`` property of connection and pool creation methods.
811817

812818
Note that node-oracledb caches configurations by default, see
@@ -889,7 +895,10 @@ To use node-oracledb with Azure App Configuration, you must:
889895

890896
2. Install the required Azure Application modules. See :ref:`azuremodules`.
891897

892-
3. :ref:`Use an Azure App Configuration connection string URL
898+
3. Load the :ref:`azure <azureplugin>` plugin in your application using
899+
``require('oracledb/plugins/configProviders/azure')``.
900+
901+
4. :ref:`Use an Azure App Configuration connection string URL
893902
<connstringazure>` in the ``connectString`` parameter of connection and
894903
pool creation methods.
895904

@@ -1050,7 +1059,10 @@ To use node-oracledb with Azure Key Vault, you must:
10501059
2. Install the required Azure Application modules. See
10511060
:ref:`azurevaultmodules`.
10521061

1053-
3. :ref:`Use an Azure Key Vault connection string URL <connstringazurevault>`
1062+
3. Load the :ref:`azurevault <azurevaultplugin>` plugin in your application
1063+
using ``require('oracledb/plugins/configProviders/azurevault')``.
1064+
1065+
4. :ref:`Use an Azure Key Vault connection string URL <connstringazurevault>`
10541066
in the ``connectString`` parameter of connection and pool creation methods.
10551067

10561068
Note that node-oracledb caches configurations by default, see
@@ -2884,11 +2896,64 @@ the number of open connections does not fall below ``poolMin``.
28842896
Connection Hook Functions
28852897
=========================
28862898
2887-
Node-oracledb supports hook functions that can be used to customize connection
2899+
Node-oracledb supports centralized configuration provider and process
2900+
configuration hook functions that can be used to customize connection
28882901
logic.
28892902
2890-
Using oracledb.registerProcessConfigurationHook()
2891-
-------------------------------------------------
2903+
.. _configproviderhookfn:
2904+
2905+
Using Centralized Configuration Provider Hook Functions
2906+
-------------------------------------------------------
2907+
2908+
The :meth:`oracledb.registerConfigurationProviderHook()` method registers the
2909+
:ref:`centralized configuration provider <configproviderplugins>` extension
2910+
modules that were loaded in your code. When this method is called, it
2911+
registers a user hook function that will be called internally by node-oracledb
2912+
prior to connection or pool creation. The hook function will be invoked when
2913+
:meth:`oracledb.getConnection()` or :meth:`oracledb.createPool()` are called
2914+
with the ``connectString`` property prefixed with a specified configuration
2915+
provider. Your hook function can retrieve the connection information, which
2916+
node-oracledb can subsequently use to complete the connection or pool
2917+
creation.
2918+
2919+
Pre-supplied node-oracledb plugins such as :ref:`OCI Object Storage
2920+
(ociobject) <ociobjectplugin>`, :ref:`OCI Vault (ocivault) <ocivaultplugin>`,
2921+
:ref:`Azure App Configuration (azure) <azureplugin>`, and
2922+
:ref:`Azure Key Vault (azurevault) <azurevaultplugin>` make use of
2923+
:meth:`oracledb.registerConfigurationProviderHook()`. These plugins use the
2924+
information found in a connection method's ``connectString`` property which
2925+
allows node-oracledb to access the required information from the configuration
2926+
provider, and connect to Oracle Database with this information. For the
2927+
complete plugin implementation, see the respective folders of the
2928+
configuration providers in the `plugins/configProviders <https://github.com/
2929+
oracle/node-oracledb/tree/main/plugins/configProviders>`__ directory of the
2930+
node-oracledb package. Also, you can define your own plugins for centralized
2931+
configuration providers and register it using
2932+
:meth:`oracledb.registerConfigurationProviderHook()`, similar to how the
2933+
pre-supplied node-oracledb plugins are registered.
2934+
2935+
Once you define the plugin and register it using
2936+
:meth:`oracledb.registerConfigurationProviderHook`, you can connect to Oracle
2937+
Database using the information stored in the configuration provider, for
2938+
example, with OCI Vault:
2939+
2940+
.. code-block:: javascript
2941+
2942+
// Load the ocivault plugin
2943+
require('oracledb/plugins/configProviders/ocivault');
2944+
2945+
// Use an OCI vault connection string
2946+
const connection = await oracledb.getConnection({
2947+
connectString : "config-ocivault://ocid1.vaultsecret.oc1?oci_tenancy=abc123&oci_user=ociuser1&oci_fingerprint=ab:14:ba:13&oci_key_file=ociabc/ocikeyabc.pem"
2948+
});
2949+
2950+
For more information on the centralized configuration providers supported by
2951+
node-oracledb, see :ref:`configurationprovider`.
2952+
2953+
.. _processconfighookfns:
2954+
2955+
Using Process Configuration Hook Functions
2956+
------------------------------------------
28922957
28932958
The :meth:`oracledb.registerProcessConfigurationHook()` method registers
28942959
extension modules that were added to your code. When this method is called, it

doc/src/user_guide/extensions.rst

Lines changed: 144 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,33 @@ Extending node-oracledb
99
You can extend the functionalities of node-oracledb by using plugins. The
1010
plugins provided by node-oracledb are listed in this section.
1111

12+
.. _cloudnativeauthplugins:
13+
14+
Cloud Native Authentication Plugins
15+
===================================
16+
17+
.. versionadded:: 6.8
18+
19+
Node-oracledb provides pre-supplied plugins for cloud native authentication
20+
which are listed in this section. These plugins enable token generation using
21+
the Software Development Kit (SDK) of the respective token-authentication
22+
method.
23+
24+
The cloud native authentication token plugin implementation is available in
25+
the `plugins/token <https://github.com/oracle/node-oracledb/tree/main/plugins/
26+
token>`__ directory of the node-oracledb package.
27+
28+
To load these node-oracledb plugins in your application, use
29+
``require('oracledb/plugins/token/<name of plugin>')``, for example:
30+
31+
.. code-block:: javascript
32+
33+
require('oracledb/plugins/token/extensionOci');
34+
1235
.. _extensionociplugin:
1336

1437
Oracle Cloud Infrastructure (OCI) Cloud Native Authentication Plugin
15-
====================================================================
38+
--------------------------------------------------------------------
1639

1740
Node-oracledb's ``extensionOci`` plugin enables token generation using `OCI
1841
Software Development Kit (SDK) <https://www.npmjs.com/package/oci-sdk>`__ when
@@ -35,7 +58,7 @@ See :ref:`cloudnativeauthoci` for more information.
3558
.. _extensionazureplugin:
3659

3760
Azure Cloud Native Authentication Plugin
38-
========================================
61+
----------------------------------------
3962

4063
Node-oracledb's ``extensionAzure`` plugin enables token generation using `Azure
4164
Software Development Kit (SDK) <https://www.npmjs.com/~azure-sdk>`__ when
@@ -52,3 +75,122 @@ that generates OAuth 2.0 tokens. This function is internally invoked when the
5275
:meth:`oracledb.getConnection()` or :meth:`oracledb.createPool()`.
5376

5477
See :ref:`cloudnativeauthoauth` for more information.
78+
79+
.. _configproviderplugins:
80+
81+
Centralized Configuration Provider Plugins
82+
==========================================
83+
84+
.. versionadded:: 6.9
85+
86+
Node-oracledb provides pre-supplied plugins for centralized configuration
87+
providers which are listed in this section. These plugins provide access to
88+
database connection credentials and application configuration information
89+
stored in a centralized configuration provider.
90+
91+
The centralized configuration provider plugin implementation is available in
92+
the `plugins/configProviders <https://github.com/oracle/node-oracledb/tree/
93+
main/plugins/configProviders>`__ directory of the node-oracledb package.
94+
95+
To load these node-oracledb plugins in your application, use
96+
``require('oracledb/plugins/configProviders/<name of plugin>')``, for example:
97+
98+
.. code-block:: javascript
99+
100+
require('oracledb/plugins/configProviders/ociobject');
101+
102+
.. _ociobjectplugin:
103+
104+
OCI Object Storage Centralized Configuration Provider Plugin
105+
------------------------------------------------------------
106+
107+
.. versionadded:: 6.9
108+
109+
``ociobject`` is a plugin that can be loaded in your application to provide
110+
access to configuration information stored in
111+
:ref:`Oracle Cloud Infrastructure (OCI) Object Storage <ociobjstorage>`.
112+
113+
This plugin is implemented as a :ref:`centralized configuration provider hook
114+
function <configproviderhookfn>` to handle connection strings which have the
115+
prefix ``config-ociobject``, see :ref:`OCI Object Storage connection strings
116+
<connstringoci>`.
117+
118+
To load the ``ociobject`` plugin in your application, use::
119+
120+
.. code-block:: javascript
121+
122+
require('oracledb/plugins/configProviders/ociobject');
123+
124+
See :ref:`ociobjstorage` for more information.
125+
126+
.. _ocivaultplugin:
127+
128+
OCI Vault Centralized Configuration Provider Plugin
129+
---------------------------------------------------
130+
131+
.. versionadded:: 6.9
132+
133+
``ocivault`` is a plugin that can be loaded in your application to provide
134+
access to configuration information stored in
135+
:ref:`Oracle Cloud Infrastructure (OCI) Vault <ocivault>`.
136+
137+
This plugin is implemented as a :ref:`centralized configuration provider hook
138+
function <configproviderhookfn>` to handle connection strings which have the
139+
prefix ``config-ocivault``, see :ref:`OCI Vault connection strings
140+
<connstringocivault>`.
141+
142+
To load the ``ocivault`` plugin in your application, use::
143+
144+
.. code-block:: javascript
145+
146+
require('oracledb/plugins/configProviders/ocivault');
147+
148+
See :ref:`ocivault` for more information.
149+
150+
.. _azureplugin:
151+
152+
Microsoft Azure App Centralized Configuration Provider Plugin
153+
-------------------------------------------------------------
154+
155+
.. versionadded:: 6.9
156+
157+
``azure`` is a plugin that can be loaded in your application to provide
158+
access to configuration information stored in
159+
:ref:`Azure App Configuration <azureappconfig>`.
160+
161+
This plugin is implemented as a :ref:`centralized configuration provider hook
162+
function <configproviderhookfn>` to handle connection strings which have the
163+
prefix ``config-azure``, see :ref:`Azure App Configuration connection strings
164+
<connstringazure>`.
165+
166+
To load the ``azure`` plugin in your application, use::
167+
168+
.. code-block:: javascript
169+
170+
require('oracledb/plugins/configProviders/azure');
171+
172+
See :ref:`azureappconfig` for more information.
173+
174+
.. _azurevaultplugin:
175+
176+
Microsoft Azure Key Vault Centralized Configuration Provider Plugin
177+
-------------------------------------------------------------------
178+
179+
.. versionadded:: 6.9
180+
181+
``azurevault`` is a plugin that can be loaded in your application to provide
182+
access to configuration information stored in
183+
:ref:`Azure Key Vault <azurekeyvault>`.
184+
185+
This plugin is implemented as a :ref:`centralized configuration provider hook
186+
function <configproviderhookfn>` to handle connection strings which have the
187+
prefix ``config-azurevault``, see :ref:`Azure Key Vault connection strings
188+
<connstringazurevault>`.
189+
190+
To load the ``azurevault`` plugin in your application, use::
191+
192+
.. code-block:: javascript
193+
194+
require('oracledb/plugins/configProviders/azurevault');
195+
196+
See :ref:`azurekeyvault` for more information.

lib/configProviders/file.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,4 @@ async function hookFn(args) {
6969
}
7070
return [await configProvider.returnConfig(), configProvider.credential];
7171
}
72-
oracledb.registerConfigProviderHooks('file', hookFn);
73-
72+
oracledb.registerConfigurationProviderHook('file', hookFn);

lib/oracledb.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,12 +1157,12 @@ function registerProcessConfigurationHook(fn) {
11571157
}
11581158

11591159
//-----------------------------------------------------------------------------
1160-
// registerConfigProviderHooks()
1160+
// registerConfigurationProviderHook()
11611161
//
1162-
// Registers configProvider plugin modules and registered modules will be called and
1163-
// executed during pool and standalone connection creation.
1162+
// Registers Configuration Provider plugin modules and registered modules will
1163+
// be called and executed during pool and standalone connection creation.
11641164
//-----------------------------------------------------------------------------
1165-
function registerConfigProviderHooks(configProvider, fn) {
1165+
function registerConfigurationProviderHook(configProvider, fn) {
11661166
errors.assertArgCount(arguments, 2, 2);
11671167
errors.assertParamValue(typeof fn === 'function', 1);
11681168
errors.assertParamValue(typeof configProvider === 'string', 1);
@@ -1200,7 +1200,7 @@ module.exports = {
12001200
getPool,
12011201
initOracleClient,
12021202
registerProcessConfigurationHook,
1203-
registerConfigProviderHooks,
1203+
registerConfigurationProviderHook,
12041204
shutdown: nodbUtil.callbackify(nodbUtil.wrapFn(shutdown)),
12051205
startup: nodbUtil.callbackify(nodbUtil.wrapFn(startup)),
12061206

0 commit comments

Comments
 (0)