@raytio/core 11.2.0 → 11.3.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 (86) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +119 -30
  3. package/dist/accessApplication/api/__tests__/fetchKeysForSubmission.test.d.ts +1 -0
  4. package/dist/accessApplication/api/__tests__/fetchKeysForSubmission.test.js +28 -0
  5. package/dist/accessApplication/api/__tests__/fetchPOsOrAOsForSubmission.test.d.ts +1 -0
  6. package/dist/accessApplication/api/__tests__/fetchPOsOrAOsForSubmission.test.js +23 -0
  7. package/dist/accessApplication/api/__tests__/fetchRelationshipsForSubmission.test.d.ts +1 -0
  8. package/dist/accessApplication/api/__tests__/fetchRelationshipsForSubmission.test.js +27 -0
  9. package/dist/accessApplication/api/__tests__/getMissingDataForInstance.test.d.ts +1 -0
  10. package/dist/accessApplication/api/__tests__/getMissingDataForInstance.test.js +30 -0
  11. package/dist/accessApplication/api/fetchKeysForSubmission.d.ts +12 -0
  12. package/dist/accessApplication/api/fetchKeysForSubmission.js +16 -0
  13. package/dist/accessApplication/api/fetchPOsOrAOsForSubmission.d.ts +6 -0
  14. package/dist/accessApplication/api/fetchPOsOrAOsForSubmission.js +25 -0
  15. package/dist/accessApplication/api/fetchRelationshipsForSubmission.d.ts +6 -0
  16. package/dist/accessApplication/api/fetchRelationshipsForSubmission.js +10 -0
  17. package/dist/accessApplication/api/getMissingDataForInstance.d.ts +10 -0
  18. package/dist/accessApplication/api/getMissingDataForInstance.js +28 -0
  19. package/dist/accessApplication/api/index.d.ts +2 -0
  20. package/dist/accessApplication/api/index.js +18 -0
  21. package/dist/accessApplication/api/legacy/__tests__/convertRelationships.test.d.ts +1 -0
  22. package/dist/accessApplication/api/legacy/__tests__/convertRelationships.test.js +37 -0
  23. package/dist/accessApplication/api/legacy/convertRelationships.d.ts +16 -0
  24. package/dist/accessApplication/api/legacy/convertRelationships.js +21 -0
  25. package/dist/accessApplication/api/legacy/index.d.ts +1 -0
  26. package/dist/accessApplication/api/legacy/index.js +17 -0
  27. package/dist/accessApplication/createAA.js +6 -5
  28. package/dist/accessApplication/index.d.ts +1 -0
  29. package/dist/accessApplication/index.js +1 -0
  30. package/dist/crypto/cognitoAttributes.d.ts +1 -1
  31. package/dist/crypto/decryptSharedData.d.ts +2 -2
  32. package/dist/crypto/decryptSharedData.js +2 -5
  33. package/dist/crypto/getAADecryptor.d.ts +18 -3
  34. package/dist/crypto/getAADecryptor.js +10 -10
  35. package/dist/crypto/helpers.d.ts +2 -2
  36. package/dist/general/types.d.ts +9 -0
  37. package/dist/general/types.js +10 -1
  38. package/dist/rules/calculateScore.d.ts +1 -1
  39. package/dist/rules/convertInstanceToRuleInput.d.ts +3 -3
  40. package/dist/rules/convertInstanceToRuleInput.js +5 -2
  41. package/dist/rules/evaluateScoreCondition.d.ts +1 -1
  42. package/dist/rules/helpers/__tests__/getValuesFromPath.test.js +1 -1
  43. package/dist/rules/helpers/addInfiniteThresholdBoundaries.d.ts +1 -1
  44. package/dist/rules/helpers/checkTypeofValue.d.ts +1 -1
  45. package/dist/rules/helpers/getValuesFromPath.d.ts +1 -1
  46. package/dist/rules/helpers/thresholds.d.ts +1 -1
  47. package/dist/rules/operators/bool.d.ts +1 -1
  48. package/dist/rules/operators/date.d.ts +1 -1
  49. package/dist/rules/operators/hfield.d.ts +1 -1
  50. package/dist/rules/operators/hschema.d.ts +1 -1
  51. package/dist/rules/operators/index.d.ts +1 -1
  52. package/dist/rules/operators/number.d.ts +1 -1
  53. package/dist/rules/operators/string.d.ts +1 -1
  54. package/dist/rules/types/config.d.ts +4 -3
  55. package/dist/rules/types/dataValueTypes.d.ts +2 -3
  56. package/dist/rules/types/internal.d.ts +4 -3
  57. package/dist/rules/validate.d.ts +2 -2
  58. package/dist/schema/expandSchema/__tests__/expandSchema.test.js +2 -2
  59. package/dist/schema/expandSchema/__tests__/i18n.test.js +1 -1
  60. package/dist/schema/expandSchema/__tests__/maybeUseI18n.test.js +2 -2
  61. package/dist/schema/expandSchema/__tests__/processSchema.test.js +2 -2
  62. package/dist/schema/expandSchema/addLoadingTimes.d.ts +1 -1
  63. package/dist/schema/expandSchema/constants.d.ts +1 -1
  64. package/dist/schema/expandSchema/expandSchema.d.ts +1 -1
  65. package/dist/schema/expandSchema/maybeUseI18n.d.ts +1 -1
  66. package/dist/schema/expandSchema/processSchema.d.ts +1 -1
  67. package/dist/schema/expandSchema/removePrivateFields.d.ts +5 -5
  68. package/dist/schema/expandSchema/sortSchemaProperties.d.ts +3 -3
  69. package/dist/schema/expandSchema/unwrapSchema.d.ts +2 -6
  70. package/dist/schema/labels.d.ts +2 -1
  71. package/dist/testHelpers.d.ts +2 -2
  72. package/dist/verifications/cleanInstance.d.ts +1 -1
  73. package/dist/verifications/getPOVerification.d.ts +1 -1
  74. package/dist/verifications/index.d.ts +0 -1
  75. package/dist/verifications/index.js +0 -1
  76. package/dist/verifications/safeHarbour.d.ts +2 -2
  77. package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.js +3 -3
  78. package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.js +2 -2
  79. package/dist/verifications/verifyCheck/getOwnRealVerifications.d.ts +1 -1
  80. package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.d.ts +1 -1
  81. package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.js +1 -1
  82. package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.js +1 -1
  83. package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.js +2 -2
  84. package/dist/verifications/verifyCheck/operations/checkOwnVerification.d.ts +1 -1
  85. package/dist/verifications/verifyCheck/operations/checkOwnVerification.js +2 -0
  86. package/package.json +6 -42
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./cleanInstance"), exports);
18
17
  __exportStar(require("./getPOVerification"), exports);
