@degenerate/generic 0.0.9 → 0.0.10

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 (93) hide show
  1. package/dist/crypto/index.d.ts +3 -0
  2. package/dist/crypto/index.d.ts.map +1 -1
  3. package/dist/crypto/index.js +5 -0
  4. package/dist/crypto/signature/create-crypto-signature.d.ts +9 -0
  5. package/dist/crypto/signature/create-crypto-signature.d.ts.map +1 -0
  6. package/dist/crypto/signature/create-crypto-signature.js +13 -0
  7. package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts +13 -0
  8. package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts.map +1 -0
  9. package/dist/crypto/signature/verify-crypto-signature-by-data.js +45 -0
  10. package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts +13 -0
  11. package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts.map +1 -0
  12. package/dist/{errors/__tests__/index-test.js → crypto/signature/verify-crypto-signature-by-hash.js} +17 -9
  13. package/dist/errors/generic/generic-errors.d.ts +35 -0
  14. package/dist/errors/generic/generic-errors.d.ts.map +1 -0
  15. package/dist/errors/generic/generic-errors.js +47 -0
  16. package/dist/errors/index.d.ts +3 -0
  17. package/dist/errors/index.d.ts.map +1 -1
  18. package/dist/errors/index.js +3 -0
  19. package/dist/errors/request/request-errors.d.ts +89 -0
  20. package/dist/errors/request/request-errors.d.ts.map +1 -0
  21. package/dist/errors/request/request-errors.js +120 -0
  22. package/dist/errors/share-data/share-data-errors.d.ts +49 -0
  23. package/dist/errors/share-data/share-data-errors.d.ts.map +1 -0
  24. package/dist/errors/share-data/share-data-errors.js +66 -0
  25. package/dist/helpers/array/array-helpers.d.ts +8 -0
  26. package/dist/helpers/array/array-helpers.d.ts.map +1 -0
  27. package/dist/helpers/array/array-helpers.js +14 -0
  28. package/dist/helpers/data/data-helpers.d.ts +46 -0
  29. package/dist/helpers/data/data-helpers.d.ts.map +1 -0
  30. package/dist/helpers/data/data-helpers.js +106 -0
  31. package/dist/helpers/file/file-helpers.d.ts +12 -0
  32. package/dist/helpers/file/file-helpers.d.ts.map +1 -0
  33. package/dist/helpers/file/file-helpers.js +39 -0
  34. package/dist/helpers/id-helpers.d.ts +8 -0
  35. package/dist/helpers/id-helpers.d.ts.map +1 -0
  36. package/dist/helpers/id-helpers.js +19 -0
  37. package/dist/helpers/index.d.ts +11 -0
  38. package/dist/helpers/index.d.ts.map +1 -0
  39. package/dist/helpers/index.js +31 -0
  40. package/dist/helpers/lodash/lodash-helpers.d.ts +14 -0
  41. package/dist/helpers/lodash/lodash-helpers.d.ts.map +1 -0
  42. package/dist/helpers/lodash/lodash-helpers.js +28 -0
  43. package/dist/helpers/object-helpers.d.ts +23 -0
  44. package/dist/helpers/object-helpers.d.ts.map +1 -0
  45. package/dist/helpers/object-helpers.js +54 -0
  46. package/dist/helpers/object-validation-helpers.d.ts +59 -0
  47. package/dist/helpers/object-validation-helpers.d.ts.map +1 -0
  48. package/dist/helpers/object-validation-helpers.js +233 -0
  49. package/dist/helpers/request/params-object-helpers.d.ts +38 -0
  50. package/dist/helpers/request/params-object-helpers.d.ts.map +1 -0
  51. package/dist/helpers/request/params-object-helpers.js +54 -0
  52. package/dist/helpers/request/query-object-helpers.d.ts +12 -0
  53. package/dist/helpers/request/query-object-helpers.d.ts.map +1 -0
  54. package/dist/helpers/request/query-object-helpers.js +25 -0
  55. package/dist/helpers/request/request-object-helpers.d.ts +19 -0
  56. package/dist/helpers/request/request-object-helpers.d.ts.map +1 -0
  57. package/dist/helpers/request/request-object-helpers.js +28 -0
  58. package/dist/index.d.ts +2 -0
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +3 -0
  61. package/dist/models/data/data-models.d.ts +24 -0
  62. package/dist/models/data/data-models.d.ts.map +1 -0
  63. package/dist/models/data/data-models.js +3 -0
  64. package/dist/models/dynamic-execution/dynamic-execution-models.d.ts +9 -0
  65. package/dist/models/dynamic-execution/dynamic-execution-models.d.ts.map +1 -0
  66. package/dist/models/dynamic-execution/dynamic-execution-models.js +2 -0
  67. package/dist/models/events/share-event-models.d.ts +65 -0
  68. package/dist/models/events/share-event-models.d.ts.map +1 -0
  69. package/dist/models/events/share-event-models.js +70 -0
  70. package/dist/models/functions/share-data-function-models.d.ts +86 -0
  71. package/dist/models/functions/share-data-function-models.d.ts.map +1 -0
  72. package/dist/models/functions/share-data-function-models.js +17 -0
  73. package/dist/models/generic/__tests__/request-response-models.d.ts +2 -0
  74. package/dist/models/generic/__tests__/request-response-models.d.ts.map +1 -0
  75. package/dist/models/generic/__tests__/request-response-models.js +33 -0
  76. package/dist/models/generic/request-response-models.d.ts +8 -0
  77. package/dist/models/generic/request-response-models.d.ts.map +1 -0
  78. package/dist/models/generic/request-response-models.js +2 -0
  79. package/dist/models/index.d.ts +8 -0
  80. package/dist/models/index.d.ts.map +1 -0
  81. package/dist/models/index.js +24 -0
  82. package/dist/models/rules/share-rule-models.d.ts +277 -0
  83. package/dist/models/rules/share-rule-models.d.ts.map +1 -0
  84. package/dist/models/rules/share-rule-models.js +107 -0
  85. package/dist/models/share-data/share-data.d.ts +55 -0
  86. package/dist/models/share-data/share-data.d.ts.map +1 -0
  87. package/dist/models/share-data/share-data.js +19 -0
  88. package/dist/share-data/share-data.d.ts +1 -0
  89. package/dist/share-data/share-data.d.ts.map +1 -0
  90. package/dist/share-data/share-data.js +166 -0
  91. package/package.json +1 -1
  92. package/dist/errors/__tests__/index-test.d.ts +0 -2
  93. package/dist/errors/__tests__/index-test.d.ts.map +0 -1
