File tree 3 files changed +21
-0
lines changed
3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ const ERR_POOL_HAS_BUSY_CONNECTIONS = 104;
109
109
const ERR_NAN_VALUE = 105 ;
110
110
const ERR_INVALID_REF_CURSOR = 107 ;
111
111
const ERR_LOB_CLOSED = 108 ;
112
+ const ERR_INVALID_PRIVATE_KEY = 117 ;
112
113
113
114
// define mapping for ODPI-C errors that need to be wrapped with NJS errors
114
115
const adjustErrorXref = new Map ( ) ;
@@ -284,6 +285,8 @@ messages.set(ERR_INVALID_REF_CURSOR,
284
285
'invalid cursor' ) ;
285
286
messages . set ( ERR_LOB_CLOSED ,
286
287
'LOB was already closed' ) ;
288
+ messages . set ( ERR_INVALID_PRIVATE_KEY ,
289
+ 'invalid private key. Headers and footers are not allowed' ) ;
287
290
288
291
//-----------------------------------------------------------------------------
289
292
// assert()
@@ -544,6 +547,7 @@ module.exports = {
544
547
ERR_INVALID_BIND_NAME ,
545
548
ERR_INVALID_REF_CURSOR ,
546
549
ERR_LOB_CLOSED ,
550
+ ERR_INVALID_PRIVATE_KEY ,
547
551
assert,
548
552
assertArgCount,
549
553
assertParamPropBool,
Original file line number Diff line number Diff line change @@ -366,6 +366,10 @@ async function _verifyOptions(options, inCreatePool) {
366
366
}
367
367
errors . assert ( nodbUtil . isTokenValid ( accessToken ) ,
368
368
errors . ERR_TOKEN_HAS_EXPIRED ) ;
369
+ if ( accessToken . privateKey !== undefined ) {
370
+ errors . assert ( nodbUtil . isPrivateKeyValid ( accessToken ) ,
371
+ errors . ERR_INVALID_PRIVATE_KEY ) ;
372
+ }
369
373
370
374
// store token and privatekey
371
375
if ( typeof accessToken === 'string' ) {
Original file line number Diff line number Diff line change @@ -291,6 +291,18 @@ function isTokenValid(accessToken) {
291
291
}
292
292
}
293
293
294
+ function isPrivateKeyValid ( accessToken ) {
295
+ errors . assert ( typeof accessToken . privateKey === 'string' ,
296
+ errors . ERR_TOKEN_BASED_AUTH ) ;
297
+
298
+ if ( accessToken . privateKey . startsWith ( "-----BEGIN PRIVATE KEY-----" ) ||
299
+ accessToken . privateKey . endsWith ( "-----END PRIVATE KEY-----" ) ) {
300
+ return false ;
301
+ }
302
+
303
+ return true ;
304
+ }
305
+
294
306
// define exports
295
307
module . exports = {
296
308
BINARY_FILE ,
@@ -303,6 +315,7 @@ module.exports = {
303
315
isArrayOfStrings,
304
316
isObject,
305
317
isObjectOrArray,
318
+ isPrivateKeyValid,
306
319
isShardingKey,
307
320
isSodaDocument,
308
321
isTokenExpired,
You can’t perform that action at this time.
0 commit comments