@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,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);
@@ -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;
@@ -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, beacuse 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
+ "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, 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]"; // 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;
@@ -1,2 +1,2 @@
1
- export * from "./canonicalJsonify";
2
- export * from "./handleResponse";
1
+ export * from "./canonicalJsonify";
2
+ export * from "./handleResponse";
@@ -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
- * Determines the verification status of a profile object, and its individual fields.
4
- */
5
- export declare function getPOVerification({ PO, schema, realVers, }: {
6
- PO: ProfileObject | ProfileObjectForUpload;
7
- schema: Schema;
8
- realVers: RealVer[];
9
- }): {
10
- status: POVerification;
11
- details: {
12
- sourceNId?: NId;
13
- verifiers: VerificationProvider[];
14
- };
15
- fieldVerifications: Record<string, FieldVerification>;
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
- const someAreEncrypted = !!(0, crypto_1.someEncrypted)(PO.properties);
22
- if (someAreEncrypted) {
23
- return {
24
- status: types_1.POVerification.Encrypted,
25
- details: { sourceNId: PO.n_id, verifiers: [] },
26
- fieldVerifications: {},
27
- };
28
- }
29
- // if a subObject is supplied, properties might not be an object.
30
- // In which case this PO is definitely not verified
31
- const shouldBeVerifiedProps = PO.properties instanceof Object
32
- ? (0, ramda_1.pick)(
33
- // 📛 part1: this is the straightforward case, we pick the fields that are always verifiable
34
- ((_a = schema.verified_fields) === null || _a === void 0 ? void 0 : _a.filter((x) => typeof x === "string")) || [], PO.properties)
35
- : {};
36
- // 📛 part2: some fields may be conditionally verifiable. if so, and the condition is true, add them to shouldBeVerifiedProps
37
- ((_b = schema.verified_fields) !== null && _b !== void 0 ? _b : [])
38
- .filter((x) => typeof x !== "string" && (0, general_1.isConditionMet)(x.if, PO.properties))
39
- .forEach(x => {
40
- // eslint-disable-next-line fp/no-mutation
41
- shouldBeVerifiedProps[x.field] = PO.properties[x.field];
42
- });
43
- const fieldVerifications = (0, ramda_1.mapObjIndexed)((content, fieldName) => {
44
- const pertainingVers = realVers.filter(x => x.fieldName === fieldName &&
45
- // using ramda's `equals` because this needs to work for objects/arrays
46
- (0, ramda_1.equals)((0, maybeRereference_1.maybeRereference)(x.value), (0, maybeRereference_1.maybeRereference)(content)) &&
47
- // if an nId is supplied, also filter out verifications that don't relate to that n_id
48
- (PO.n_id ? x.belongsToNId === PO.n_id : true));
49
- // .every() illogically returns true for arrays with zero length
50
- if (pertainingVers.length && pertainingVers.every(x => x.expired)) {
51
- return types_1.FieldVerification.Expired;
52
- }
53
- if (pertainingVers.some(x => !x.verified)) {
54
- return types_1.FieldVerification.VerifiedFalse;
55
- }
56
- return pertainingVers.length
57
- ? types_1.FieldVerification.Verified
58
- : types_1.FieldVerification.NotVerified;
59
- }, shouldBeVerifiedProps);
60
- const status = (() => {
61
- if (!Object.values(shouldBeVerifiedProps).length) {
62
- return types_1.POVerification.NotVerified;
63
- }
64
- const allExpired = Object.values(fieldVerifications).every(x => x === types_1.FieldVerification.Expired);
65
- if (allExpired)
66
- return types_1.POVerification.Expired;
67
- const anyVerfiedFalse = Object.values(fieldVerifications).some(x => x === types_1.FieldVerification.VerifiedFalse);
68
- if (anyVerfiedFalse)
69
- return types_1.POVerification.VerifiedFalse;
70
- const allVerified = Object.values(fieldVerifications).every(x => x === types_1.FieldVerification.Verified);
71
- if (allVerified)
72
- return types_1.POVerification.FullyVerified;
73
- const anyVerified = Object.values(fieldVerifications).some(x => x === types_1.FieldVerification.Verified);
74
- if (anyVerified)
75
- return types_1.POVerification.PartiallyVerified;
76
- const noneVerified = Object.values(fieldVerifications).every(x => x === types_1.FieldVerification.NotVerified);
77
- if (noneVerified)
78
- return types_1.POVerification.NotVerified;
79
- // can't happen, but just in case the logic above fails
80
- /* istanbul ignore next */
81
- return types_1.POVerification.NotVerified;
82
- })();
83
- const verifiers = (0, getVerifiedBy_1.getVerifiedBy)({
84
- nId: PO.n_id,
85
- realVers,
86
- shouldBeVerifiedProps,
87
- });
88
- return {
89
- status,
90
- details: { sourceNId: PO.n_id, verifiers },
91
- fieldVerifications,
92
- };
93
- }
94
- exports.getPOVerification = getPOVerification;
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";