@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/schema/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
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("./labels"), 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("./labels"), exports);
|
package/dist/schema/labels.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** Finds the label (on a profile object) which is the schema name */
|
|
2
|
-
export declare const findSchemaLabel: (labels: string[] | undefined) => string | undefined;
|
|
1
|
+
/** Finds the label (on a profile object) which is the schema name */
|
|
2
|
+
export declare const findSchemaLabel: (labels: string[] | undefined) => string | undefined;
|
package/dist/schema/labels.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findSchemaLabel = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* every possible label should be listed here,
|
|
6
|
-
* finds the schemaName by searching the list of labels for the
|
|
7
|
-
* first one that is not in this list
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
const LABELS_DENYLIST = [
|
|
11
|
-
"Document",
|
|
12
|
-
"ProfileObject",
|
|
13
|
-
"ApplicationObject",
|
|
14
|
-
"ServiceProvider",
|
|
15
|
-
"receiverCreated",
|
|
16
|
-
];
|
|
17
|
-
/** Finds the label (on a profile object) which is the schema name */
|
|
18
|
-
const findSchemaLabel = (labels) => labels === null || labels === void 0 ? void 0 : labels.find(label => !LABELS_DENYLIST.includes(label) &&
|
|
19
|
-
!label.startsWith("related_service_provider:"));
|
|
20
|
-
exports.findSchemaLabel = findSchemaLabel;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findSchemaLabel = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* every possible label should be listed here, because the client
|
|
6
|
+
* finds the schemaName by searching the list of labels for the
|
|
7
|
+
* first one that is not in this list
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
const LABELS_DENYLIST = [
|
|
11
|
+
"Document",
|
|
12
|
+
"ProfileObject",
|
|
13
|
+
"ApplicationObject",
|
|
14
|
+
"ServiceProvider",
|
|
15
|
+
"receiverCreated",
|
|
16
|
+
];
|
|
17
|
+
/** Finds the label (on a profile object) which is the schema name */
|
|
18
|
+
const findSchemaLabel = (labels) => labels === null || labels === void 0 ? void 0 : labels.find(label => !LABELS_DENYLIST.includes(label) &&
|
|
19
|
+
!label.startsWith("related_service_provider:"));
|
|
20
|
+
exports.findSchemaLabel = findSchemaLabel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* eslint-disable fp/no-mutating-methods, fp/no-mutation,
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.canonicalJsonify = void 0;
|
|
5
|
-
const isObject = (a) => Object.prototype.toString.call(a) === "[object Object]"; // TODO: wtf ?
|
|
6
|
-
const REGEX =
|
|
7
|
-
// eslint-disable-next-line no-control-regex
|
|
8
|
-
/[\u0000-\u001F]|"|\\|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g;
|
|
9
|
-
const SLASH_ESC = {
|
|
10
|
-
"\b": "\\b",
|
|
11
|
-
"\t": "\\t",
|
|
12
|
-
"\n": "\\n",
|
|
13
|
-
"\f": "\\f",
|
|
14
|
-
"\r": "\\r",
|
|
15
|
-
'"': '\\"',
|
|
16
|
-
"\\": "\\\\",
|
|
17
|
-
};
|
|
18
|
-
const replacer = (char) => SLASH_ESC[char] ||
|
|
19
|
-
`\\u${char.charCodeAt(0).toString(16).toUpperCase().padStart(4, "0")}`;
|
|
20
|
-
function copyObjectWithSortedKeys(object) {
|
|
21
|
-
if (isObject(object)) {
|
|
22
|
-
return `{${Object.keys(object)
|
|
23
|
-
.sort()
|
|
24
|
-
.map(key => `"${key}":${copyObjectWithSortedKeys(object[key])}`)
|
|
25
|
-
.join(",")}}`;
|
|
26
|
-
}
|
|
27
|
-
if (Array.isArray(object)) {
|
|
28
|
-
return `[${object.map(copyObjectWithSortedKeys).join(",")}]`;
|
|
29
|
-
}
|
|
30
|
-
if (typeof object === "number" && object % 1 !== 0) {
|
|
31
|
-
if (Number.isNaN(object) || !Number.isFinite(object))
|
|
32
|
-
return "null";
|
|
33
|
-
// float
|
|
34
|
-
const exponent = Math.floor(Math.log10(Math.abs(object)));
|
|
35
|
-
let mantissa = `${object / 10 ** exponent}`;
|
|
36
|
-
if (!mantissa.includes("."))
|
|
37
|
-
mantissa += ".0";
|
|
38
|
-
return `${mantissa}E${exponent}`;
|
|
39
|
-
}
|
|
40
|
-
if (typeof object === "string")
|
|
41
|
-
return `"${object.replace(REGEX, replacer)}"`;
|
|
42
|
-
return object; // bool or int
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* @internal
|
|
46
|
-
* spec compliant, and matches
|
|
47
|
-
* https://gitlab.com/raytio/mono/-/blob/devo/common/signing/signing/canonical_json.py
|
|
48
|
-
*/
|
|
49
|
-
const canonicalJsonify = (object) => `${copyObjectWithSortedKeys(object)}`;
|
|
50
|
-
exports.canonicalJsonify = canonicalJsonify;
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable fp/no-mutating-methods, fp/no-mutation, prefer-reflect */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.canonicalJsonify = void 0;
|
|
5
|
+
const isObject = (a) => Object.prototype.toString.call(a) === "[object Object]"; // TODO: wtf ?
|
|
6
|
+
const REGEX =
|
|
7
|
+
// eslint-disable-next-line no-control-regex
|
|
8
|
+
/[\u0000-\u001F]|"|\\|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g;
|
|
9
|
+
const SLASH_ESC = {
|
|
10
|
+
"\b": "\\b",
|
|
11
|
+
"\t": "\\t",
|
|
12
|
+
"\n": "\\n",
|
|
13
|
+
"\f": "\\f",
|
|
14
|
+
"\r": "\\r",
|
|
15
|
+
'"': '\\"',
|
|
16
|
+
"\\": "\\\\",
|
|
17
|
+
};
|
|
18
|
+
const replacer = (char) => SLASH_ESC[char] ||
|
|
19
|
+
`\\u${char.charCodeAt(0).toString(16).toUpperCase().padStart(4, "0")}`;
|
|
20
|
+
function copyObjectWithSortedKeys(object) {
|
|
21
|
+
if (isObject(object)) {
|
|
22
|
+
return `{${Object.keys(object)
|
|
23
|
+
.sort()
|
|
24
|
+
.map(key => `"${key}":${copyObjectWithSortedKeys(object[key])}`)
|
|
25
|
+
.join(",")}}`;
|
|
26
|
+
}
|
|
27
|
+
if (Array.isArray(object)) {
|
|
28
|
+
return `[${object.map(copyObjectWithSortedKeys).join(",")}]`;
|
|
29
|
+
}
|
|
30
|
+
if (typeof object === "number" && object % 1 !== 0) {
|
|
31
|
+
if (Number.isNaN(object) || !Number.isFinite(object))
|
|
32
|
+
return "null";
|
|
33
|
+
// float
|
|
34
|
+
const exponent = Math.floor(Math.log10(Math.abs(object)));
|
|
35
|
+
let mantissa = `${object / 10 ** exponent}`;
|
|
36
|
+
if (!mantissa.includes("."))
|
|
37
|
+
mantissa += ".0";
|
|
38
|
+
return `${mantissa}E${exponent}`;
|
|
39
|
+
}
|
|
40
|
+
if (typeof object === "string")
|
|
41
|
+
return `"${object.replace(REGEX, replacer)}"`;
|
|
42
|
+
return object; // bool or int
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
* spec compliant, and matches
|
|
47
|
+
* https://gitlab.com/raytio/mono/-/blob/devo/common/signing/signing/canonical_json.py
|
|
48
|
+
*/
|
|
49
|
+
const canonicalJsonify = (object) => `${copyObjectWithSortedKeys(object)}`;
|
|
50
|
+
exports.canonicalJsonify = canonicalJsonify;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.handleResponse = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @internal
|
|
6
|
-
* Throws an error if the API request fails.
|
|
7
|
-
* Drop-in replacement for `response.json()`
|
|
8
|
-
* @example
|
|
9
|
-
* ```
|
|
10
|
-
* const json = await fetch(...).then(handleResponse)
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
const handleResponse = async (response) => {
|
|
14
|
-
const json = await response.json();
|
|
15
|
-
// json could be a string | number
|
|
16
|
-
if (typeof json === "object" && "message" in json) {
|
|
17
|
-
throw new Error(json.message);
|
|
18
|
-
}
|
|
19
|
-
return json;
|
|
20
|
-
};
|
|
21
|
-
exports.handleResponse = handleResponse;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleResponse = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* Throws an error if the API request fails.
|
|
7
|
+
* Drop-in replacement for `response.json()`
|
|
8
|
+
* @example
|
|
9
|
+
* ```
|
|
10
|
+
* const json = await fetch(...).then(handleResponse)
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
const handleResponse = async (response) => {
|
|
14
|
+
const json = await response.json();
|
|
15
|
+
// json could be a string | number
|
|
16
|
+
if (typeof json === "object" && json && "message" in json) {
|
|
17
|
+
throw new Error(json.message);
|
|
18
|
+
}
|
|
19
|
+
return json;
|
|
20
|
+
};
|
|
21
|
+
exports.handleResponse = handleResponse;
|
package/dist/util/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./canonicalJsonify";
|
|
2
|
-
export * from "./handleResponse";
|
|
1
|
+
export * from "./canonicalJsonify";
|
|
2
|
+
export * from "./handleResponse";
|
package/dist/util/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
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("./canonicalJsonify"), exports);
|
|
18
|
-
__exportStar(require("./handleResponse"), 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("./canonicalJsonify"), exports);
|
|
18
|
+
__exportStar(require("./handleResponse"), exports);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Instance } from "@raytio/types";
|
|
2
|
-
/**
|
|
3
|
-
* The API response from share/v2/access_application/instance/:iId
|
|
4
|
-
* returns a complicated hashed_n_id format, so you need to clean up
|
|
5
|
-
* the API response using this function as soon as possible.
|
|
6
|
-
*
|
|
7
|
-
* We relace `hashed_n_id`s with a string `HASHED::{NId}::{AId}`
|
|
8
|
-
*/
|
|
9
|
-
export declare function cleanInstance(instance: Instance): Instance;
|
|
1
|
+
import { Instance } from "@raytio/types";
|
|
2
|
+
/**
|
|
3
|
+
* The API response from share/v2/access_application/instance/:iId
|
|
4
|
+
* returns a complicated hashed_n_id format, so you need to clean up
|
|
5
|
+
* the API response using this function as soon as possible.
|
|
6
|
+
*
|
|
7
|
+
* We relace `hashed_n_id`s with a string `HASHED::{NId}::{AId}`
|
|
8
|
+
*/
|
|
9
|
+
export declare function cleanInstance(instance: Instance): Instance;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cleanInstance = void 0;
|
|
4
|
-
const ramda_1 = require("ramda");
|
|
5
|
-
/**
|
|
6
|
-
* The API response from share/v2/access_application/instance/:iId
|
|
7
|
-
* returns a complicated hashed_n_id format, so you need to clean up
|
|
8
|
-
* the API response using this function as soon as possible.
|
|
9
|
-
*
|
|
10
|
-
* We relace `hashed_n_id`s with a string `HASHED::{NId}::{AId}`
|
|
11
|
-
*/
|
|
12
|
-
function cleanInstance(instance) {
|
|
13
|
-
return Object.assign(Object.assign({}, instance), { profile_objects: instance.profile_objects.map((PO) => (Object.assign(Object.assign({}, (0, ramda_1.omit)(["hashed_n_id"], PO)), { n_id: PO.n_id || `HASHED::${PO.hashed_n_id}::${instance.a_id}` }))) });
|
|
14
|
-
}
|
|
15
|
-
exports.cleanInstance = cleanInstance;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cleanInstance = void 0;
|
|
4
|
+
const ramda_1 = require("ramda");
|
|
5
|
+
/**
|
|
6
|
+
* The API response from share/v2/access_application/instance/:iId
|
|
7
|
+
* returns a complicated hashed_n_id format, so you need to clean up
|
|
8
|
+
* the API response using this function as soon as possible.
|
|
9
|
+
*
|
|
10
|
+
* We relace `hashed_n_id`s with a string `HASHED::{NId}::{AId}`
|
|
11
|
+
*/
|
|
12
|
+
function cleanInstance(instance) {
|
|
13
|
+
return Object.assign(Object.assign({}, instance), { profile_objects: instance.profile_objects.map((PO) => (Object.assign(Object.assign({}, (0, ramda_1.omit)(["hashed_n_id"], PO)), { n_id: PO.n_id || `HASHED::${PO.hashed_n_id}::${instance.a_id}` }))) });
|
|
14
|
+
}
|
|
15
|
+
exports.cleanInstance = cleanInstance;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { FieldVerification, ProfileObject, POVerification, RealVer, Schema, VerificationProvider, ProfileObjectForUpload, NId } from "@raytio/types";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { FieldVerification, ProfileObject, POVerification, RealVer, Schema, VerificationProvider, ProfileObjectForUpload, NId } from "@raytio/types";
|
|
2
|
+
export type VerDetails = {
|
|
3
|
+
sourceNId?: NId;
|
|
4
|
+
verifiers: VerificationProvider[];
|
|
5
|
+
/** field only present for expired verifications */
|
|
6
|
+
expiryDate?: Date;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Determines the verification status of a profile object, and its individual fields.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getPOVerification({ PO, schema, realVers, }: {
|
|
12
|
+
PO: ProfileObject | ProfileObjectForUpload;
|
|
13
|
+
schema: Schema;
|
|
14
|
+
realVers: RealVer[];
|
|
15
|
+
}): {
|
|
16
|
+
status: POVerification;
|
|
17
|
+
details: VerDetails;
|
|
18
|
+
fieldVerifications: Record<string, FieldVerification>;
|
|
19
|
+
};
|
|
@@ -1,94 +1,105 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPOVerification = void 0;
|
|
4
|
-
const ramda_1 = require("ramda");
|
|
5
|
-
const types_1 = require("@raytio/types");
|
|
6
|
-
const crypto_1 = require("../crypto");
|
|
7
|
-
const getVerifiedBy_1 = require("./getVerifiedBy");
|
|
8
|
-
const maybeRereference_1 = require("./maybeRereference");
|
|
9
|
-
const general_1 = require("../general");
|
|
10
|
-
const schema_1 = require("../schema");
|
|
11
|
-
/**
|
|
12
|
-
* Determines the verification status of a profile object, and its individual fields.
|
|
13
|
-
*/
|
|
14
|
-
function getPOVerification({ PO, schema, realVers, }) {
|
|
15
|
-
var _a, _b;
|
|
16
|
-
// safe guard to avoid a misleading response from this function
|
|
17
|
-
const schemaName = PO.schema || (0, schema_1.findSchemaLabel)(PO.labels);
|
|
18
|
-
if (schema.name !== schemaName) {
|
|
19
|
-
throw new Error(`Wrong schema supplied to getPOVerification: ${schema.name} != ${schemaName}`);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPOVerification = void 0;
|
|
4
|
+
const ramda_1 = require("ramda");
|
|
5
|
+
const types_1 = require("@raytio/types");
|
|
6
|
+
const crypto_1 = require("../crypto");
|
|
7
|
+
const getVerifiedBy_1 = require("./getVerifiedBy");
|
|
8
|
+
const maybeRereference_1 = require("./maybeRereference");
|
|
9
|
+
const general_1 = require("../general");
|
|
10
|
+
const schema_1 = require("../schema");
|
|
11
|
+
/**
|
|
12
|
+
* Determines the verification status of a profile object, and its individual fields.
|
|
13
|
+
*/
|
|
14
|
+
function getPOVerification({ PO, schema, realVers, }) {
|
|
15
|
+
var _a, _b, _c;
|
|
16
|
+
// safe guard to avoid a misleading response from this function
|
|
17
|
+
const schemaName = PO.schema || (0, schema_1.findSchemaLabel)(PO.labels);
|
|
18
|
+
if (schema.name !== schemaName) {
|
|
19
|
+
throw new Error(`Wrong schema supplied to getPOVerification: ${schema.name} != ${schemaName}`);
|
|
20
|
+
}
|
|
21
|
+
if (!PO.n_id) {
|
|
22
|
+
// TODO: (semver breaking) immediately return NotVerified here
|
|
23
|
+
// eslint-disable-next-line no-console
|
|
24
|
+
console.warn("No n_id supplied to getPOVerification. You may be seeing incorrect and misleading verifications");
|
|
25
|
+
}
|
|
26
|
+
const someAreEncrypted = !!(0, crypto_1.someEncrypted)(PO.properties);
|
|
27
|
+
if (someAreEncrypted) {
|
|
28
|
+
return {
|
|
29
|
+
status: types_1.POVerification.Encrypted,
|
|
30
|
+
details: { sourceNId: PO.n_id, verifiers: [] },
|
|
31
|
+
fieldVerifications: {},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
// if a subObject is supplied, properties might not be an object.
|
|
35
|
+
// In which case this PO is definitely not verified
|
|
36
|
+
const shouldBeVerifiedProps = PO.properties instanceof Object
|
|
37
|
+
? (0, ramda_1.pick)(
|
|
38
|
+
// 📛 part1: this is the straightforward case, we pick the fields that are always verifiable
|
|
39
|
+
((_a = schema.verified_fields) === null || _a === void 0 ? void 0 : _a.filter((x) => typeof x === "string")) || [], PO.properties)
|
|
40
|
+
: {};
|
|
41
|
+
// 📛 part2: some fields may be conditionally verifiable. if so, and the condition is true, add them to shouldBeVerifiedProps
|
|
42
|
+
((_b = schema.verified_fields) !== null && _b !== void 0 ? _b : [])
|
|
43
|
+
.filter((x) => typeof x !== "string" && (0, general_1.isConditionMet)(x.if, PO.properties))
|
|
44
|
+
.forEach(x => {
|
|
45
|
+
// eslint-disable-next-line fp/no-mutation
|
|
46
|
+
shouldBeVerifiedProps[x.field] = PO.properties[x.field];
|
|
47
|
+
});
|
|
48
|
+
const fieldVerifications = (0, ramda_1.mapObjIndexed)((content, fieldName) => {
|
|
49
|
+
const pertainingVers = realVers.filter(x => x.fieldName === fieldName &&
|
|
50
|
+
// using ramda's `equals` because this needs to work for objects/arrays
|
|
51
|
+
(0, ramda_1.equals)((0, maybeRereference_1.maybeRereference)(x.value), (0, maybeRereference_1.maybeRereference)(content)) &&
|
|
52
|
+
// if an nId is supplied, also filter out verifications that don't relate to that n_id
|
|
53
|
+
(PO.n_id ? x.belongsToNId === PO.n_id : true));
|
|
54
|
+
// .every() illogically returns true for arrays with zero length
|
|
55
|
+
if (pertainingVers.length && pertainingVers.every(x => x.expired)) {
|
|
56
|
+
return types_1.FieldVerification.Expired;
|
|
57
|
+
}
|
|
58
|
+
if (pertainingVers.some(x => !x.verified)) {
|
|
59
|
+
return types_1.FieldVerification.VerifiedFalse;
|
|
60
|
+
}
|
|
61
|
+
return pertainingVers.length
|
|
62
|
+
? types_1.FieldVerification.Verified
|
|
63
|
+
: types_1.FieldVerification.NotVerified;
|
|
64
|
+
}, shouldBeVerifiedProps);
|
|
65
|
+
const status = (() => {
|
|
66
|
+
if (!Object.values(shouldBeVerifiedProps).length) {
|
|
67
|
+
return types_1.POVerification.NotVerified;
|
|
68
|
+
}
|
|
69
|
+
const anyExpired = Object.values(fieldVerifications).some(x => x === types_1.FieldVerification.Expired);
|
|
70
|
+
if (anyExpired)
|
|
71
|
+
return types_1.POVerification.Expired;
|
|
72
|
+
const anyVerfiedFalse = Object.values(fieldVerifications).some(x => x === types_1.FieldVerification.VerifiedFalse);
|
|
73
|
+
if (anyVerfiedFalse)
|
|
74
|
+
return types_1.POVerification.VerifiedFalse;
|
|
75
|
+
const allVerified = Object.values(fieldVerifications).every(x => x === types_1.FieldVerification.Verified);
|
|
76
|
+
if (allVerified)
|
|
77
|
+
return types_1.POVerification.FullyVerified;
|
|
78
|
+
const anyVerified = Object.values(fieldVerifications).some(x => x === types_1.FieldVerification.Verified);
|
|
79
|
+
if (anyVerified)
|
|
80
|
+
return types_1.POVerification.PartiallyVerified;
|
|
81
|
+
const noneVerified = Object.values(fieldVerifications).every(x => x === types_1.FieldVerification.NotVerified);
|
|
82
|
+
if (noneVerified)
|
|
83
|
+
return types_1.POVerification.NotVerified;
|
|
84
|
+
// can't happen, but just in case the logic above fails
|
|
85
|
+
/* istanbul ignore next */
|
|
86
|
+
return types_1.POVerification.NotVerified;
|
|
87
|
+
})();
|
|
88
|
+
const verifiers = (0, getVerifiedBy_1.getVerifiedBy)({
|
|
89
|
+
nId: PO.n_id,
|
|
90
|
+
realVers,
|
|
91
|
+
shouldBeVerifiedProps,
|
|
92
|
+
});
|
|
93
|
+
// find the earliest expiry date if there is one
|
|
94
|
+
const maybeExpiryDate = ((_c = (0, ramda_1.sortBy)(ver => +ver.expired, realVers.filter(ver => ver.belongsToNId === PO.n_id && ver.expired))[0]) === null || _c === void 0 ? void 0 : _c.expired) || undefined;
|
|
95
|
+
return {
|
|
96
|
+
status,
|
|
97
|
+
details: {
|
|
98
|
+
sourceNId: PO.n_id,
|
|
99
|
+
verifiers,
|
|
100
|
+
expiryDate: status === types_1.POVerification.Expired ? maybeExpiryDate : undefined,
|
|
101
|
+
},
|
|
102
|
+
fieldVerifications,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
exports.getPOVerification = getPOVerification;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getVerifiedBy = void 0;
|
|
4
|
-
const ramda_1 = require("ramda");
|
|
5
|
-
const maybeRereference_1 = require("./maybeRereference");
|
|
6
|
-
// we should probably document this
|
|
7
|
-
/** @internal */
|
|
8
|
-
const getVerifiedBy = ({ nId, realVers, shouldBeVerifiedProps, }) => {
|
|
9
|
-
const mayBeVerifiedFields = Object.keys(shouldBeVerifiedProps);
|
|
10
|
-
const pertainingVers = realVers
|
|
11
|
-
.filter(x => mayBeVerifiedFields.includes(x.fieldName) &&
|
|
12
|
-
// using ramda's `equals` because this needs to work for objects/arrays
|
|
13
|
-
(0, ramda_1.equals)((0, maybeRereference_1.maybeRereference)(shouldBeVerifiedProps[x.fieldName]), (0, maybeRereference_1.maybeRereference)(x.value)) &&
|
|
14
|
-
// if an nId is supplied, also filter out verifications that don't relate to that n_id
|
|
15
|
-
(nId ? x.belongsToNId === nId : true))
|
|
16
|
-
.map(x => x.provider);
|
|
17
|
-
return (0, ramda_1.uniqBy)(x => x.dataSourceNId, pertainingVers);
|
|
18
|
-
};
|
|
19
|
-
exports.getVerifiedBy = getVerifiedBy;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getVerifiedBy = void 0;
|
|
4
|
+
const ramda_1 = require("ramda");
|
|
5
|
+
const maybeRereference_1 = require("./maybeRereference");
|
|
6
|
+
// we should probably document this
|
|
7
|
+
/** @internal */
|
|
8
|
+
const getVerifiedBy = ({ nId, realVers, shouldBeVerifiedProps, }) => {
|
|
9
|
+
const mayBeVerifiedFields = Object.keys(shouldBeVerifiedProps);
|
|
10
|
+
const pertainingVers = realVers
|
|
11
|
+
.filter(x => mayBeVerifiedFields.includes(x.fieldName) &&
|
|
12
|
+
// using ramda's `equals` because this needs to work for objects/arrays
|
|
13
|
+
(0, ramda_1.equals)((0, maybeRereference_1.maybeRereference)(shouldBeVerifiedProps[x.fieldName]), (0, maybeRereference_1.maybeRereference)(x.value)) &&
|
|
14
|
+
// if an nId is supplied, also filter out verifications that don't relate to that n_id
|
|
15
|
+
(nId ? x.belongsToNId === nId : true))
|
|
16
|
+
.map(x => x.provider);
|
|
17
|
+
return (0, ramda_1.uniqBy)(x => x.dataSourceNId, pertainingVers);
|
|
18
|
+
};
|
|
19
|
+
exports.getVerifiedBy = getVerifiedBy;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from "./cleanInstance";
|
|
2
|
-
export * from "./getPOVerification";
|
|
3
|
-
export * from "./verifyCheck";
|
|
4
|
-
export * from "./getVerifiedBy";
|
|
5
|
-
export * from "./safeHarbour";
|
|
1
|
+
export * from "./cleanInstance";
|
|
2
|
+
export * from "./getPOVerification";
|
|
3
|
+
export * from "./verifyCheck";
|
|
4
|
+
export * from "./getVerifiedBy";
|
|
5
|
+
export * from "./safeHarbour";
|