@raytio/core 10.1.0 → 11.0.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/CHANGELOG.md +6 -0
- package/README.md +100 -59
- package/dist/{util/hash.d.ts → __tests__/docs.test.d.ts} +1 -1
- package/dist/__tests__/docs.test.js +24 -0
- package/dist/accessApplication/createAA.d.ts +17 -17
- package/dist/accessApplication/createAA.js +71 -71
- package/dist/accessApplication/index.d.ts +1 -1
- package/dist/accessApplication/index.js +17 -17
- package/dist/crypto/cognitoAttributes.d.ts +15 -15
- package/dist/crypto/cognitoAttributes.js +33 -33
- package/dist/crypto/decryptKeys.d.ts +1 -1
- package/dist/crypto/decryptKeys.js +33 -33
- package/dist/crypto/decryptSharedData.d.ts +26 -26
- package/dist/crypto/decryptSharedData.js +38 -38
- package/dist/crypto/getAADecryptor.d.ts +16 -16
- package/dist/crypto/getAADecryptor.js +20 -20
- package/dist/crypto/helpers.d.ts +18 -18
- package/dist/crypto/helpers.js +26 -26
- package/dist/crypto/index.d.ts +4 -4
- package/dist/crypto/index.js +21 -21
- package/dist/general/conditional.d.ts +17 -17
- package/dist/general/conditional.js +32 -32
- package/dist/general/date.d.ts +2 -2
- package/dist/general/date.js +18 -18
- package/dist/general/index.d.ts +4 -4
- package/dist/general/index.js +20 -20
- package/dist/general/password.d.ts +10 -10
- package/dist/general/password.js +31 -31
- package/dist/general/types.d.ts +6 -6
- package/dist/general/types.js +13 -13
- package/dist/index.d.ts +6 -6
- package/dist/index.js +22 -22
- package/dist/rules/calculateScore.d.ts +28 -23
- package/dist/rules/calculateScore.js +82 -76
- package/dist/rules/convertInstanceToRuleInput.d.ts +3 -3
- package/dist/rules/convertInstanceToRuleInput.js +138 -139
- package/dist/rules/evaluateScoreCondition.d.ts +2 -2
- package/dist/rules/evaluateScoreCondition.js +44 -45
- package/dist/{verifications/checkVerifications.d.ts → rules/helpers/__tests__/addInfiniteThresholdBoundaries.test.d.ts} +1 -1
- package/dist/rules/helpers/__tests__/addInfiniteThresholdBoundaries.test.js +27 -0
- package/dist/{verifications/checkVerificationsNew.d.ts → rules/helpers/__tests__/checkTypeofValue.test.d.ts} +1 -1
- package/dist/rules/helpers/__tests__/checkTypeofValue.test.js +49 -0
- package/dist/{verifications/verifyCheck/util/canonicalJsonify.d.ts → rules/helpers/__tests__/getValuesFromPath.test.d.ts} +1 -1
- package/dist/rules/helpers/__tests__/getValuesFromPath.test.js +67 -0
- package/dist/rules/helpers/__tests__/thresholds.test.d.ts +1 -0
- package/dist/rules/helpers/__tests__/thresholds.test.js +32 -0
- package/dist/rules/helpers/addInfiniteThresholdBoundaries.d.ts +8 -8
- package/dist/rules/helpers/addInfiniteThresholdBoundaries.js +11 -11
- package/dist/rules/helpers/checkTypeofValue.d.ts +9 -9
- package/dist/rules/helpers/checkTypeofValue.js +60 -55
- package/dist/rules/helpers/getValuesFromPath.d.ts +3 -3
- package/dist/rules/helpers/getValuesFromPath.js +50 -50
- package/dist/rules/helpers/index.d.ts +5 -5
- package/dist/rules/helpers/index.js +21 -21
- package/dist/rules/helpers/symbols.d.ts +2 -2
- package/dist/rules/helpers/symbols.js +5 -5
- package/dist/rules/helpers/thresholds.d.ts +5 -5
- package/dist/rules/helpers/thresholds.js +46 -47
- package/dist/rules/index.d.ts +7 -7
- package/dist/rules/index.js +25 -25
- package/dist/rules/operators/__tests__/bool.test.d.ts +1 -0
- package/dist/rules/operators/__tests__/bool.test.js +21 -0
- package/dist/rules/operators/__tests__/date.test.d.ts +1 -0
- package/dist/rules/operators/__tests__/date.test.js +81 -0
- package/dist/rules/operators/__tests__/hfield.test.d.ts +1 -0
- package/dist/rules/operators/__tests__/hfield.test.js +38 -0
- package/dist/rules/operators/__tests__/hschema.test.d.ts +1 -0
- package/dist/rules/operators/__tests__/hschema.test.js +24 -0
- package/dist/rules/operators/__tests__/number.test.d.ts +1 -0
- package/dist/rules/operators/__tests__/number.test.js +53 -0
- package/dist/rules/operators/__tests__/string.test.d.ts +1 -0
- package/dist/rules/operators/__tests__/string.test.js +74 -0
- package/dist/rules/operators/bool.d.ts +2 -2
- package/dist/rules/operators/bool.js +17 -17
- package/dist/rules/operators/date.d.ts +2 -2
- package/dist/rules/operators/date.js +91 -91
- package/dist/rules/operators/hfield.d.ts +2 -2
- package/dist/rules/operators/hfield.js +33 -33
- package/dist/rules/operators/hschema.d.ts +2 -2
- package/dist/rules/operators/hschema.js +21 -21
- package/dist/rules/operators/index.d.ts +3 -3
- package/dist/rules/operators/index.js +11 -11
- package/dist/rules/operators/number.d.ts +2 -2
- package/dist/rules/operators/number.js +41 -41
- package/dist/rules/operators/string.d.ts +2 -2
- package/dist/rules/operators/string.js +58 -58
- package/dist/rules/types/config.d.ts +95 -91
- package/dist/rules/types/config.js +2 -2
- package/dist/rules/types/dataValueTypes.d.ts +19 -19
- package/dist/rules/types/dataValueTypes.js +4 -4
- package/dist/rules/types/index.d.ts +3 -3
- package/dist/rules/types/index.js +19 -19
- package/dist/rules/types/internal.d.ts +20 -20
- package/dist/rules/types/internal.js +2 -2
- package/dist/rules/validate.d.ts +6 -6
- package/dist/rules/validate.js +14 -14
- package/dist/rules/version.d.ts +1 -1
- package/dist/rules/version.js +5 -5
- package/dist/schema/index.d.ts +1 -1
- package/dist/schema/index.js +17 -17
- package/dist/schema/labels.d.ts +2 -2
- package/dist/schema/labels.js +20 -20
- package/dist/util/canonicalJsonify.d.ts +1 -1
- package/dist/util/canonicalJsonify.js +50 -50
- package/dist/util/handleResponse.d.ts +1 -1
- package/dist/util/handleResponse.js +21 -21
- package/dist/util/index.d.ts +2 -2
- package/dist/util/index.js +18 -18
- package/dist/verifications/cleanInstance.d.ts +9 -9
- package/dist/verifications/cleanInstance.js +15 -15
- package/dist/verifications/getPOVerification.d.ts +19 -16
- package/dist/verifications/getPOVerification.js +105 -94
- package/dist/verifications/getVerifiedBy.d.ts +1 -1
- package/dist/verifications/getVerifiedBy.js +19 -19
- package/dist/verifications/index.d.ts +5 -5
- package/dist/verifications/index.js +21 -21
- package/dist/verifications/maybeRereference.d.ts +1 -1
- package/dist/verifications/maybeRereference.js +10 -10
- package/dist/verifications/safeHarbour.d.ts +20 -20
- package/dist/verifications/safeHarbour.js +74 -74
- package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.d.ts +1 -0
- package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.js +152 -0
- package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.d.ts +1 -0
- package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.js +205 -0
- package/dist/verifications/verifyCheck/getOwnRealVerifications.d.ts +13 -13
- package/dist/verifications/verifyCheck/getOwnRealVerifications.js +66 -64
- package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.d.ts +19 -19
- package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.js +72 -72
- package/dist/verifications/verifyCheck/index.d.ts +3 -3
- package/dist/verifications/verifyCheck/index.js +21 -21
- package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.d.ts +1 -0
- package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.js +91 -0
- package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.d.ts +1 -0
- package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.js +49 -0
- package/dist/verifications/verifyCheck/operations/__tests__/sampleBundle.json +43 -0
- package/dist/verifications/verifyCheck/operations/checkOwnVerification.d.ts +15 -15
- package/dist/verifications/verifyCheck/operations/checkOwnVerification.js +39 -39
- package/dist/verifications/verifyCheck/operations/checkSomeoneElsesVerifications.d.ts +1 -1
- package/dist/verifications/verifyCheck/operations/checkSomeoneElsesVerifications.js +16 -16
- package/dist/verifications/verifyCheck/operations/index.d.ts +2 -2
- package/dist/verifications/verifyCheck/operations/index.js +18 -18
- package/package.json +13 -10
- package/dist/rules/helpers/getLhsTypeofValue.d.ts +0 -0
- package/dist/rules/helpers/getLhsTypeofValue.js +0 -1
- package/dist/rules/helpers/getValueFromPath.d.ts +0 -2
- package/dist/rules/helpers/getValueFromPath.js +0 -35
- package/dist/rules/helpers/rebuildInfiniteValues.d.ts +0 -3
- package/dist/rules/helpers/rebuildInfiniteValues.js +0 -6
- package/dist/rules/isScoreResultValid.d.ts +0 -2
- package/dist/rules/isScoreResultValid.js +0 -9
- package/dist/rules/operators/array.d.ts +0 -2
- package/dist/rules/operators/array.js +0 -74
- package/dist/rules/types/operators.d.ts +0 -19
- package/dist/rules/types/operators.js +0 -2
- package/dist/rules/types/score.d.ts +0 -50
- package/dist/rules/types/score.js +0 -2
- package/dist/util/conditional.d.ts +0 -7
- package/dist/util/conditional.js +0 -15
- package/dist/util/hash.js +0 -11
- package/dist/verifications/checkSingleVerification.d.ts +0 -9
- package/dist/verifications/checkSingleVerification.js +0 -29
- package/dist/verifications/checkVerifications.js +0 -16
- package/dist/verifications/checkVerificationsNew.js +0 -16
- package/dist/verifications/getOwnRealVerifications.d.ts +0 -14
- package/dist/verifications/getOwnRealVerifications.js +0 -64
- package/dist/verifications/getRealVerifications.d.ts +0 -22
- package/dist/verifications/getRealVerifications.js +0 -71
- package/dist/verifications/verifyCheck/util/canonicalJsonify.js +0 -48
- package/dist/verifications/verifyCheck/util/getValuesForAField.d.ts +0 -2
- package/dist/verifications/verifyCheck/util/getValuesForAField.js +0 -9
- package/dist/verifications/verifyCheck/util/index.d.ts +0 -2
- package/dist/verifications/verifyCheck/util/index.js +0 -14
package/dist/general/date.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.repairDate = void 0;
|
|
4
|
-
/** repairs broken ISO dates into valid JS date objects */
|
|
5
|
-
function repairDate(date) {
|
|
6
|
-
if (date instanceof Date)
|
|
7
|
-
return date;
|
|
8
|
-
if (typeof date !== "string")
|
|
9
|
-
return new Date(date); // will return an invalid date obj
|
|
10
|
-
if (date.includes("T") && !date.includes("Z") && !date.includes("+")) {
|
|
11
|
-
// it's a weird ISO date from the backend
|
|
12
|
-
// as of #1280, most APIs should return valid dates, but POs or verifications
|
|
13
|
-
// created before July 2022 will still have the invalid dates emebedded in them.
|
|
14
|
-
return new Date(`${date}Z`);
|
|
15
|
-
}
|
|
16
|
-
return new Date(date);
|
|
17
|
-
}
|
|
18
|
-
exports.repairDate = repairDate;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.repairDate = void 0;
|
|
4
|
+
/** repairs broken ISO dates into valid JS date objects */
|
|
5
|
+
function repairDate(date) {
|
|
6
|
+
if (date instanceof Date)
|
|
7
|
+
return date;
|
|
8
|
+
if (typeof date !== "string")
|
|
9
|
+
return new Date(date); // will return an invalid date obj
|
|
10
|
+
if (date.includes("T") && !date.includes("Z") && !date.includes("+")) {
|
|
11
|
+
// it's a weird ISO date from the backend
|
|
12
|
+
// as of #1280, most APIs should return valid dates, but POs or verifications
|
|
13
|
+
// created before July 2022 will still have the invalid dates emebedded in them.
|
|
14
|
+
return new Date(`${date}Z`);
|
|
15
|
+
}
|
|
16
|
+
return new Date(date);
|
|
17
|
+
}
|
|
18
|
+
exports.repairDate = repairDate;
|
package/dist/general/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./conditional";
|
|
2
|
-
export * from "./date";
|
|
3
|
-
export * from "./password";
|
|
4
|
-
export * from "./types";
|
|
1
|
+
export * from "./conditional";
|
|
2
|
+
export * from "./date";
|
|
3
|
+
export * from "./password";
|
|
4
|
+
export * from "./types";
|
package/dist/general/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./conditional"), exports);
|
|
18
|
-
__exportStar(require("./date"), exports);
|
|
19
|
-
__exportStar(require("./password"), exports);
|
|
20
|
-
__exportStar(require("./types"), exports);
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./conditional"), exports);
|
|
18
|
+
__exportStar(require("./date"), exports);
|
|
19
|
+
__exportStar(require("./password"), exports);
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated legacy feature, see #1252
|
|
3
|
-
*
|
|
4
|
-
* AWS Cognito never gets the raw password. We send them
|
|
5
|
-
* a hashed verison using PBKDF2 with SHA-256 and 10,000
|
|
6
|
-
* iterations.
|
|
7
|
-
* @param password The raw password
|
|
8
|
-
* @returns Promise resolving to the hashed password
|
|
9
|
-
*/
|
|
10
|
-
export declare function hashPassword(password: string): Promise<string>;
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated legacy feature, see #1252
|
|
3
|
+
*
|
|
4
|
+
* AWS Cognito never gets the raw password. We send them
|
|
5
|
+
* a hashed verison using PBKDF2 with SHA-256 and 10,000
|
|
6
|
+
* iterations.
|
|
7
|
+
* @param password The raw password
|
|
8
|
+
* @returns Promise resolving to the hashed password
|
|
9
|
+
*/
|
|
10
|
+
export declare function hashPassword(password: string): Promise<string>;
|
package/dist/general/password.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hashPassword = void 0;
|
|
4
|
-
// ⚠ updating this value will lock all existing users out of their accounts
|
|
5
|
-
/** @internal */
|
|
6
|
-
const SALT = "247 213 94 9 15 236 156 48 194 177 107 216 198 215 169 239";
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated legacy feature, see #1252
|
|
9
|
-
*
|
|
10
|
-
* AWS Cognito never gets the raw password. We send them
|
|
11
|
-
* a hashed verison using PBKDF2 with SHA-256 and 10,000
|
|
12
|
-
* iterations.
|
|
13
|
-
* @param password The raw password
|
|
14
|
-
* @returns Promise resolving to the hashed password
|
|
15
|
-
*/
|
|
16
|
-
async function hashPassword(password) {
|
|
17
|
-
const binaryPassword = new TextEncoder().encode(password);
|
|
18
|
-
const cryptoKey = await crypto.subtle.importKey("raw", binaryPassword, "PBKDF2", false, ["deriveBits"]);
|
|
19
|
-
const options = {
|
|
20
|
-
name: "PBKDF2",
|
|
21
|
-
hash: "SHA-256",
|
|
22
|
-
salt: new Uint8Array(SALT.split(" ").map(Number)),
|
|
23
|
-
iterations: 10000,
|
|
24
|
-
};
|
|
25
|
-
const keyBuffer = new Uint8Array(await crypto.subtle.deriveBits(options, cryptoKey, 256));
|
|
26
|
-
const compositeStr = Array.from(keyBuffer)
|
|
27
|
-
.map(byte => String.fromCharCode(byte))
|
|
28
|
-
.join("");
|
|
29
|
-
return btoa(compositeStr);
|
|
30
|
-
}
|
|
31
|
-
exports.hashPassword = hashPassword;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hashPassword = void 0;
|
|
4
|
+
// ⚠ updating this value will lock all existing users out of their accounts
|
|
5
|
+
/** @internal */
|
|
6
|
+
const SALT = "247 213 94 9 15 236 156 48 194 177 107 216 198 215 169 239";
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated legacy feature, see #1252
|
|
9
|
+
*
|
|
10
|
+
* AWS Cognito never gets the raw password. We send them
|
|
11
|
+
* a hashed verison using PBKDF2 with SHA-256 and 10,000
|
|
12
|
+
* iterations.
|
|
13
|
+
* @param password The raw password
|
|
14
|
+
* @returns Promise resolving to the hashed password
|
|
15
|
+
*/
|
|
16
|
+
async function hashPassword(password) {
|
|
17
|
+
const binaryPassword = new TextEncoder().encode(password);
|
|
18
|
+
const cryptoKey = await crypto.subtle.importKey("raw", binaryPassword, "PBKDF2", false, ["deriveBits"]);
|
|
19
|
+
const options = {
|
|
20
|
+
name: "PBKDF2",
|
|
21
|
+
hash: "SHA-256",
|
|
22
|
+
salt: new Uint8Array(SALT.split(" ").map(Number)),
|
|
23
|
+
iterations: 10000,
|
|
24
|
+
};
|
|
25
|
+
const keyBuffer = new Uint8Array(await crypto.subtle.deriveBits(options, cryptoKey, 256));
|
|
26
|
+
const compositeStr = Array.from(keyBuffer)
|
|
27
|
+
.map(byte => String.fromCharCode(byte))
|
|
28
|
+
.join("");
|
|
29
|
+
return btoa(compositeStr);
|
|
30
|
+
}
|
|
31
|
+
exports.hashPassword = hashPassword;
|
package/dist/general/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* to prevent a key from the JS object prototype (e.g. `__proto__`) from
|
|
3
|
-
* returning an unexpected value (see #1162)
|
|
4
|
-
* @ignore
|
|
5
|
-
*/
|
|
6
|
-
export declare function assertSafeProperty(key: string): asserts key is string;
|
|
1
|
+
/**
|
|
2
|
+
* to prevent a key from the JS object prototype (e.g. `__proto__`) from
|
|
3
|
+
* returning an unexpected value (see #1162)
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export declare function assertSafeProperty(key: string): asserts key is string;
|
package/dist/general/types.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertSafeProperty = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* to prevent a key from the JS object prototype (e.g. `__proto__`) from
|
|
6
|
-
* returning an unexpected value (see #1162)
|
|
7
|
-
* @ignore
|
|
8
|
-
*/
|
|
9
|
-
function assertSafeProperty(key) {
|
|
10
|
-
if (key in {})
|
|
11
|
-
throw new Error("Unacceptable object property");
|
|
12
|
-
}
|
|
13
|
-
exports.assertSafeProperty = assertSafeProperty;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertSafeProperty = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* to prevent a key from the JS object prototype (e.g. `__proto__`) from
|
|
6
|
+
* returning an unexpected value (see #1162)
|
|
7
|
+
* @ignore
|
|
8
|
+
*/
|
|
9
|
+
function assertSafeProperty(key) {
|
|
10
|
+
if (key in {})
|
|
11
|
+
throw new Error("Unacceptable object property");
|
|
12
|
+
}
|
|
13
|
+
exports.assertSafeProperty = assertSafeProperty;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./accessApplication";
|
|
2
|
-
export * from "./crypto";
|
|
3
|
-
export * from "./general";
|
|
4
|
-
export * from "./rules";
|
|
5
|
-
export * from "./schema";
|
|
6
|
-
export * from "./verifications";
|
|
1
|
+
export * from "./accessApplication";
|
|
2
|
+
export * from "./crypto";
|
|
3
|
+
export * from "./general";
|
|
4
|
+
export * from "./rules";
|
|
5
|
+
export * from "./schema";
|
|
6
|
+
export * from "./verifications";
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./accessApplication"), exports);
|
|
18
|
-
__exportStar(require("./crypto"), exports);
|
|
19
|
-
__exportStar(require("./general"), exports);
|
|
20
|
-
__exportStar(require("./rules"), exports);
|
|
21
|
-
__exportStar(require("./schema"), exports);
|
|
22
|
-
__exportStar(require("./verifications"), exports);
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./accessApplication"), exports);
|
|
18
|
+
__exportStar(require("./crypto"), exports);
|
|
19
|
+
__exportStar(require("./general"), exports);
|
|
20
|
+
__exportStar(require("./rules"), exports);
|
|
21
|
+
__exportStar(require("./schema"), exports);
|
|
22
|
+
__exportStar(require("./verifications"), exports);
|
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
import { RuleData, ScoreConfig } from "./types";
|
|
2
|
-
/** @
|
|
3
|
-
export declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { RuleData, ScoreConfig, ScoreRule } from "./types";
|
|
2
|
+
/** evaluates an individual rule, normally you should use {@link calculateScore} */
|
|
3
|
+
export declare function evaluateRule(rule: ScoreRule, data: RuleData): {
|
|
4
|
+
passed: boolean;
|
|
5
|
+
score: number;
|
|
6
|
+
};
|
|
7
|
+
/** @ignore */
|
|
8
|
+
export type ScoreResult = {
|
|
9
|
+
score: number;
|
|
10
|
+
category: string;
|
|
11
|
+
categoryColour: string | undefined;
|
|
12
|
+
diagnostics: {
|
|
13
|
+
version: string;
|
|
14
|
+
config: {
|
|
15
|
+
id: string;
|
|
16
|
+
rules: {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
passed: boolean;
|
|
20
|
+
}[];
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* the main function to calculate a score and category.
|
|
26
|
+
* Might throw an error.
|
|
27
|
+
*/
|
|
28
|
+
export declare function calculateScore(ruleConfig: ScoreConfig, ruleInput: RuleData): Promise<ScoreResult>;
|
|
@@ -1,76 +1,82 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateScore = void 0;
|
|
4
|
-
const evaluateScoreCondition_1 = require("./evaluateScoreCondition");
|
|
5
|
-
const helpers_1 = require("./helpers");
|
|
6
|
-
const general_1 = require("../general");
|
|
7
|
-
const version_1 = require("./version");
|
|
8
|
-
function evaluateASTNode(node, data) {
|
|
9
|
-
if (node.type === "LanguageOperator") {
|
|
10
|
-
if (!node.children.length) {
|
|
11
|
-
// we allow a single child because why not.
|
|
12
|
-
throw new Error("LanguageOperator has no children");
|
|
13
|
-
}
|
|
14
|
-
if (node.operator === "AND") {
|
|
15
|
-
return node.children.every(n => evaluateASTNode(n, data));
|
|
16
|
-
}
|
|
17
|
-
if (node.operator === "OR") {
|
|
18
|
-
return node.children.some(n => evaluateASTNode(n, data));
|
|
19
|
-
}
|
|
20
|
-
throw new Error(`LanguageOperator node has invalid operator '${node.operator}'`);
|
|
21
|
-
}
|
|
22
|
-
if (node.type === "ScoreCondition") {
|
|
23
|
-
return (0, evaluateScoreCondition_1.evaluateScoreCondition)(node, data);
|
|
24
|
-
}
|
|
25
|
-
throw new Error("ASTNode has invalid type");
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
score
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateScore = exports.evaluateRule = void 0;
|
|
4
|
+
const evaluateScoreCondition_1 = require("./evaluateScoreCondition");
|
|
5
|
+
const helpers_1 = require("./helpers");
|
|
6
|
+
const general_1 = require("../general");
|
|
7
|
+
const version_1 = require("./version");
|
|
8
|
+
function evaluateASTNode(node, data) {
|
|
9
|
+
if (node.type === "LanguageOperator") {
|
|
10
|
+
if (!node.children.length) {
|
|
11
|
+
// we allow a single child because why not.
|
|
12
|
+
throw new Error("LanguageOperator has no children");
|
|
13
|
+
}
|
|
14
|
+
if (node.operator === "AND") {
|
|
15
|
+
return node.children.every(n => evaluateASTNode(n, data));
|
|
16
|
+
}
|
|
17
|
+
if (node.operator === "OR") {
|
|
18
|
+
return node.children.some(n => evaluateASTNode(n, data));
|
|
19
|
+
}
|
|
20
|
+
throw new Error(`LanguageOperator node has invalid operator '${node.operator}'`);
|
|
21
|
+
}
|
|
22
|
+
if (node.type === "ScoreCondition") {
|
|
23
|
+
return (0, evaluateScoreCondition_1.evaluateScoreCondition)(node, data);
|
|
24
|
+
}
|
|
25
|
+
throw new Error("ASTNode has invalid type");
|
|
26
|
+
}
|
|
27
|
+
/** evaluates an individual rule, normally you should use {@link calculateScore} */
|
|
28
|
+
function evaluateRule(rule, data) {
|
|
29
|
+
if (rule.tree.length !== 1) {
|
|
30
|
+
throw new Error("A rule may only have 1 root node");
|
|
31
|
+
}
|
|
32
|
+
const rulePassed = rule.tree.every(n => evaluateASTNode(n, data));
|
|
33
|
+
return {
|
|
34
|
+
passed: rulePassed,
|
|
35
|
+
score: rulePassed ? rule.trueWeight : rule.falseWeight,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.evaluateRule = evaluateRule;
|
|
39
|
+
/**
|
|
40
|
+
* We guarantee that the same configId or ruleId will always produce the same output.
|
|
41
|
+
* This is the closest thing we have to versioning.
|
|
42
|
+
*/
|
|
43
|
+
const jsonId = (json) => (0, general_1.hashPassword)(JSON.stringify(json)).then(hash => hash.slice(0, 10));
|
|
44
|
+
/**
|
|
45
|
+
* the main function to calculate a score and category.
|
|
46
|
+
* Might throw an error.
|
|
47
|
+
*/
|
|
48
|
+
async function calculateScore(ruleConfig, ruleInput) {
|
|
49
|
+
const activeRules = ruleConfig.rules.filter(rule => rule.enabled !== false);
|
|
50
|
+
if (!activeRules.length) {
|
|
51
|
+
throw new Error("There are no enabled rules");
|
|
52
|
+
}
|
|
53
|
+
const result = activeRules.map(rule => evaluateRule(rule, ruleInput));
|
|
54
|
+
const [addOrMultiply, initialValue] = (0, helpers_1.getCombinator)(ruleConfig.combinator);
|
|
55
|
+
const finalScore = result
|
|
56
|
+
.map(x => x.score)
|
|
57
|
+
.reduce(addOrMultiply, initialValue);
|
|
58
|
+
const matchingCategories = (0, helpers_1.addInfiniteThresholdBoundaries)(ruleConfig.scoreThresholds).filter(threshold => finalScore >= threshold.from && finalScore <= threshold.to);
|
|
59
|
+
if (matchingCategories.length === 0) {
|
|
60
|
+
throw new Error(`No categories match the final score (${finalScore})`);
|
|
61
|
+
}
|
|
62
|
+
if (matchingCategories.length !== 1) {
|
|
63
|
+
throw new Error(`Multiple categories match the final score (${finalScore})`);
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
score: finalScore,
|
|
67
|
+
category: matchingCategories[0].name,
|
|
68
|
+
categoryColour: matchingCategories[0].colour,
|
|
69
|
+
diagnostics: {
|
|
70
|
+
version: version_1.SUBMISSION_RULES_VERSION,
|
|
71
|
+
config: {
|
|
72
|
+
id: await jsonId(ruleConfig),
|
|
73
|
+
rules: await Promise.all(result.map(async ({ passed }, i) => {
|
|
74
|
+
const r = ruleConfig.rules[i];
|
|
75
|
+
const ruleId = await jsonId(r);
|
|
76
|
+
return { id: ruleId, name: r.name, passed };
|
|
77
|
+
})),
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
exports.calculateScore = calculateScore;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RuleData } from "./types";
|
|
3
|
-
export declare const convertInstanceToRuleInput: (
|
|
1
|
+
import { ProfileObject, RealVer, Schema } from "@raytio/types";
|
|
2
|
+
import { RuleData } from "./types";
|
|
3
|
+
export declare const convertInstanceToRuleInput: (POs: ProfileObject[], realVers: RealVer[], getSchema: (schemaName: string) => Promise<Schema>) => Promise<RuleData>;
|