@onehat/data 1.22.47 → 1.23.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/data",
3
- "version": "1.22.47",
3
+ "version": "1.23.0",
4
4
  "description": "JS data modeling package with adapters for many storage mediums.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -41,6 +41,7 @@
41
41
  "async-wait-until": "^2.0.31",
42
42
  "axios": "^1.17.0",
43
43
  "chrono-node": "^2.9.1",
44
+ "crypto-es": "^2.1.0",
44
45
  "he": "^1.2.0",
45
46
  "js-base64": "^3.7.8",
46
47
  "lodash": "^4.18.1",
@@ -1,13 +1,12 @@
1
1
  /** @module Repository */
2
2
 
3
3
  import LocalStorageRepository from '@onehat/data/src/Integration/Browser/Repository/LocalStorage';
4
- import CryptoJS from 'crypto-js';
5
- import AES from 'crypto-js/aes';
4
+ import CryptoES from 'crypto-es';
6
5
  import _ from 'lodash';
7
6
 
8
7
  /**
9
8
  * Repository representing an encrypted version of the browser's LocalStorage implementation
10
- * Requires crypto-js - https://www.npmjs.com/package/crypto-js
9
+ * Requires crypto-es - https://www.npmjs.com/package/crypto-es
11
10
  * @extends LocalStorageRepository
12
11
  */
13
12
  class SecureLocalStorageRepository extends LocalStorageRepository {
@@ -32,7 +31,7 @@ class SecureLocalStorageRepository extends LocalStorageRepository {
32
31
  // BEGIN MOD
33
32
  let result = this._store(name);
34
33
  if (!_.isEmpty(result)) {
35
- result = AES.decrypt(result, this.passphrase).toString(CryptoJS.enc.Utf8);
34
+ result = CryptoES.AES.decrypt(result, this.passphrase).toString(CryptoES.enc.Utf8);
36
35
  }
37
36
  // END MOD
38
37
 
@@ -67,7 +66,7 @@ class SecureLocalStorageRepository extends LocalStorageRepository {
67
66
  value = JSON.stringify(value);
68
67
  }
69
68
 
70
- value = AES.encrypt(value, this.passphrase).toString(); // MOD
69
+ value = CryptoES.AES.encrypt(value, this.passphrase).toString(); // MOD
71
70
 
72
71
  const result = this._store(name, value);
73
72
  this._broadcastStorageChange(name, 'set');
@@ -1,13 +1,12 @@
1
1
  /** @module Repository */
2
2
 
3
3
  import SessionStorageRepository from '@onehat/data/src/Integration/Browser/Repository/SessionStorage';
4
- import CryptoJS from 'crypto-js';
5
- import AES from 'crypto-js/aes';
4
+ import CryptoES from 'crypto-es';
6
5
  import _ from 'lodash';
7
6
 
8
7
  /**
9
8
  * Repository representing an encrypted version of the browser's SessionStorage implementation
10
- * Requires crypto-js - https://www.npmjs.com/package/crypto-js
9
+ * Requires crypto-es - https://www.npmjs.com/package/crypto-es
11
10
  * @extends SessionStorageRepository
12
11
  */
13
12
  class SecureSessionStorageRepository extends SessionStorageRepository {
@@ -27,7 +26,7 @@ class SecureSessionStorageRepository extends SessionStorageRepository {
27
26
  // BEGIN MOD
28
27
  let result = this._store.session(name);
29
28
  if (!_.isEmpty(result)) {
30
- result = AES.decrypt(result, this.passphrase).toString(CryptoJS.enc.Utf8);
29
+ result = CryptoES.AES.decrypt(result, this.passphrase).toString(CryptoES.enc.Utf8);
31
30
  }
32
31
  // END MOD
33
32
 
@@ -46,7 +45,7 @@ class SecureSessionStorageRepository extends SessionStorageRepository {
46
45
  value = JSON.stringify(value);
47
46
  }
48
47
 
49
- value = AES.encrypt(value, this.passphrase).toString(); // MOD
48
+ value = CryptoES.AES.encrypt(value, this.passphrase).toString(); // MOD
50
49
 
51
50
  const result = this._store.session(name, value);
52
51
  this._broadcastStorageChange(name, 'set');
@@ -304,6 +304,10 @@ export default class Schema extends EventEmitter {
304
304
  return propertyDefinition.name === propertyName;
305
305
  }));
306
306
 
307
+ if (!found) {
308
+ throw Error('Property "' + propertyName + '" not found in schema "' + this.name + '".');
309
+ }
310
+
307
311
  if (this.model?.validator?.fields && this.model.validator.fields[propertyName]) {
308
312
  found.validator = this.model?.validator?.fields[propertyName];
309
313
  }