@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.
Files changed (172) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +100 -59
  3. package/dist/{util/hash.d.ts → __tests__/docs.test.d.ts} +1 -1
  4. package/dist/__tests__/docs.test.js +24 -0
  5. package/dist/accessApplication/createAA.d.ts +17 -17
  6. package/dist/accessApplication/createAA.js +71 -71
  7. package/dist/accessApplication/index.d.ts +1 -1
  8. package/dist/accessApplication/index.js +17 -17
  9. package/dist/crypto/cognitoAttributes.d.ts +15 -15
  10. package/dist/crypto/cognitoAttributes.js +33 -33
  11. package/dist/crypto/decryptKeys.d.ts +1 -1
  12. package/dist/crypto/decryptKeys.js +33 -33
  13. package/dist/crypto/decryptSharedData.d.ts +26 -26
  14. package/dist/crypto/decryptSharedData.js +38 -38
  15. package/dist/crypto/getAADecryptor.d.ts +16 -16
  16. package/dist/crypto/getAADecryptor.js +20 -20
  17. package/dist/crypto/helpers.d.ts +18 -18
  18. package/dist/crypto/helpers.js +26 -26
  19. package/dist/crypto/index.d.ts +4 -4
  20. package/dist/crypto/index.js +21 -21
  21. package/dist/general/conditional.d.ts +17 -17
  22. package/dist/general/conditional.js +32 -32
  23. package/dist/general/date.d.ts +2 -2
  24. package/dist/general/date.js +18 -18
  25. package/dist/general/index.d.ts +4 -4
  26. package/dist/general/index.js +20 -20
  27. package/dist/general/password.d.ts +10 -10
  28. package/dist/general/password.js +31 -31
  29. package/dist/general/types.d.ts +6 -6
  30. package/dist/general/types.js +13 -13
  31. package/dist/index.d.ts +6 -6
  32. package/dist/index.js +22 -22
  33. package/dist/rules/calculateScore.d.ts +28 -23
  34. package/dist/rules/calculateScore.js +82 -76
  35. package/dist/rules/convertInstanceToRuleInput.d.ts +3 -3
  36. package/dist/rules/convertInstanceToRuleInput.js +138 -139
  37. package/dist/rules/evaluateScoreCondition.d.ts +2 -2
  38. package/dist/rules/evaluateScoreCondition.js +44 -45
  39. package/dist/{verifications/checkVerifications.d.ts → rules/helpers/__tests__/addInfiniteThresholdBoundaries.test.d.ts} +1 -1
  40. package/dist/rules/helpers/__tests__/addInfiniteThresholdBoundaries.test.js +27 -0
  41. package/dist/{verifications/checkVerificationsNew.d.ts → rules/helpers/__tests__/checkTypeofValue.test.d.ts} +1 -1
  42. package/dist/rules/helpers/__tests__/checkTypeofValue.test.js +49 -0
  43. package/dist/{verifications/verifyCheck/util/canonicalJsonify.d.ts → rules/helpers/__tests__/getValuesFromPath.test.d.ts} +1 -1
  44. package/dist/rules/helpers/__tests__/getValuesFromPath.test.js +67 -0
  45. package/dist/rules/helpers/__tests__/thresholds.test.d.ts +1 -0
  46. package/dist/rules/helpers/__tests__/thresholds.test.js +32 -0
  47. package/dist/rules/helpers/addInfiniteThresholdBoundaries.d.ts +8 -8
  48. package/dist/rules/helpers/addInfiniteThresholdBoundaries.js +11 -11
  49. package/dist/rules/helpers/checkTypeofValue.d.ts +9 -9
  50. package/dist/rules/helpers/checkTypeofValue.js +60 -55
  51. package/dist/rules/helpers/getValuesFromPath.d.ts +3 -3
  52. package/dist/rules/helpers/getValuesFromPath.js +50 -50
  53. package/dist/rules/helpers/index.d.ts +5 -5
  54. package/dist/rules/helpers/index.js +21 -21
  55. package/dist/rules/helpers/symbols.d.ts +2 -2
  56. package/dist/rules/helpers/symbols.js +5 -5
  57. package/dist/rules/helpers/thresholds.d.ts +5 -5
  58. package/dist/rules/helpers/thresholds.js +46 -47
  59. package/dist/rules/index.d.ts +7 -7
  60. package/dist/rules/index.js +25 -25
  61. package/dist/rules/operators/__tests__/bool.test.d.ts +1 -0
  62. package/dist/rules/operators/__tests__/bool.test.js +21 -0
  63. package/dist/rules/operators/__tests__/date.test.d.ts +1 -0
  64. package/dist/rules/operators/__tests__/date.test.js +81 -0
  65. package/dist/rules/operators/__tests__/hfield.test.d.ts +1 -0
  66. package/dist/rules/operators/__tests__/hfield.test.js +38 -0
  67. package/dist/rules/operators/__tests__/hschema.test.d.ts +1 -0
  68. package/dist/rules/operators/__tests__/hschema.test.js +24 -0
  69. package/dist/rules/operators/__tests__/number.test.d.ts +1 -0
  70. package/dist/rules/operators/__tests__/number.test.js +53 -0
  71. package/dist/rules/operators/__tests__/string.test.d.ts +1 -0
  72. package/dist/rules/operators/__tests__/string.test.js +74 -0
  73. package/dist/rules/operators/bool.d.ts +2 -2
  74. package/dist/rules/operators/bool.js +17 -17
  75. package/dist/rules/operators/date.d.ts +2 -2
  76. package/dist/rules/operators/date.js +91 -91
  77. package/dist/rules/operators/hfield.d.ts +2 -2
  78. package/dist/rules/operators/hfield.js +33 -33
  79. package/dist/rules/operators/hschema.d.ts +2 -2
  80. package/dist/rules/operators/hschema.js +21 -21
  81. package/dist/rules/operators/index.d.ts +3 -3
  82. package/dist/rules/operators/index.js +11 -11
  83. package/dist/rules/operators/number.d.ts +2 -2
  84. package/dist/rules/operators/number.js +41 -41
  85. package/dist/rules/operators/string.d.ts +2 -2
  86. package/dist/rules/operators/string.js +58 -58
  87. package/dist/rules/types/config.d.ts +95 -91
  88. package/dist/rules/types/config.js +2 -2
  89. package/dist/rules/types/dataValueTypes.d.ts +19 -19
  90. package/dist/rules/types/dataValueTypes.js +4 -4
  91. package/dist/rules/types/index.d.ts +3 -3
  92. package/dist/rules/types/index.js +19 -19
  93. package/dist/rules/types/internal.d.ts +20 -20
  94. package/dist/rules/types/internal.js +2 -2
  95. package/dist/rules/validate.d.ts +6 -6
  96. package/dist/rules/validate.js +14 -14
  97. package/dist/rules/version.d.ts +1 -1
  98. package/dist/rules/version.js +5 -5
  99. package/dist/schema/index.d.ts +1 -1
  100. package/dist/schema/index.js +17 -17
  101. package/dist/schema/labels.d.ts +2 -2
  102. package/dist/schema/labels.js +20 -20
  103. package/dist/util/canonicalJsonify.d.ts +1 -1
  104. package/dist/util/canonicalJsonify.js +50 -50
  105. package/dist/util/handleResponse.d.ts +1 -1
  106. package/dist/util/handleResponse.js +21 -21
  107. package/dist/util/index.d.ts +2 -2
  108. package/dist/util/index.js +18 -18
  109. package/dist/verifications/cleanInstance.d.ts +9 -9
  110. package/dist/verifications/cleanInstance.js +15 -15
  111. package/dist/verifications/getPOVerification.d.ts +19 -16
  112. package/dist/verifications/getPOVerification.js +105 -94
  113. package/dist/verifications/getVerifiedBy.d.ts +1 -1
  114. package/dist/verifications/getVerifiedBy.js +19 -19
  115. package/dist/verifications/index.d.ts +5 -5
  116. package/dist/verifications/index.js +21 -21
  117. package/dist/verifications/maybeRereference.d.ts +1 -1
  118. package/dist/verifications/maybeRereference.js +10 -10
  119. package/dist/verifications/safeHarbour.d.ts +20 -20
  120. package/dist/verifications/safeHarbour.js +74 -74
  121. package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.d.ts +1 -0
  122. package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.js +152 -0
  123. package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.d.ts +1 -0
  124. package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.js +205 -0
  125. package/dist/verifications/verifyCheck/getOwnRealVerifications.d.ts +13 -13
  126. package/dist/verifications/verifyCheck/getOwnRealVerifications.js +66 -64
  127. package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.d.ts +19 -19
  128. package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.js +72 -72
  129. package/dist/verifications/verifyCheck/index.d.ts +3 -3
  130. package/dist/verifications/verifyCheck/index.js +21 -21
  131. package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.d.ts +1 -0
  132. package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.js +91 -0
  133. package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.d.ts +1 -0
  134. package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.js +49 -0
  135. package/dist/verifications/verifyCheck/operations/__tests__/sampleBundle.json +43 -0
  136. package/dist/verifications/verifyCheck/operations/checkOwnVerification.d.ts +15 -15
  137. package/dist/verifications/verifyCheck/operations/checkOwnVerification.js +39 -39
  138. package/dist/verifications/verifyCheck/operations/checkSomeoneElsesVerifications.d.ts +1 -1
  139. package/dist/verifications/verifyCheck/operations/checkSomeoneElsesVerifications.js +16 -16
  140. package/dist/verifications/verifyCheck/operations/index.d.ts +2 -2
  141. package/dist/verifications/verifyCheck/operations/index.js +18 -18
  142. package/package.json +13 -10
  143. package/dist/rules/helpers/getLhsTypeofValue.d.ts +0 -0
  144. package/dist/rules/helpers/getLhsTypeofValue.js +0 -1
  145. package/dist/rules/helpers/getValueFromPath.d.ts +0 -2
  146. package/dist/rules/helpers/getValueFromPath.js +0 -35
  147. package/dist/rules/helpers/rebuildInfiniteValues.d.ts +0 -3
  148. package/dist/rules/helpers/rebuildInfiniteValues.js +0 -6
  149. package/dist/rules/isScoreResultValid.d.ts +0 -2
  150. package/dist/rules/isScoreResultValid.js +0 -9
  151. package/dist/rules/operators/array.d.ts +0 -2
  152. package/dist/rules/operators/array.js +0 -74
  153. package/dist/rules/types/operators.d.ts +0 -19
  154. package/dist/rules/types/operators.js +0 -2
  155. package/dist/rules/types/score.d.ts +0 -50
  156. package/dist/rules/types/score.js +0 -2
  157. package/dist/util/conditional.d.ts +0 -7
  158. package/dist/util/conditional.js +0 -15
  159. package/dist/util/hash.js +0 -11
  160. package/dist/verifications/checkSingleVerification.d.ts +0 -9
  161. package/dist/verifications/checkSingleVerification.js +0 -29
  162. package/dist/verifications/checkVerifications.js +0 -16
  163. package/dist/verifications/checkVerificationsNew.js +0 -16
  164. package/dist/verifications/getOwnRealVerifications.d.ts +0 -14
  165. package/dist/verifications/getOwnRealVerifications.js +0 -64
  166. package/dist/verifications/getRealVerifications.d.ts +0 -22
  167. package/dist/verifications/getRealVerifications.js +0 -71
  168. package/dist/verifications/verifyCheck/util/canonicalJsonify.js +0 -48
  169. package/dist/verifications/verifyCheck/util/getValuesForAField.d.ts +0 -2
  170. package/dist/verifications/verifyCheck/util/getValuesForAField.js +0 -9
  171. package/dist/verifications/verifyCheck/util/index.d.ts +0 -2
  172. package/dist/verifications/verifyCheck/util/index.js +0 -14