19
18
  __exportStar(require("./verifyCheck"), exports);
20
19
  __exportStar(require("./getVerifiedBy"), exports);
@@ -1,4 +1,4 @@
1
- import { ProfileObject, RealVer, SafeHarbourCode, Schema } from "@raytio/types";
1
+ import { type ProfileObject, type RealVer, type SafeHarbourCode, type Schema, type SchemaName } from "@raytio/types";
2
2
  /** an object listing the `xId`s for each SafeHarbourCode */
3
3
  export type SafeHarbourObj = Partial<Record<SafeHarbourCode, string[]>>;
4
4
  /** the response from {@link calcSafeHarbourScore} */
@@ -16,5 +16,5 @@ export declare const calcSafeHarbourScore: (data: {
16
16
  person: ProfileObject;
17
17
  profileObjects: ProfileObject[];
18
18
  realVers: RealVer[];
19
- getSchema(schemaName: string): Promise<Schema>;
19
+ getSchema(schemaName: SchemaName): Promise<Schema>;
20
20
  }) => Promise<SafeHarbourResult>;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const __1 = require("..");
4
4
  const operations_1 = require("../operations");
5
5
  const testHelpers_1 = require("../../../testHelpers");
6
- jest.mock("../operations");
6
+ vi.mock("../operations");
7
7
  /**
8
8
  * in this test case:
9
9
  * - there are valid verifications for fName=Max and fName=Erika, but we don't which
@@ -17,7 +17,7 @@ jest.mock("../operations");
17
17
  */
