@raytio/core 10.0.1 → 10.1.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 +4 -0
- package/README.md +35 -2
- 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 -11
- 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 -7
- package/dist/general/conditional.js +32 -22
- package/dist/general/date.d.ts +2 -0
- package/dist/general/date.js +18 -0
- package/dist/general/index.d.ts +4 -3
- package/dist/general/index.js +20 -19
- 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 +23 -23
- package/dist/rules/calculateScore.js +76 -76
- package/dist/rules/convertInstanceToRuleInput.d.ts +3 -3
- package/dist/rules/convertInstanceToRuleInput.js +139 -139
- package/dist/rules/evaluateScoreCondition.d.ts +2 -2
- package/dist/rules/evaluateScoreCondition.js +45 -45
- 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 +55 -55
- package/dist/rules/helpers/getLhsTypeofValue.d.ts +0 -0
- package/dist/rules/helpers/getLhsTypeofValue.js +1 -0
- package/dist/rules/helpers/getValueFromPath.d.ts +2 -0
- package/dist/rules/helpers/getValueFromPath.js +35 -0
- 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/rebuildInfiniteValues.d.ts +3 -0
- package/dist/rules/helpers/rebuildInfiniteValues.js +6 -0
- 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 +47 -47
- package/dist/rules/index.d.ts +7 -7
- package/dist/rules/index.js +25 -25
- package/dist/rules/isScoreResultValid.d.ts +2 -0
- package/dist/rules/isScoreResultValid.js +9 -0
- package/dist/rules/operators/array.d.ts +2 -0
- package/dist/rules/operators/array.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 +91 -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/types/operators.d.ts +19 -0
- package/dist/rules/types/operators.js +2 -0
- package/dist/rules/types/score.d.ts +50 -0
- package/dist/rules/types/score.js +2 -0
- 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/conditional.d.ts +7 -0
- package/dist/util/conditional.js +15 -0
- package/dist/util/handleResponse.d.ts +1 -1
- package/dist/util/handleResponse.js +21 -21
- package/dist/util/hash.d.ts +1 -0
- package/dist/util/hash.js +11 -0
- package/dist/util/index.d.ts +2 -2
- package/dist/util/index.js +18 -18
- package/dist/verifications/checkSingleVerification.d.ts +9 -0
- package/dist/verifications/checkSingleVerification.js +29 -0
- package/dist/verifications/checkVerifications.d.ts +1 -0
- package/dist/verifications/checkVerifications.js +16 -0
- package/dist/verifications/checkVerificationsNew.d.ts +1 -0
- package/dist/verifications/checkVerificationsNew.js +16 -0
- package/dist/verifications/cleanInstance.d.ts +9 -9
- package/dist/verifications/cleanInstance.js +15 -15
- package/dist/verifications/getOwnRealVerifications.d.ts +14 -0
- package/dist/verifications/getOwnRealVerifications.js +64 -0
- package/dist/verifications/getPOVerification.d.ts +16 -16
- package/dist/verifications/getPOVerification.js +94 -94
- package/dist/verifications/getRealVerifications.d.ts +22 -0
- package/dist/verifications/getRealVerifications.js +71 -0
- 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/getOwnRealVerifications.d.ts +13 -13
- package/dist/verifications/verifyCheck/getOwnRealVerifications.js +64 -63
- package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.d.ts +19 -19
- package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.js +72 -71
- package/dist/verifications/verifyCheck/index.d.ts +3 -3
- package/dist/verifications/verifyCheck/index.js +21 -21
- 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/dist/verifications/verifyCheck/util/canonicalJsonify.d.ts +1 -0
- package/dist/verifications/verifyCheck/util/canonicalJsonify.js +48 -0
- package/dist/verifications/verifyCheck/util/getValuesForAField.d.ts +2 -0
- package/dist/verifications/verifyCheck/util/getValuesForAField.js +9 -0
- package/dist/verifications/verifyCheck/util/index.d.ts +2 -0
- package/dist/verifications/verifyCheck/util/index.js +14 -0
- package/package.json +4 -4
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAADecryptor = void 0;
|
|
4
|
-
const util_1 = require("../util");
|
|
5
|
-
/**
|
|
6
|
-
* Fetchs the public and private keys for an Access Application, then initializes
|
|
7
|
-
* the {@link https://npm.im/@raytio/maxcryptor|Maxcryptor}'s `ApplicationEncryptor`.
|
|
8
|
-
* @returns an `ApplicationEncryptor` and the public key of the Access Application
|
|
9
|
-
*/
|
|
10
|
-
async function getAADecryptor({ aId, apiUrl, maxcryptor, apiToken, }) {
|
|
11
|
-
const { n_id: publicKeyNId, properties: publicKey } = (await fetch(`${apiUrl}/share/v2/access_application/${aId}/public_key`, {
|
|
12
|
-
headers: { Authorization: `Bearer ${apiToken}` },
|
|
13
|
-
}).then(util_1.handleResponse));
|
|
14
|
-
const privateKey = await fetch(`${apiUrl}/share/v2/access_application/public_key/${publicKeyNId}/private_key`, { headers: { Authorization: `Bearer ${apiToken}` } }).then(util_1.handleResponse);
|
|
15
|
-
return {
|
|
16
|
-
decryptor: await maxcryptor.loadApplicationEncryptorForDecryption(publicKey, privateKey),
|
|
17
|
-
publicKeyNId,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
exports.getAADecryptor = getAADecryptor;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAADecryptor = void 0;
|
|
4
|
+
const util_1 = require("../util");
|
|
5
|
+
/**
|
|
6
|
+
* Fetchs the public and private keys for an Access Application, then initializes
|
|
7
|
+
* the {@link https://npm.im/@raytio/maxcryptor|Maxcryptor}'s `ApplicationEncryptor`.
|
|
8
|
+
* @returns an `ApplicationEncryptor` and the public key of the Access Application
|
|
9
|
+
*/
|
|
10
|
+
async function getAADecryptor({ aId, apiUrl, maxcryptor, apiToken, }) {
|
|
11
|
+
const { n_id: publicKeyNId, properties: publicKey } = (await fetch(`${apiUrl}/share/v2/access_application/${aId}/public_key`, {
|
|
12
|
+
headers: { Authorization: `Bearer ${apiToken}` },
|
|
13
|
+
}).then(util_1.handleResponse));
|
|
14
|
+
const privateKey = await fetch(`${apiUrl}/share/v2/access_application/public_key/${publicKeyNId}/private_key`, { headers: { Authorization: `Bearer ${apiToken}` } }).then(util_1.handleResponse);
|
|
15
|
+
return {
|
|
16
|
+
decryptor: await maxcryptor.loadApplicationEncryptorForDecryption(publicKey, privateKey),
|
|
17
|
+
publicKeyNId,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.getAADecryptor = getAADecryptor;
|
package/dist/crypto/helpers.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Encrypted } from "@raytio/types";
|
|
2
|
-
/**
|
|
3
|
-
* Determines where the input is an encrypted Raytio object
|
|
4
|
-
* @param value anything
|
|
5
|
-
* @returns true or false depending on whether the input is an encrypted Raytio object
|
|
6
|
-
*/
|
|
7
|
-
export declare const isEncrypted: (value: unknown) => value is Encrypted<string>;
|
|
8
|
-
/**
|
|
9
|
-
* Determines where the input is an encrypted Raytio file
|
|
10
|
-
* @param value anything
|
|
11
|
-
* @returns true or false depending on whether the input is an encrypted Raytio file
|
|
12
|
-
*/
|
|
13
|
-
export declare const isEncryptedFile: (value: unknown) => value is Encrypted<string>;
|
|
14
|
-
/**
|
|
15
|
-
* Given a profile object's properties, returns the number
|
|
16
|
-
* of properties that are encryted.
|
|
17
|
-
*/
|
|
18
|
-
export declare const someEncrypted: <T extends object, K extends keyof T>(obj: T) => number;
|
|
1
|
+
import { Encrypted } from "@raytio/types";
|
|
2
|
+
/**
|
|
3
|
+
* Determines where the input is an encrypted Raytio object
|
|
4
|
+
* @param value anything
|
|
5
|
+
* @returns true or false depending on whether the input is an encrypted Raytio object
|
|
6
|
+
*/
|
|
7
|
+
export declare const isEncrypted: (value: unknown) => value is Encrypted<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Determines where the input is an encrypted Raytio file
|
|
10
|
+
* @param value anything
|
|
11
|
+
* @returns true or false depending on whether the input is an encrypted Raytio file
|
|
12
|
+
*/
|
|
13
|
+
export declare const isEncryptedFile: (value: unknown) => value is Encrypted<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Given a profile object's properties, returns the number
|
|
16
|
+
* of properties that are encryted.
|
|
17
|
+
*/
|
|
18
|
+
export declare const someEncrypted: <T extends object, K extends keyof T>(obj: T) => number;
|
package/dist/crypto/helpers.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.someEncrypted = exports.isEncryptedFile = exports.isEncrypted = void 0;
|
|
4
|
-
const ramda_1 = require("ramda");
|
|
5
|
-
/**
|
|
6
|
-
* Determines where the input is an encrypted Raytio object
|
|
7
|
-
* @param value anything
|
|
8
|
-
* @returns true or false depending on whether the input is an encrypted Raytio object
|
|
9
|
-
*/
|
|
10
|
-
const isEncrypted = (value) => typeof value === "object" &&
|
|
11
|
-
value !== null &&
|
|
12
|
-
"encrypted_key" in value &&
|
|
13
|
-
"encrypted_data" in value;
|
|
14
|
-
exports.isEncrypted = isEncrypted;
|
|
15
|
-
/**
|
|
16
|
-
* Determines where the input is an encrypted Raytio file
|
|
17
|
-
* @param value anything
|
|
18
|
-
* @returns true or false depending on whether the input is an encrypted Raytio file
|
|
19
|
-
*/
|
|
20
|
-
const isEncryptedFile = (value) => { var _a, _b; return (0, exports.isEncrypted)(value) && ((_b = (_a = value === null || value === void 0 ? void 0 : value.encrypted_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.slice(0, 4)) === "urn:"; };
|
|
21
|
-
exports.isEncryptedFile = isEncryptedFile;
|
|
22
|
-
/**
|
|
23
|
-
* Given a profile object's properties, returns the number
|
|
24
|
-
* of properties that are encryted.
|
|
25
|
-
*/
|
|
26
|
-
exports.someEncrypted = (0, ramda_1.pipe)(ramda_1.values, (0, ramda_1.filter)(x => (0, exports.isEncrypted)(x) && !(0, exports.isEncryptedFile)(x)), ramda_1.length);
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.someEncrypted = exports.isEncryptedFile = exports.isEncrypted = void 0;
|
|
4
|
+
const ramda_1 = require("ramda");
|
|
5
|
+
/**
|
|
6
|
+
* Determines where the input is an encrypted Raytio object
|
|
7
|
+
* @param value anything
|
|
8
|
+
* @returns true or false depending on whether the input is an encrypted Raytio object
|
|
9
|
+
*/
|
|
10
|
+
const isEncrypted = (value) => typeof value === "object" &&
|
|
11
|
+
value !== null &&
|
|
12
|
+
"encrypted_key" in value &&
|
|
13
|
+
"encrypted_data" in value;
|
|
14
|
+
exports.isEncrypted = isEncrypted;
|
|
15
|
+
/**
|
|
16
|
+
* Determines where the input is an encrypted Raytio file
|
|
17
|
+
* @param value anything
|
|
18
|
+
* @returns true or false depending on whether the input is an encrypted Raytio file
|
|
19
|
+
*/
|
|
20
|
+
const isEncryptedFile = (value) => { var _a, _b; return (0, exports.isEncrypted)(value) && ((_b = (_a = value === null || value === void 0 ? void 0 : value.encrypted_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.slice(0, 4)) === "urn:"; };
|
|
21
|
+
exports.isEncryptedFile = isEncryptedFile;
|
|
22
|
+
/**
|
|
23
|
+
* Given a profile object's properties, returns the number
|
|
24
|
+
* of properties that are encryted.
|
|
25
|
+
*/
|
|
26
|
+
exports.someEncrypted = (0, ramda_1.pipe)(ramda_1.values, (0, ramda_1.filter)(x => (0, exports.isEncrypted)(x) && !(0, exports.isEncryptedFile)(x)), ramda_1.length);
|
package/dist/crypto/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./cognitoAttributes";
|
|
2
|
-
export * from "./decryptSharedData";
|
|
3
|
-
export * from "./getAADecryptor";
|
|
4
|
-
export * from "./helpers";
|
|
1
|
+
export * from "./cognitoAttributes";
|
|
2
|
+
export * from "./decryptSharedData";
|
|
3
|
+
export * from "./getAADecryptor";
|
|
4
|
+
export * from "./helpers";
|
package/dist/crypto/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
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("./cognitoAttributes"), exports);
|
|
18
|
-
// not exporting decryptKeys; it's not a public API
|
|
19
|
-
__exportStar(require("./decryptSharedData"), exports);
|
|
20
|
-
__exportStar(require("./getAADecryptor"), exports);
|
|
21
|
-
__exportStar(require("./helpers"), 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("./cognitoAttributes"), exports);
|
|
18
|
+
// not exporting decryptKeys; it's not a public API
|
|
19
|
+
__exportStar(require("./decryptSharedData"), exports);
|
|
20
|
+
__exportStar(require("./getAADecryptor"), exports);
|
|
21
|
+
__exportStar(require("./helpers"), exports);
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
declare type ConditionValue = string | number | boolean;
|
|
2
|
-
/**
|
|
3
|
-
* Checks all other form values in case any have a
|
|
4
|
-
* trigger value that makes this field
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
declare type ConditionValue = string | number | boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Checks all other form values in case any have a
|
|
4
|
+
* trigger value that makes this field required.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```json
|
|
8
|
+
* [
|
|
9
|
+
* { "if": { "age": [17, 18], "city": ["Taupō"] } },
|
|
10
|
+
* { "if": { "age": [19, 20] } }
|
|
11
|
+
* ]
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* This means `[(age=17 OR age=18) AND (city=Taupō)] OR [(age=19 OR age=20)]`
|
|
15
|
+
*/
|
|
16
|
+
export declare const isConditionMet: (condition: Record<string, ConditionValue[]>, formValues: Record<string, unknown>) => boolean;
|
|
17
|
+
export {};
|
|
@@ -1,22 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isConditionMet = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Checks all other form values in case any have a
|
|
6
|
-
* trigger value that makes this field
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isConditionMet = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Checks all other form values in case any have a
|
|
6
|
+
* trigger value that makes this field required.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```json
|
|
10
|
+
* [
|
|
11
|
+
* { "if": { "age": [17, 18], "city": ["Taupō"] } },
|
|
12
|
+
* { "if": { "age": [19, 20] } }
|
|
13
|
+
* ]
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* This means `[(age=17 OR age=18) AND (city=Taupō)] OR [(age=19 OR age=20)]`
|
|
17
|
+
*/
|
|
18
|
+
const isConditionMet = (condition, formValues) => {
|
|
19
|
+
// .every() illogically returns true for arrays with zero length
|
|
20
|
+
// a condition where `if: {}` should not return true by our definition
|
|
21
|
+
const c = Object.entries(condition);
|
|
22
|
+
if (!c.length)
|
|
23
|
+
return false;
|
|
24
|
+
return c.every(([fieldName, triggerValues]) => {
|
|
25
|
+
if (Array.isArray(formValues[fieldName])) {
|
|
26
|
+
// if it's a multiselect, check if any of the selected values match the criteria
|
|
27
|
+
return formValues[fieldName].some(val => triggerValues.includes(val));
|
|
28
|
+
}
|
|
29
|
+
return triggerValues.includes(formValues[fieldName]);
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
exports.isConditionMet = isConditionMet;
|
|
@@ -0,0 +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;
|
package/dist/general/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export * from "./conditional";
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
1
|
+
export * from "./conditional";
|
|
2
|
+
export * from "./date";
|
|
3
|
+
export * from "./password";
|
|
4
|
+
export * from "./types";
|
package/dist/general/index.js
CHANGED
|
@@ -1,19 +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("./
|
|
19
|
-
__exportStar(require("./
|
|
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,23 @@
|
|
|
1
|
-
import { RuleData, ScoreConfig } from "./types";
|
|
2
|
-
/** @ignore */
|
|
3
|
-
export declare type ScoreResult = {
|
|
4
|
-
score: number;
|
|
5
|
-
category: string;
|
|
6
|
-
categoryColour: string | undefined;
|
|
7
|
-
diagnostics: {
|
|
8
|
-
version: string;
|
|
9
|
-
config: {
|
|
10
|
-
id: string;
|
|
11
|
-
rules: {
|
|
12
|
-
id: string;
|
|
13
|
-
name: string;
|
|
14
|
-
passed: boolean;
|
|
15
|
-
}[];
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* the main function to calculate a score and category.
|
|
21
|
-
* Might throw an error.
|
|
22
|
-
*/
|
|
23
|
-
export declare function calculateScore(ruleConfig: ScoreConfig, ruleInput: RuleData): Promise<ScoreResult>;
|
|
1
|
+
import { RuleData, ScoreConfig } from "./types";
|
|
2
|
+
/** @ignore */
|
|
3
|
+
export declare type ScoreResult = {
|
|
4
|
+
score: number;
|
|
5
|
+
category: string;
|
|
6
|
+
categoryColour: string | undefined;
|
|
7
|
+
diagnostics: {
|
|
8
|
+
version: string;
|
|
9
|
+
config: {
|
|
10
|
+
id: string;
|
|
11
|
+
rules: {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
passed: boolean;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* the main function to calculate a score and category.
|
|
21
|
+
* Might throw an error.
|
|
22
|
+
*/
|
|
23
|
+
export declare function calculateScore(ruleConfig: ScoreConfig, ruleInput: RuleData): Promise<ScoreResult>;
|