@@ -7,4 +7,7 @@ export * from './private-public-keys/generation/generate-key-pair';
7
7
  export * from './private-public-keys/generation/get-private-public-key-from-keypair';
8
8
  export * from './private-public-keys/create-key-pair-from-private-key';
9
9
  export * from './private-public-keys/create-key-pair-from-mnemonic';
10
+ export * from './signature/create-crypto-signature';
11
+ export * from './signature/verify-crypto-signature-by-data';
12
+ export * from './signature/verify-crypto-signature-by-hash';
10
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAK1C,cAAc,uEAAuE,CAAC;AACtF,cAAc,sEAAsE,CAAC;AACrF,cAAc,gEAAgE,CAAC;AAC/E,cAAc,oDAAoD,CAAC;AACnE,cAAc,sEAAsE,CAAC;AAGrF,cAAc,wDAAwD,CAAC;AACvE,cAAc,qDAAqD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crypto/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAK1C,cAAc,uEAAuE,CAAC;AACtF,cAAc,sEAAsE,CAAC;AACrF,cAAc,gEAAgE,CAAC;AAC/E,cAAc,oDAAoD,CAAC;AACnE,cAAc,sEAAsE,CAAC;AAGrF,cAAc,wDAAwD,CAAC;AACvE,cAAc,qDAAqD,CAAC;AAMpE,cAAc,qCAAqC,CAAC;AACpD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,6CAA6C,CAAC"}
@@ -27,3 +27,8 @@ __exportStar(require("./private-public-keys/generation/get-private-public-key-fr
27
27
  __exportStar(require("./private-public-keys/create-key-pair-from-private-key"), exports);
28
28
  __exportStar(require("./private-public-keys/create-key-pair-from-mnemonic"), exports);
29
29
  //#endregion folder private-public-keys
30
+ //#region folder signature
31
+ __exportStar(require("./signature/create-crypto-signature"), exports);
32
+ __exportStar(require("./signature/verify-crypto-signature-by-data"), exports);
33
+ __exportStar(require("./signature/verify-crypto-signature-by-hash"), exports);
34
+ //#endregion folder signature
@@ -0,0 +1,9 @@
1
+ import * as Elliptic from 'elliptic';
2
+ /**
3
+ * This function creates a signature for a hash using an elliptical curve.
4
+ * @param keyPair the key pair to use for signing.
5
+ * @param hashToSign the hash to sign.
6
+ */
7
+ declare const createEllipticalCurveSignature: (keyPair: Elliptic.ec.KeyPair, hashToSign: string) => string;
8
+ export { createEllipticalCurveSignature };
9
+ //# sourceMappingURL=create-crypto-signature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-crypto-signature.d.ts","sourceRoot":"","sources":["../../../src/crypto/signature/create-crypto-signature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC;;;;GAIG;AACH,QAAA,MAAM,8BAA8B,YAAa,QAAQ,CAAC,EAAE,CAAC,OAAO,cAAc,MAAM,KAAG,MAG1F,CAAC;AAEF,OAAO,EAAE,8BAA8B,EAAE,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createEllipticalCurveSignature = void 0;
4
+ /**
5
+ * This function creates a signature for a hash using an elliptical curve.
6
+ * @param keyPair the key pair to use for signing.
7
+ * @param hashToSign the hash to sign.
8
+ */
9
+ const createEllipticalCurveSignature = (keyPair, hashToSign) => {
10
+ const signature = keyPair.sign(hashToSign).toDER('hex');
11
+ return signature;
12
+ };
13
+ exports.createEllipticalCurveSignature = createEllipticalCurveSignature;
@@ -0,0 +1,13 @@
1
+ import { EllipticalCurvesSigning, EllipticalCurvesEncryption } from '../../_settings/cryptography-settings';
2
+ /**
3
+ * This function verifies the signature of the data using the public key
4
+ *
5
+ * @param curve the curve used for the signature
6
+ * @param data the data to verify
7
+ * @param signature the signature to verify
8
+ * @param publicKey the public key to verify the signature
9
+ * @returns
10
+ */
11
+ declare const verifyCryptoSignatureByData: (curve: EllipticalCurvesSigning | EllipticalCurvesEncryption, data: any, signature: string, publicKey: string) => Promise<boolean>;
12
+ export { verifyCryptoSignatureByData };
13
+ //# sourceMappingURL=verify-crypto-signature-by-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-crypto-signature-by-data.d.ts","sourceRoot":"","sources":["../../../src/crypto/signature/verify-crypto-signature-by-data.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AAE5G;;;;;;;;GAQG;AACH,QAAA,MAAM,2BAA2B,UAAiB,uBAAuB,GAAG,0BAA0B,QAAQ,GAAG,aAAa,MAAM,aACrH,MAAM,KAAG,OAAO,CAAC,OAAO,CAMtC,CAAC;AAEF,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.verifyCryptoSignatureByData = void 0;
27
+ /* eslint-disable @typescript-eslint/no-explicit-any */
28
+ const elliptic = __importStar(require("elliptic"));
29
+ /**
30
+ * This function verifies the signature of the data using the public key
31
+ *
32
+ * @param curve the curve used for the signature
33
+ * @param data the data to verify
34
+ * @param signature the signature to verify
35
+ * @param publicKey the public key to verify the signature
36
+ * @returns
37
+ */
38
+ const verifyCryptoSignatureByData = async (curve, data, signature, publicKey) => {
39
+ // convert data to a string.
40
+ const hash = JSON.stringify(data);
41
+ // eslint-disable-next-line new-cap
42
+ const key = new elliptic.ec(curve).keyFromPublic(publicKey, 'hex');
43
+ return key.verify(hash, signature);
44
+ };
45
+ exports.verifyCryptoSignatureByData = verifyCryptoSignatureByData;
@@ -0,0 +1,13 @@
1
+ import { EllipticalCurvesSigning, EllipticalCurvesEncryption } from '../../_settings/cryptography-settings';
2
+ /**
3
+ * This function verifies the signature of the data using the public key
4
+ *
5
+ * @param curve the curve used for the signature
6
+ * @param hash the hash to verify
7
+ * @param signature the signature to verify
8
+ * @param publicKey the public key to verify the signature
9
+ * @returns
10
+ */
11
+ declare const verifyCryptoSignatureByHash: (curve: EllipticalCurvesSigning | EllipticalCurvesEncryption, hash: string, signature: string, publicKey: string) => Promise<boolean>;
12
+ export { verifyCryptoSignatureByHash };
13
+ //# sourceMappingURL=verify-crypto-signature-by-hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-crypto-signature-by-hash.d.ts","sourceRoot":"","sources":["../../../src/crypto/signature/verify-crypto-signature-by-hash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AAE5G;;;;;;;;GAQG;AACH,QAAA,MAAM,2BAA2B,UAAiB,uBAAuB,GAAG,0BAA0B,QAAQ,MAAM,aAAa,MAAM,aACxH,MAAM,KAAG,OAAO,CAAC,OAAO,CAItC,CAAC;AAEF,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
@@ -23,12 +23,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- const index = __importStar(require("../index"));
27
- describe('index module', () => {
28
- it('should export BaseError', () => {
29
- expect(index.BaseError).toBe(index.BaseError);
30
- });
31
- it('should export TaskNotFoundError', () => {
32
- expect(index.TaskNotFoundError).toBe(index.TaskNotFoundError);
33
- });
34
- });
26
+ exports.verifyCryptoSignatureByHash = void 0;
27
+ const elliptic = __importStar(require("elliptic"));
28
+ /**
29
+ * This function verifies the signature of the data using the public key
30
+ *
31
+ * @param curve the curve used for the signature
32
+ * @param hash the hash to verify
33
+ * @param signature the signature to verify
34
+ * @param publicKey the public key to verify the signature
35
+ * @returns
36
+ */
37
+ const verifyCryptoSignatureByHash = async (curve, hash, signature, publicKey) => {
38
+ // eslint-disable-next-line new-cap
39
+ const key = new elliptic.ec(curve).keyFromPublic(publicKey, 'hex');
40
+ return key.verify(hash, signature);
41
+ };
42
+ exports.verifyCryptoSignatureByHash = verifyCryptoSignatureByHash;
@@ -0,0 +1,35 @@
1
+ import { BaseError } from '../base-error';
2
+ /**
3
+ * This file contains all the errors that are more generic in nature.
4
+ */
5
+ /**
6
+ * This is used for when function data was not received.
7
+ */
8
+ export declare class FunctionDataNotReceivedError extends BaseError {
9
+ /**
10
+ * This is used for when function data was not received.
11
+ */
12
+ constructor();
13
+ }
14
+ /**
15
+ * This is used for when an item can not have a searchable index created for it.
16
+ */
17
+ export declare class UnableToCreateSearchableIndexError extends BaseError {
18
+ /**
19
+ * This is used for when an item can not have a searchable index created for it.
20
+ *
21
+ * @param item
22
+ */
23
+ constructor(item: any);
24
+ }
25
+ /**
26
+ * This is used for when a function is not implemented.
27
+ */
28
+ export declare class NotImplementedError extends BaseError {
29
+ /**
30
+ * This is used for when a function is not implemented.
31
+ *
32
+ */
33
+ constructor();
34
+ }
35
+ //# sourceMappingURL=generic-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generic-errors.d.ts","sourceRoot":"","sources":["../../../src/errors/generic/generic-errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C;;GAEG;AAEH;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,SAAS;IACvD;;OAEG;;CAIN;AAED;;GAEG;AACH,qBAAa,kCAAmC,SAAQ,SAAS;IAC7D;;;;OAIG;gBACS,IAAI,EAAE,GAAG;CAGxB;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IAC9C;;;OAGG;;CAIN"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotImplementedError = exports.UnableToCreateSearchableIndexError = exports.FunctionDataNotReceivedError = void 0;
4
+ /* eslint-disable @typescript-eslint/no-explicit-any */
5
+ const base_error_1 = require("../base-error");
6
+ /**
7
+ * This file contains all the errors that are more generic in nature.
8
+ */
9
+ /**
10
+ * This is used for when function data was not received.
11
+ */
12
+ class FunctionDataNotReceivedError extends base_error_1.BaseError {
13
+ /**
14
+ * This is used for when function data was not received.
15
+ */
16
+ constructor() {
17
+ super('Data required for the functions to run was not received.');
18
+ }
19
+ }
20
+ exports.FunctionDataNotReceivedError = FunctionDataNotReceivedError;
21
+ /**
22
+ * This is used for when an item can not have a searchable index created for it.
23
+ */
24
+ class UnableToCreateSearchableIndexError extends base_error_1.BaseError {
25
+ /**
26
+ * This is used for when an item can not have a searchable index created for it.
27
+ *
28
+ * @param item
29
+ */
30
+ constructor(item) {
31
+ super(`The item ${item} can not have a searchable index created for it.`);
32
+ }
33
+ }
34
+ exports.UnableToCreateSearchableIndexError = UnableToCreateSearchableIndexError;
35
+ /**
36
+ * This is used for when a function is not implemented.
37
+ */
38
+ class NotImplementedError extends base_error_1.BaseError {
39
+ /**
40
+ * This is used for when a function is not implemented.
41
+ *
42
+ */
43
+ constructor() {
44
+ super('This function / feature is not implemented.');
45
+ }
46
+ }
47
+ exports.NotImplementedError = NotImplementedError;
@@ -1,3 +1,6 @@
1
1
  export * from './base-error';
2
+ export * from './generic/generic-errors';
3
+ export * from './request/request-errors';
2
4
  export * from './scheduler/scheduler-errors';
5
+ export * from './share-data/share-data-errors';
3
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC"}
@@ -15,4 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./base-error"), exports);
18
+ __exportStar(require("./generic/generic-errors"), exports);
19
+ __exportStar(require("./request/request-errors"), exports);
18
20
  __exportStar(require("./scheduler/scheduler-errors"), exports);
21
+ __exportStar(require("./share-data/share-data-errors"), exports);
@@ -0,0 +1,89 @@
1
+ import { BaseError } from '../base-error';
2
+ /**
3
+ * This is thrown when the request object is not valid.
4
+ */
5
+ export declare class RequestObjectValidationFailedError extends BaseError {
6
+ /**
7
+ * This is thrown when the request object is not valid.
8
+ * @param objectToValidate the object that is not valid
9
+ * @param validationType the type of validation that failed
10
+ */
11
+ constructor(objectToValidate: any, validationObject: string, validationType: string);
12
+ }
13
+ /**
14
+ * This is throw when the request object has too many properties.
15
+ */
16
+ export declare class RequestObjectTooManyPropertiesError extends BaseError {
17
+ /**
18
+ * This is throw when the request object has too many properties.
19
+ * @param objectToValidate the object that is not valid
20
+ * @param validationOject the object property text that is being validated
21
+ * @param totalProperties the total properties on the object
22
+ * @param maxProperties the max properties allowed on the object
23
+ */
24
+ constructor(objectToValidate: any, validationOject: string, totalProperties: number, maxProperties: number);
25
+ }
26
+ /**
27
+ * This is thrown when the request object has too few properties.
28
+ */
29
+ export declare class RequestObjectTooFewPropertiesError extends BaseError {
30
+ /**
31
+ * This is thrown when the request object has too few properties.
32
+ * @param objectToValidate the object that is not valid
33
+ * @param validationOject the object property text that is being validated
34
+ * @param totalProperties the total properties on the object
35
+ * @param minProperties the min properties allowed on the object
36
+ */
37
+ constructor(objectToValidate: any, validationOject: string, totalProperties: number, minProperties: number);
38
+ }
39
+ /**
40
+ * This is thrown when the request object should only have a certain number of properties.
41
+ */
42
+ export declare class RequestObjectShouldOnlyHaveXPropertiesError extends BaseError {
43
+ /**
44
+ * This is thrown when the request object should only have a certain number of properties.
45
+ * @param objectToValidate the object that is not valid
46
+ * @param validationOject the object property text that is being validated
47
+ * @param totalProperties the total properties on the object
48
+ * @param expectedProperties the expected properties on the object
49
+ */
50
+ constructor(objectToValidate: any, validationOject: string, totalProperties: number, expectedProperties: number);
51
+ }
52
+ /**
53
+ * This is throw when the request object has a property that does not match the param property.
54
+ */
55
+ export declare class RequestObjectPropertyNotMatchingParamProperty extends BaseError {
56
+ /**
57
+ * This is thrown when the request object doesnot match the param property.
58
+ * @param requestPropertyName the property in the request object
59
+ * @param requestPropertyValue the value of the property in the request object
60
+ * @param paramPropertyName the property in the param object
61
+ * @param paramPropertyValue the value of the property in the param object
62
+ */
63
+ constructor(requestPropertyName: string, requestPropertyValue: any, paramPropertyName: string, paramPropertyValue: any);
64
+ }
65
+ /**
66
+ * This is thrown when the query object is not valid.
67
+ */
68
+ export declare class RequestQueryNotValidError extends BaseError {
69
+ /**
70
+ * This is thrown when the query object is not valid.
71
+ * @param queryObjectName the name of the query object
72
+ * @param queryValue the value of the query object
73
+ * @param expectedType the expected type of the query object
74
+ */
75
+ constructor(queryObjectName: string, queryValue: any, expectedType: string);
76
+ }
77
+ /**
78
+ * This is thrown when the param object is not valid.
79
+ */
80
+ export declare class RequestParamNotValidError extends BaseError {
81
+ /**
82
+ * This is thrown when the param object is not valid.
83
+ * @param paramName the name of the param object
84
+ * @param paramValue the value of the param object
85
+ * @param expectedType the expected type of the param object
86
+ */
87
+ constructor(paramName: string, paramValue: any, expectedType: string, allParams: any);
88
+ }
89
+ //# sourceMappingURL=request-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-errors.d.ts","sourceRoot":"","sources":["../../../src/errors/request/request-errors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAI1C;;GAEG;AACH,qBAAa,kCAAmC,SAAQ,SAAS;IAC7D;;;;OAIG;gBACS,gBAAgB,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;CAGtF;AAED;;GAEG;AACH,qBAAa,mCAAoC,SAAQ,SAAS;IAC9D;;;;;;OAMG;gBACS,gBAAgB,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;CAG7G;AAED;;GAEG;AACH,qBAAa,kCAAmC,SAAQ,SAAS;IAC7D;;;;;;OAMG;gBACS,gBAAgB,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;CAG7G;AAED;;GAEG;AACH,qBAAa,2CAA4C,SAAQ,SAAS;IACtE;;;;;;OAMG;gBACS,gBAAgB,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM;CAGlH;AAED;;GAEG;AACH,qBAAa,6CAA8C,SAAQ,SAAS;IACxE;;;;;;OAMG;gBACS,mBAAmB,EAAE,MAAM,EAAE,oBAAoB,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,EAAE,kBAAkB,EAAE,GAAG;CAGzH;AAMD;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACpD;;;;;OAKG;gBACS,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM;CAG7E;AAMD;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACpD;;;;;OAKG;gBACS,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG;CAGvF"}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RequestParamNotValidError = exports.RequestQueryNotValidError = exports.RequestObjectPropertyNotMatchingParamProperty = exports.RequestObjectShouldOnlyHaveXPropertiesError = exports.RequestObjectTooFewPropertiesError = exports.RequestObjectTooManyPropertiesError = exports.RequestObjectValidationFailedError = void 0;
4
+ /* eslint-disable @typescript-eslint/no-explicit-any */
5
+ // This file contains the errors that are thrown when the request object is not valid.
6
+ const base_error_1 = require("../base-error");
7
+ //#region Request Body Errors
8
+ /**
9
+ * This is thrown when the request object is not valid.
10
+ */
11
+ class RequestObjectValidationFailedError extends base_error_1.BaseError {
12
+ /**
13
+ * This is thrown when the request object is not valid.
14
+ * @param objectToValidate the object that is not valid
15
+ * @param validationType the type of validation that failed
16
+ */
17
+ constructor(objectToValidate, validationObject, validationType) {
18
+ super(`The object ${objectToValidate} in the node ${validationObject} is not a valid ${validationType}`);
19
+ }
20
+ }
21
+ exports.RequestObjectValidationFailedError = RequestObjectValidationFailedError;
22
+ /**
23
+ * This is throw when the request object has too many properties.
24
+ */
25
+ class RequestObjectTooManyPropertiesError extends base_error_1.BaseError {
26
+ /**
27
+ * This is throw when the request object has too many properties.
28
+ * @param objectToValidate the object that is not valid
29
+ * @param validationOject the object property text that is being validated
30
+ * @param totalProperties the total properties on the object
31
+ * @param maxProperties the max properties allowed on the object
32
+ */
33
+ constructor(objectToValidate, validationOject, totalProperties, maxProperties) {
34
+ super(`The object ${objectToValidate} which is property ${validationOject} has too many properties. It has ${totalProperties} and the max is ${maxProperties}`);
35
+ }
36
+ }
37
+ exports.RequestObjectTooManyPropertiesError = RequestObjectTooManyPropertiesError;
38
+ /**
39
+ * This is thrown when the request object has too few properties.
40
+ */
41
+ class RequestObjectTooFewPropertiesError extends base_error_1.BaseError {
42
+ /**
43
+ * This is thrown when the request object has too few properties.
44
+ * @param objectToValidate the object that is not valid
45
+ * @param validationOject the object property text that is being validated
46
+ * @param totalProperties the total properties on the object
47
+ * @param minProperties the min properties allowed on the object
48
+ */
49
+ constructor(objectToValidate, validationOject, totalProperties, minProperties) {
50
+ super(`The object ${objectToValidate} which is property ${validationOject} has too few properties. It has ${totalProperties} and the min is ${minProperties}`);
51
+ }
52
+ }
53
+ exports.RequestObjectTooFewPropertiesError = RequestObjectTooFewPropertiesError;
54
+ /**
55
+ * This is thrown when the request object should only have a certain number of properties.
56
+ */
57
+ class RequestObjectShouldOnlyHaveXPropertiesError extends base_error_1.BaseError {
58
+ /**
59
+ * This is thrown when the request object should only have a certain number of properties.
60
+ * @param objectToValidate the object that is not valid
61
+ * @param validationOject the object property text that is being validated
62
+ * @param totalProperties the total properties on the object
63
+ * @param expectedProperties the expected properties on the object
64
+ */
65
+ constructor(objectToValidate, validationOject, totalProperties, expectedProperties) {
66
+ super(`The object ${objectToValidate} which is property ${validationOject} should only have ${expectedProperties} properties. It has ${totalProperties}`);
67
+ }
68
+ }
69
+ exports.RequestObjectShouldOnlyHaveXPropertiesError = RequestObjectShouldOnlyHaveXPropertiesError;
70
+ /**
71
+ * This is throw when the request object has a property that does not match the param property.
72
+ */
73
+ class RequestObjectPropertyNotMatchingParamProperty extends base_error_1.BaseError {
74
+ /**
75
+ * This is thrown when the request object doesnot match the param property.
76
+ * @param requestPropertyName the property in the request object
77
+ * @param requestPropertyValue the value of the property in the request object
78
+ * @param paramPropertyName the property in the param object
79
+ * @param paramPropertyValue the value of the property in the param object
80
+ */
81
+ constructor(requestPropertyName, requestPropertyValue, paramPropertyName, paramPropertyValue) {
82
+ super(`The request object property ${requestPropertyName} with value ${requestPropertyValue} does not match the param property ${paramPropertyName} with value ${paramPropertyValue}`);
83
+ }
84
+ }
85
+ exports.RequestObjectPropertyNotMatchingParamProperty = RequestObjectPropertyNotMatchingParamProperty;
86
+ //#endregion Request Body Errors
87
+ //#region Request Query Errors
88
+ /**
89
+ * This is thrown when the query object is not valid.
90
+ */
91
+ class RequestQueryNotValidError extends base_error_1.BaseError {
92
+ /**
93
+ * This is thrown when the query object is not valid.
94
+ * @param queryObjectName the name of the query object
95
+ * @param queryValue the value of the query object
96
+ * @param expectedType the expected type of the query object
97
+ */
98
+ constructor(queryObjectName, queryValue, expectedType) {
99
+ super(`The query object ${queryObjectName} with value ${queryValue} is not a valid ${expectedType}`);
100
+ }
101
+ }
102
+ exports.RequestQueryNotValidError = RequestQueryNotValidError;
103
+ //#endregion Request Query Errors
104
+ //#region Request Param Errors
105
+ /**
106
+ * This is thrown when the param object is not valid.
107
+ */
108
+ class RequestParamNotValidError extends base_error_1.BaseError {
109
+ /**
110
+ * This is thrown when the param object is not valid.
111
+ * @param paramName the name of the param object
112
+ * @param paramValue the value of the param object
113
+ * @param expectedType the expected type of the param object
114
+ */
115
+ constructor(paramName, paramValue, expectedType, allParams) {
116
+ super(`The param object ${paramName} with value ${paramValue} is not a valid ${expectedType}. All params: ${JSON.stringify(allParams)}`);
117
+ }
118
+ }
119
+ exports.RequestParamNotValidError = RequestParamNotValidError;
120
+ //#endregion Request Param Errors
@@ -0,0 +1,49 @@
1
+ import { BaseError } from '../base-error';
2
+ import { ShareDataTypes } from '../../models/share-data/share-data';
3
+ import { IShareDataFunction } from '../../models/functions/share-data-function-models';
4
+ /**
5
+ * This error is thrown when a function is tried to be applied to the share data thats state is locked.
6
+ */
7
+ export declare class ShareDataIsLockedError extends BaseError {
8
+ /**
9
+ * This error is thrown when a function is tried to be applied to the share data thats state is locked.
10
+ */
11
+ constructor(shareDataId: string, shareDataType: ShareDataTypes);
12
+ }
13
+ /**
14
+ * This error is thrown when a data proposal matches the current data in the rules evaluation service.
15
+ */
16
+ export declare class ShareDataCurrentAndProposalDataMatchesError extends BaseError {
17
+ /**
18
+ * This error is thrown when a data proposal matches the current data in the rules evaluation service.
19
+ */
20
+ constructor(shareDataId: string);
21
+ }
22
+ /**
23
+ * This error is thrown when the share data integrity check fails.
24
+ */
25
+ export declare class ShareDataIntegrityError extends BaseError {
26
+ /**
27
+ * This error is thrown when the share data integrity check fails.
28
+ */
29
+ constructor(shareDataId: string);
30
+ }
31
+ /**
32
+ * This error is thrown when the attemping to be applied function does not exist on the share data.
33
+ */
34
+ export declare class ShareDataFunctionBeingAppliedDoesNotExistOnShareDataError extends BaseError {
35
+ /**
36
+ * This error is thrown when the attemping to be applied function does not exist on the share data.
37
+ */
38
+ constructor(shareDataId: string, functionName: string, functionId: string);
39
+ }
40
+ /**
41
+ * This error is thrown when the function hash is not valid.
42
+ */
43
+ export declare class ShareDataFunctionHashNotValid extends BaseError {
44
+ /**
45
+ * This error is thrown when the function hash is not valid.
46
+ */
47
+ constructor(shareDataId: string, shareDataFunction: IShareDataFunction, calculatedHash: string);
48
+ }
49
+ //# sourceMappingURL=share-data-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share-data-errors.d.ts","sourceRoot":"","sources":["../../../src/errors/share-data/share-data-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAEvF;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,SAAS;IACjD;;OAEG;gBACS,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc;CAGjE;AAED;;GAEG;AACH,qBAAa,2CAA4C,SAAQ,SAAS;IACtE;;OAEG;gBACS,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,SAAS;IAClD;;OAEG;gBACS,WAAW,EAAE,MAAM;CAGlC;AAED;;GAEG;AACH,qBAAa,yDAA0D,SAAQ,SAAS;IACpF;;OAEG;gBACS,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAI5E;AAGD;;GAEG;AACH,qBAAa,6BAA8B,SAAQ,SAAS;IACxD;;OAEG;gBACS,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM;CAIjG"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ShareDataFunctionHashNotValid = exports.ShareDataFunctionBeingAppliedDoesNotExistOnShareDataError = exports.ShareDataIntegrityError = exports.ShareDataCurrentAndProposalDataMatchesError = exports.ShareDataIsLockedError = void 0;
4
+ const base_error_1 = require("../base-error");
5
+ /**
6
+ * This error is thrown when a function is tried to be applied to the share data thats state is locked.
7
+ */
8
+ class ShareDataIsLockedError extends base_error_1.BaseError {
9
+ /**
10
+ * This error is thrown when a function is tried to be applied to the share data thats state is locked.
11
+ */
12
+ constructor(shareDataId, shareDataType) {
13
+ super(`Share data with id ${shareDataId} and type ${shareDataType} is locked and cannot be modified.`);
14
+ }
15
+ }
16
+ exports.ShareDataIsLockedError = ShareDataIsLockedError;
17
+ /**
18
+ * This error is thrown when a data proposal matches the current data in the rules evaluation service.
19
+ */
20
+ class ShareDataCurrentAndProposalDataMatchesError extends base_error_1.BaseError {
21
+ /**
22
+ * This error is thrown when a data proposal matches the current data in the rules evaluation service.
23
+ */
24
+ constructor(shareDataId) {
25
+ super(`Share data with id ${shareDataId} current and proposal data matches.`);
26
+ }
27
+ }
28
+ exports.ShareDataCurrentAndProposalDataMatchesError = ShareDataCurrentAndProposalDataMatchesError;
29
+ /**
30
+ * This error is thrown when the share data integrity check fails.
31
+ */
32
+ class ShareDataIntegrityError extends base_error_1.BaseError {
33
+ /**
34
+ * This error is thrown when the share data integrity check fails.
35
+ */
36
+ constructor(shareDataId) {
37
+ super(`Share data with id ${shareDataId} failed the integrity check.`);
38
+ }
39
+ }
40
+ exports.ShareDataIntegrityError = ShareDataIntegrityError;
41
+ /**
42
+ * This error is thrown when the attemping to be applied function does not exist on the share data.
43
+ */
44
+ class ShareDataFunctionBeingAppliedDoesNotExistOnShareDataError extends base_error_1.BaseError {
45
+ /**
46
+ * This error is thrown when the attemping to be applied function does not exist on the share data.
47
+ */
48
+ constructor(shareDataId, functionName, functionId) {
49
+ super(`On share data with id ${shareDataId} the function with id: ${functionId} & name: ${functionName} that is trying to be executed, ` +
50
+ 'but does not exist in the authorized functions for the share data.');
51
+ }
52
+ }
53
+ exports.ShareDataFunctionBeingAppliedDoesNotExistOnShareDataError = ShareDataFunctionBeingAppliedDoesNotExistOnShareDataError;
54
+ /**
55
+ * This error is thrown when the function hash is not valid.
56
+ */
57
+ class ShareDataFunctionHashNotValid extends base_error_1.BaseError {
58
+ /**
59
+ * This error is thrown when the function hash is not valid.
60
+ */
61
+ constructor(shareDataId, shareDataFunction, calculatedHash) {
62
+ super(`On share data with id ${shareDataId} the function with current hash: ${shareDataFunction.currentHash} & previous hase: ${shareDataFunction.previousHash}` +
63
+ ` that is trying to be executed does not meet the generated hash ${calculatedHash}. This makes it an authorized function execution.`);
64
+ }
65
+ }
66
+ exports.ShareDataFunctionHashNotValid = ShareDataFunctionHashNotValid;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * this gets a random item from an array.
3
+ *
4
+ * @param incomingArray the incoming array to get a random item from.
5
+ */
6
+ declare const getRandomItemFromArray: <T>(incomingArray: T[]) => T;
7
+ export { getRandomItemFromArray };
8
+ //# sourceMappingURL=array-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array-helpers.d.ts","sourceRoot":"","sources":["../../../src/helpers/array/array-helpers.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,QAAA,MAAM,sBAAsB,GAAI,CAAC,iBAAiB,CAAC,EAAE,KAAG,CAGvD,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ // This file contains the helper functions for arrays.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getRandomItemFromArray = void 0;
5
+ /**
6
+ * this gets a random item from an array.
7
+ *
8
+ * @param incomingArray the incoming array to get a random item from.
9
+ */
10
+ const getRandomItemFromArray = (incomingArray) => {
11
+ const randomIndex = Math.floor(Math.random() * incomingArray.length);
12
+ return incomingArray[randomIndex];
13
+ };
14
+ exports.getRandomItemFromArray = getRandomItemFromArray;