18
18
  describe("getOwnRealVerifications", () => {
19
19
  beforeAll(() => {
20
- jest.fn(() => 1).mockImplementation(() => 123);
20
+ vi.fn(() => 1).mockImplementation(() => 123);
21
21
  (0, testHelpers_1.m)(operations_1.checkOwnVerification).mockImplementation(async ({ signature, keyId }) => {
22
22
  if (signature === "signatureForLastNameMustermannFromN2")
23
23
  return false;
@@ -35,7 +35,7 @@ describe("getOwnRealVerifications", () => {
35
35
  {
36
36
  n_id: "nv1",
37
37
  properties: {
38
- valid_until: "2020-08-28T23:12:35.678Z",
38
+ valid_until: "2020-08-28T23:12:35.678Z", // this one has expired
39
39
  verifications: [
40
40
  {
41
41
  signature: "signatureForFirstNameMax",
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const getSomeoneElsesRealVerifications_1 = require("../getSomeoneElsesRealVerifications");
4
4
  const operations_1 = require("../operations");
5
- jest.mock("../operations");
5
+ vi.mock("../operations");
6
6
  const checkVerificationsResp = [
7
7
  {
8
8
  verified: false,
@@ -133,7 +133,7 @@ const verifications = [
133
133
  ];
134
134
  describe("getSomeoneElsesRealVerifications", () => {
135
135
  beforeEach(() => {
136
- jest.resetAllMocks();
136
+ vi.resetAllMocks();
137
137
  operations_1.checkSomeoneElsesVerifications.mockResolvedValue(checkVerificationsResp);
138
138
  });
139
139
  it("returns an empty array if provided nothing", async () => {
@@ -1,4 +1,4 @@
1
- import { ProfileObject, Verification, RealVer, UId } from "@raytio/types";
1
+ import type { ProfileObject, RealVer, UId, Verification } from "@raytio/types";
2
2
  /**
3
3
  * Given a list of verifications and decrypted profile objects, this function
4
4
  * locally verifies the credibility of the signatures in the verifications.
@@ -1,4 +1,4 @@
1
- import { ProfileObject, Verification, RealVer, AId } from "@raytio/types";
1
+ import type { AId, ProfileObject, RealVer, Verification } from "@raytio/types";
2
2
  type Props = {
3
3
  aId: AId;
4
4
  apiUrl: string;
@@ -64,7 +64,7 @@ const getSomeoneElsesRealVerifications = async ({ aId, apiUrl, verifications, pr
64
64
  verified: data.passed,
65
65
  nID,
66
66
  belongsToNId: data.source_hashed_n_id
67
- ? `HASHED::${data.source_hashed_n_id}::${aId}`
67
+ ? (0, general_1.createHashedNId)(data.source_hashed_n_id, aId)
68
68
  : data.source_n_id,
69
69
  }));
70
70
  return realVers;
@@ -7,7 +7,7 @@ const __1 = require("..");
7
7
  const util_1 = require("../../../../util");
8
8
  const checkOwnVerification_1 = require("../checkOwnVerification");
9
9
  const sampleBundle_json_1 = __importDefault(require("./sampleBundle.json"));
10
- global.fetch = jest.fn().mockImplementation(async (url) => ({
10
+ global.fetch = vi.fn().mockImplementation(async (url) => ({
11
11
  text: async () => url.endsWith("raytio.pem")
12
12
  ? `-----BEGIN PUBLIC KEY-----
13
13
  MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAn9QtCqYa3H3ipFFU0xP3
@@ -13,7 +13,7 @@ const toVerify = [
13
13
  ];
14
14
  describe("checkSomeoneElsesVerifications", () => {
15
15
  it("calls the API and filters out garbage", async () => {
16
- global.fetch = jest
16
+ global.fetch = vi
17
17
  .fn()
18
18
  .mockImplementation()
19
19
  // first fetch request
@@ -34,7 +34,7 @@ describe("checkSomeoneElsesVerifications", () => {
34
34
  expect(result).toStrictEqual([{ verified: true }, { verified: false }]);
35
35
  });
36
36
  it("throws an error if the API rejects", async () => {
37
- global.fetch = jest
37
+ global.fetch = vi
38
38
  .fn()
39
39
  .mockImplementation()
40
40
  // first fetch request
@@ -1,4 +1,4 @@
1
- import { UId, VerificationPayload } from "@raytio/types";
1
+ import type { UId, VerificationPayload } from "@raytio/types";
2
2
  type SingleVerToCheck = {
3
3
  verObject: VerificationPayload<false>;
4
4
  signature: string;
@@ -31,6 +31,8 @@ const checkJsonSignature = async (data, signature, keyId) => {
31
31
  if (!keyFileName || /[^\w-]/.test(keyFileName)) {
32
32
  throw new Error("Invalid key ID");
33
33
  }
34
+ // NOTE: We have to hard code the URL, we can't use an environment
35
+ // variable here, since this package is used outside of the monorepo.
34
36
  const keyUrl = `https://api-docs.rayt.io/lookups/${keyFileName}.pem`;
35
37
  const jwk = await getJwk(keyUrl);
36
38
  const stringified = (0, util_1.canonicalJsonify)(data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raytio/core",
3
- "version": "11.2.0",
3
+ "version": "11.3.0",
4
4
  "license": "MIT",
5
5
  "main": "index",
6
6
  "types": "index",
@@ -12,52 +12,16 @@
12
12
  ],
13
13
  "scripts": {
14
14
  "docs": "sh ../../scripts/generate-docs.sh",
15
- "build": "tsc && rimraf dist/jest.setup.* dist/**/__tests__",
16
- "test": "jest && yarn docs"
15
+ "build": "tsc && rimraf dist/**/__tests__",
16
+ "test": "vitest && yarn docs"
17
17
  },
18
18
  "dependencies": {
19
19
  "@raytio/maxcryptor": "3.1.0",
20
- "@raytio/types": "7.2.0",
21
- "ramda": "0.29.0"
20
+ "@raytio/types": "7.3.0",
21
+ "ramda": "0.29.1"
22
22
  },
23
23
  "devDependencies": {
24
- "@types/ramda": "0.29.2",
25
- "jest": "29.6.1",
26
- "ts-jest": "29.1.1"
27
- },
28
- "jest": {
29
- "transform": {
30
- "^.+\\.(t|j)sx?$": "ts-jest"
31
- },
32
- "testEnvironment": "node",
33
- "collectCoverage": false,
34
- "coverageThreshold": {
35
- "global": {
36
- "statements": 100
37
- }
38
- },
39
- "collectCoverageFrom": [
40
- "**/*.js",
41
- "**/*.ts",
42
- "**/*.tsx"
43
- ],
44
- "coveragePathIgnorePatterns": [
45
- "/dist/",
46
- "/coverage/"
47
- ],
48
- "modulePathIgnorePatterns": [
49
- "/dist/"
50
- ],
51
- "reporters": [
52
- "default",
53
- "jest-junit"
54
- ],
55
- "setupFilesAfterEnv": [
56
- "./src/jest.setup.ts"
57
- ]
58
- },
59
- "jest-junit": {
60
- "outputDirectory": "../../tmp"
24
+ "@types/ramda": "0.29.7"
61
25
  },
62
26
  "engineStrict": true,
63
27
  "engines": {