@@ -1,22 +0,0 @@
1
- import { ProfileObject, Verification, RealVer } from "@raytio/types";
2
- declare type Props = {
3
- apiUrl: string;
4
- verifications: Verification[];
5
- profileObjects: ProfileObject[];
6
- controller?: AbortController;
7
- /**
8
- * do NOT use this option. If the value of a field
9
- * equals the value of this prop, that field will be treated
10
- * as verified, even if the API says it's not verified. See
11
- * #614 for context. @deprecated
12
- */
13
- UNSAFE_treatNoValueAsVerified?: string;
14
- };
15
- /**
16
- * Given a list of verifications and decrypted profile objects, this function calls
17
- * the Raytio API to verify the credibility of these verifications, returning only valid
18
- * verifications.
19
- * @returns a list of fileNames/values that are verified.
20
- */
21
- export declare const getRealVerifications: ({ apiUrl, verifications, profileObjects, controller, UNSAFE_treatNoValueAsVerified, }: Props) => Promise<RealVer[]>;
22
- export {};
@@ -1,71 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRealVerifications = void 0;
4
- const ramda_1 = require("ramda");
5
- const crypto_1 = require("../crypto");
6
- const checkVerifications_1 = require("./checkVerifications");
7
- const maybeRereference_1 = require("./maybeRereference");
8
- const getValuesForAField = (fieldName, POs) => (0, ramda_1.uniq)(
9
- // truthy only, and ignore encrypted properties. this function will be called again once they're decrypted
10
- POs.map(x => { var _a; return (_a = x.properties) === null || _a === void 0 ? void 0 : _a[fieldName]; }).filter(x => !!x && !(0, crypto_1.isEncrypted)(x)));
11
- /**
12
- * Given a list of verifications and decrypted profile objects, this function calls
13
- * the Raytio API to verify the credibility of these verifications, returning only valid
14
- * verifications.
15
- * @returns a list of fileNames/values that are verified.
16
- */
17
- const getRealVerifications = async ({ apiUrl, verifications, profileObjects, controller, UNSAFE_treatNoValueAsVerified, }) => {
18
- // for each verification (including passed: false), create a list of every possible that
19
- // value that that verification might have been for. Flatten the list
20
- // and send the whole thing to the API.
21
- const toVerify = verifications.flatMap(ver => {
22
- const values = getValuesForAField(ver.properties.field, profileObjects);
23
- return values.flatMap(value => ver.properties.verifications.map(({ signature }) => ({
24
- verifications: [
25
- Object.assign({ signature }, (ver.n_id.startsWith("HASHED::")
26
- ? {
27
- hashed_n_id: ver.n_id.split("::")[1],
28
- a_id: ver.n_id.split("::")[2],
29
- }
30
- : { n_id: ver.n_id })),
31
- ],
32
- data_to_verify: [{ value: (0, maybeRereference_1.maybeRereference)(value) }],
33
- })));
34
- });
35
- // the API can't cope with an empty array
36
- if (!toVerify.length)
37
- return [];
38
- const apiResponse = await (0, checkVerifications_1.checkVerifications)({
39
- apiUrl,
40
- toVerify,
41
- controller,
42
- });
43
- // do NOT expose the `verified` prop from the /verify_check API to avoid semantic confusion,
44
- // since verified: true does not mean that the verification is verified!
45
- const realVers = apiResponse
46
- .filter(x => x.verified ||
47
- // if UNSAFE_treatNoValueAsVerified is enabled, and we don't know the value of this field,
48
- // treat is as verified if the `passed` property is true (this is NOT a safe check).
49
- (!!UNSAFE_treatNoValueAsVerified &&
50
- x.data.value === UNSAFE_treatNoValueAsVerified &&
51
- x.data.passed))
52
- .map(({ signature, data, n_id: nID, valid_until }) => ({
53
- fieldName: data.field,
54
- value: data.value,
55
- provider: {
56
- dataSourceNId: data.verifier_source_id,
57
- serviceProviderNId: data.verifier_service_id,
58
- verifierNId: data.verifier_id,
59
- date: new Date(`${data.verification_date}Z`), // the api returns invalid dates (missing the `Z`)
60
- },
61
- expired: valid_until ? new Date(valid_until) : false,
62
- metadata: data.metadata,
63
- xId: data.request_div,
64
- signature,
65
- verified: data.passed,
66
- nID,
67
- belongsToNId: data.source_n_id,
68
- }));
69
- return realVers;
70
- };
71
- exports.getRealVerifications = getRealVerifications;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- /* eslint-disable fp/no-mutating-methods, fp/no-mutation, fp/no-let, 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]";
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
- // float ->
32
- const exponent = Math.round(Math.log10(Math.abs(object)));
33
- let mantissa = `${object / 10 ** exponent}`;
34
- if (!mantissa.includes("."))
35
- mantissa += ".0";
36
- return `${mantissa}E${exponent}`;
37
- }
38
- if (typeof object === "string")
39
- return `"${object.replace(REGEX, replacer)}"`;
40
- return object; // bool or int
41
- }
42
- /**
43
- * @internal
44
- * spec compliant, and matches
45
- * https://gitlab.com/raytio/mono/-/blob/devo/common/signing/signing/canonical_json.py
46
- */
47
- const canonicalJsonify = (object) => `${copyObjectWithSortedKeys(object)}`;
48
- exports.canonicalJsonify = canonicalJsonify;
@@ -1,2 +0,0 @@
1
- import { ProfileObject } from "@raytio/types";
2
- export declare const getValuesForAField: (fieldName: string, POs: ProfileObject[]) => unknown[];
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getValuesForAField = void 0;
4
- const ramda_1 = require("ramda");
5
- const crypto_1 = require("../../../crypto");
6
- const getValuesForAField = (fieldName, POs) => (0, ramda_1.uniq)(
7
- // truthy only, and ignore encrypted properties. this function will be called again once they're decrypted
8
- POs.map(x => { var _a; return (_a = x.properties) === null || _a === void 0 ? void 0 : _a[fieldName]; }).filter(x => !!x && !(0, crypto_1.isEncrypted)(x)));
9
- exports.getValuesForAField = getValuesForAField;
@@ -1,2 +0,0 @@
1
- export * from "./canonicalJsonify";
2
- export * from "./getValuesForAField";
@@ -1,14 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./canonicalJsonify"), exports);
14
- __exportStar(require("./getValuesForAField"), exports);