@capillarytech/cap-ui-utils 1.0.11 → 1.0.12

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 (2) hide show
  1. package/auth/index.js +27 -17
  2. package/package.json +1 -1
package/auth/index.js CHANGED
@@ -13,30 +13,36 @@ import authHoc from './authHoc';
13
13
  import hasRole from './hasRole';
14
14
  import isCapUser from './isCapUser';
15
15
 
16
+ const KEYS_EXEMPTED_FROM_VALIDATION = ['isCapUser']
16
17
  /**
17
18
  * Function to initialize the capAuth configurations to the document
18
19
  * @param {*} authConfigs
19
20
  */
20
21
  function _initialize(authConfigs) {
21
22
  const capAuth = {};
22
- if (!authConfigs.permissions) {
23
- warn("Cannot initialize auth without permissions");
24
- return;
25
- }
26
- if(authConfigs.permissions) {
27
- capAuth.permissions = Object.freeze(authConfigs.permissions);
28
- }
29
- if(authConfigs.orgFeatures) {
30
- capAuth.orgFeatures = Object.freeze(authConfigs.orgFeatures);
31
- }
32
- if(authConfigs.roles) {
33
- capAuth.roles = Object.freeze(authConfigs.roles);
23
+ try {
24
+ if (!authConfigs.permissions) {
25
+ warn("Cannot initialize auth without permissions");
26
+ return;
27
+ }
28
+ if(authConfigs.permissions) {
29
+ capAuth.permissions = Object.freeze(authConfigs.permissions);
30
+ }
31
+ if(authConfigs.orgFeatures) {
32
+ capAuth.orgFeatures = Object.freeze(authConfigs.orgFeatures);
33
+ }
34
+ if(authConfigs.roles) {
35
+ capAuth.roles = Object.freeze(authConfigs.roles);
36
+ }
37
+ if(authConfigs.isCapUser) {
38
+ capAuth.isCapUser = true;
39
+ }
40
+ log("Cap auth initialized");
41
+ window.capAuth = Object.freeze(capAuth);
34
42
  }
35
- if(authConfigs.isCapUser) {
36
- capAuth.isCapUser = true;
43
+ catch(error) {
44
+ warn(error);
37
45
  }
38
- log("Cap auth initialized");
39
- window.capAuth = Object.freeze(capAuth);
40
46
  }
41
47
 
42
48
  /**
@@ -53,7 +59,11 @@ function initialize(authConfigs, authOptions) {
53
59
  return;
54
60
  }
55
61
  for ( const config in authConfigs) {
56
- if(typeof authConfigs[config] !== "object") {
62
+ if(KEYS_EXEMPTED_FROM_VALIDATION.includes(config)) {
63
+ //Skip validation
64
+ continue;
65
+ }
66
+ if(!["object"].includes(typeof authConfigs[config])) {
57
67
  warn("Config must be an object");
58
68
  return;
59
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capillarytech/cap-ui-utils",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Utility functions shared accross all the modules",
5
5
  "main": "index.js",
6
6
  "scripts": {