@universis/janitor 2.4.0 → 2.4.2

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/dist/index.esm.js CHANGED
@@ -908,7 +908,27 @@ function validateClientScope() {
908
908
 
909
909
  function validateScope() {
910
910
  return (req, res, next) => {
911
- return validateClientScope();
911
+ const validateClientScopeHandler = validateClientScope();
912
+ return validateClientScopeHandler(req, res, (err) => {
913
+ if (err) {
914
+ return next(err);
915
+ }
916
+ /**
917
+ * @type {ScopeAccessConfiguration}
918
+ */
919
+ let scopeAccessConfiguration = req.context.getApplication().getConfiguration().getStrategy(ScopeAccessConfiguration);
920
+ if (typeof scopeAccessConfiguration === 'undefined') {
921
+ return next(new Error('Invalid application configuration. Scope access configuration strategy is missing or is in accessible.'));
922
+ }
923
+ scopeAccessConfiguration.verify(req).then((value) => {
924
+ if (value) {
925
+ return next();
926
+ }
927
+ return next(new HttpForbiddenError('Access denied due to authorization scopes.'));
928
+ }).catch((reason) => {
929
+ return next(reason);
930
+ });
931
+ });
912
932
  };
913
933
  }
914
934
 
@@ -1809,11 +1829,11 @@ class NetworkRestrictAccess extends ApplicationService {
1809
1829
  index = model.eventListeners.length - 1;
1810
1830
  }
1811
1831
  let otherIndex = model.eventListeners.findIndex((listener) => {
1812
- return listener.type === path.resolve(__dirname, './OnAccountUpdate');
1832
+ return listener.type === '@universis/janitor/listeners/OnAccountUpdate';
1813
1833
  });
1814
1834
  if (otherIndex < 0) {
1815
1835
  model.eventListeners.splice(index, 0, {
1816
- type: path.resolve(__dirname, './OnAccountUpdate')
1836
+ type: '@universis/janitor/listeners/OnAccountUpdate'
1817
1837
  });
1818
1838
  }
1819
1839
  schemaLoader.setModelDefinition(model);