oidc-provider
Advanced tools
Comparing version 7.11.3 to 7.11.4
@@ -0,1 +1,3 @@ | ||
const util = require('util'); | ||
const MemoryAdapter = require('../adapters/memory_adapter'); | ||
@@ -5,2 +7,3 @@ | ||
const attention = require('./attention'); | ||
const { isConstructable } = require('./type_validators'); | ||
@@ -14,6 +17,8 @@ module.exports = function initializeAdapter(adapter = MemoryAdapter) { | ||
if (!adapter.prototype || !adapter.prototype.constructor.name) { | ||
throw new Error( | ||
'Expected "adapter" to be a constructor, provide a valid adapter in Provider config.', | ||
); | ||
const constructable = isConstructable(adapter); | ||
const executable = typeof adapter === 'function' && !util.types.isAsyncFunction(adapter); | ||
const valid = constructable || executable; | ||
if (!valid) { | ||
throw new Error('Expected "adapter" to be a constructor or a factory function, provide a valid adapter in Provider config.'); | ||
} | ||
@@ -20,0 +25,0 @@ |
@@ -16,2 +16,3 @@ /* eslint-disable max-classes-per-file */ | ||
const instance = require('../helpers/weak_cache'); | ||
const { isConstructable } = require('../helpers/type_validators'); | ||
@@ -27,3 +28,7 @@ const hasFormat = require('./mixins/has_format'); | ||
if (!adapterCache.has(obj)) { | ||
adapterCache.set(obj, new (instance(provider).Adapter)(obj.name)); | ||
if (isConstructable(instance(provider).Adapter)) { | ||
adapterCache.set(obj, new (instance(provider).Adapter)(obj.name)); | ||
} else { | ||
adapterCache.set(obj, instance(provider).Adapter(obj.name)); | ||
} | ||
} | ||
@@ -30,0 +35,0 @@ |
@@ -19,2 +19,3 @@ /* eslint-disable max-classes-per-file */ | ||
const epochTime = require('../helpers/epoch_time'); | ||
const { isConstructable } = require('../helpers/type_validators'); | ||
const instance = require('../helpers/weak_cache'); | ||
@@ -138,3 +139,9 @@ const constantEquals = require('../helpers/constant_equals'); | ||
function getAdapter() { | ||
if (!adapter) adapter = new (instance(provider).Adapter)('Client'); | ||
if (!adapter) { | ||
if (isConstructable(instance(provider).Adapter)) { | ||
adapter = new (instance(provider).Adapter)('Client'); | ||
} else { | ||
adapter = instance(provider).Adapter('Client'); | ||
} | ||
} | ||
return adapter; | ||
@@ -141,0 +148,0 @@ } |
{ | ||
"name": "oidc-provider", | ||
"version": "7.11.3", | ||
"version": "7.11.4", | ||
"description": "OAuth 2.0 Authorization Server implementation for Node.js with OpenID Connect", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
564640
202
14523