@raytio/core 11.4.1 → 11.6.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 (137) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1714 -213
  3. package/dist/accessApplication/api/legacy/convertRelationships.d.ts +3 -5
  4. package/dist/accessApplication/api/legacy/convertRelationships.js +3 -3
  5. package/dist/crypto/cognitoAttributes.d.ts +3 -0
  6. package/dist/crypto/cognitoAttributes.js +15 -4
  7. package/dist/crypto/getAADecryptor.d.ts +1 -1
  8. package/dist/crypto/getAADecryptor.js +1 -3
  9. package/dist/crypto/index.d.ts +3 -0
  10. package/dist/crypto/index.js +6 -0
  11. package/dist/crypto/kdf/argon2.d.ts +67 -0
  12. package/dist/crypto/kdf/argon2.js +99 -0
  13. package/dist/crypto/kdf/index.d.ts +43 -0
  14. package/dist/crypto/kdf/index.js +106 -0
  15. package/dist/crypto/kdf/pbkdf2.d.ts +16 -0
  16. package/dist/crypto/kdf/pbkdf2.js +45 -0
  17. package/dist/crypto/kdf/twoSecretKdf.d.ts +37 -0
  18. package/dist/crypto/kdf/twoSecretKdf.js +66 -0
  19. package/dist/crypto/kdf/types.d.ts +65 -0
  20. package/dist/crypto/kdf/types.js +50 -0
  21. package/dist/crypto/kdf/utils.d.ts +59 -0
  22. package/dist/crypto/kdf/utils.js +110 -0
  23. package/dist/crypto/localSecret/format.d.ts +48 -0
  24. package/dist/crypto/localSecret/format.js +157 -0
  25. package/dist/crypto/localSecret/generator.d.ts +23 -0
  26. package/dist/crypto/localSecret/generator.js +53 -0
  27. package/dist/crypto/localSecret/index.d.ts +12 -0
  28. package/dist/crypto/localSecret/index.js +46 -0
  29. package/dist/crypto/localSecret/storage.d.ts +53 -0
  30. package/dist/crypto/localSecret/storage.js +207 -0
  31. package/dist/crypto/localSecret/types.d.ts +68 -0
  32. package/dist/crypto/localSecret/types.js +31 -0
  33. package/dist/crypto/pgpKey/encryption.d.ts +49 -0
  34. package/dist/crypto/pgpKey/encryption.js +104 -0
  35. package/dist/crypto/pgpKey/export.d.ts +59 -0
  36. package/dist/crypto/pgpKey/export.js +322 -0
  37. package/dist/crypto/pgpKey/format.d.ts +61 -0
  38. package/dist/crypto/pgpKey/format.js +143 -0
  39. package/dist/crypto/pgpKey/generator.d.ts +20 -0
  40. package/dist/crypto/pgpKey/generator.js +76 -0
  41. package/dist/crypto/pgpKey/import.d.ts +69 -0
  42. package/dist/crypto/pgpKey/import.js +239 -0
  43. package/dist/crypto/pgpKey/index.d.ts +19 -0
  44. package/dist/crypto/pgpKey/index.js +67 -0
  45. package/dist/crypto/pgpKey/signing.d.ts +44 -0
  46. package/dist/crypto/pgpKey/signing.js +71 -0
  47. package/dist/crypto/pgpKey/storage.d.ts +43 -0
  48. package/dist/crypto/pgpKey/storage.js +141 -0
  49. package/dist/crypto/pgpKey/types.d.ts +86 -0
  50. package/dist/crypto/pgpKey/types.js +25 -0
  51. package/dist/index.d.ts +1 -0
  52. package/dist/index.js +1 -0
  53. package/dist/rules/calculateScore.d.ts +1 -1
  54. package/dist/rules/convertInstanceToRuleInput.js +99 -97
  55. package/dist/rules/evaluateBadge.d.ts +36 -0
  56. package/dist/rules/evaluateBadge.js +36 -0
  57. package/dist/rules/index.d.ts +1 -0
  58. package/dist/rules/index.js +1 -0
  59. package/dist/rules/types/config.d.ts +1 -1
  60. package/dist/rules/types/dataValueTypes.d.ts +4 -4
  61. package/dist/schema/expandSchema/constants.js +1 -1
  62. package/dist/schema/expandSchema/expandSchema.d.ts +3 -3
  63. package/dist/schema/expandSchema/expandSchema.js +4 -4
  64. package/dist/schema/expandSchema/i18n.d.ts +6 -1
  65. package/dist/schema/expandSchema/i18n.js +32 -4
  66. package/dist/schema/expandSchema/index.d.ts +1 -0
  67. package/dist/schema/expandSchema/index.js +1 -0
  68. package/dist/schema/expandSchema/maybeUseI18n.d.ts +2 -2
  69. package/dist/schema/expandSchema/maybeUseI18n.js +68 -11
  70. package/dist/schema/expandSchema/processSchema.js +14 -5
  71. package/dist/schema/expandSchema/removePrivateFields.d.ts +75 -22
  72. package/dist/schema/expandSchema/sortSchemaProperties.d.ts +4 -1
  73. package/dist/schema/expandSchema/sortSchemaProperties.js +24 -1
  74. package/dist/schema/labels.js +1 -2
  75. package/dist/util/canonicalJsonify.d.ts +7 -1
  76. package/dist/util/canonicalJsonify.js +11 -10
  77. package/dist/verifications/safeHarbour.js +5 -0
  78. package/dist/verifications/verifyCheck/getOwnRealVerifications.js +3 -0
  79. package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.js +1 -0
  80. package/package.json +6 -4
  81. package/dist/__tests__/docs.test.d.ts +0 -1
  82. package/dist/__tests__/docs.test.js +0 -24
  83. package/dist/accessApplication/api/__tests__/fetchKeysForSubmission.test.d.ts +0 -1
  84. package/dist/accessApplication/api/__tests__/fetchKeysForSubmission.test.js +0 -28
  85. package/dist/accessApplication/api/__tests__/fetchPOsOrAOsForSubmission.test.d.ts +0 -1
  86. package/dist/accessApplication/api/__tests__/fetchPOsOrAOsForSubmission.test.js +0 -23
  87. package/dist/accessApplication/api/__tests__/fetchRelationshipsForSubmission.test.d.ts +0 -1
  88. package/dist/accessApplication/api/__tests__/fetchRelationshipsForSubmission.test.js +0 -27
  89. package/dist/accessApplication/api/__tests__/getMissingDataForInstance.test.d.ts +0 -1
  90. package/dist/accessApplication/api/__tests__/getMissingDataForInstance.test.js +0 -30
  91. package/dist/accessApplication/api/legacy/__tests__/convertRelationships.test.d.ts +0 -1
  92. package/dist/accessApplication/api/legacy/__tests__/convertRelationships.test.js +0 -37
  93. package/dist/rules/helpers/__tests__/addInfiniteThresholdBoundaries.test.d.ts +0 -1
  94. package/dist/rules/helpers/__tests__/addInfiniteThresholdBoundaries.test.js +0 -27
  95. package/dist/rules/helpers/__tests__/checkTypeofValue.test.d.ts +0 -1
  96. package/dist/rules/helpers/__tests__/checkTypeofValue.test.js +0 -49
  97. package/dist/rules/helpers/__tests__/getValuesFromPath.test.d.ts +0 -1
  98. package/dist/rules/helpers/__tests__/getValuesFromPath.test.js +0 -67
  99. package/dist/rules/helpers/__tests__/thresholds.test.d.ts +0 -1
  100. package/dist/rules/helpers/__tests__/thresholds.test.js +0 -32
  101. package/dist/rules/operators/__tests__/bool.test.d.ts +0 -1
  102. package/dist/rules/operators/__tests__/bool.test.js +0 -21
  103. package/dist/rules/operators/__tests__/date.test.d.ts +0 -1
  104. package/dist/rules/operators/__tests__/date.test.js +0 -81
  105. package/dist/rules/operators/__tests__/hfield.test.d.ts +0 -1
  106. package/dist/rules/operators/__tests__/hfield.test.js +0 -38
  107. package/dist/rules/operators/__tests__/hschema.test.d.ts +0 -1
  108. package/dist/rules/operators/__tests__/hschema.test.js +0 -24
  109. package/dist/rules/operators/__tests__/number.test.d.ts +0 -1
  110. package/dist/rules/operators/__tests__/number.test.js +0 -53
  111. package/dist/rules/operators/__tests__/string.test.d.ts +0 -1
  112. package/dist/rules/operators/__tests__/string.test.js +0 -74
  113. package/dist/schema/expandSchema/__tests__/addLoadingTimes.test.d.ts +0 -1
  114. package/dist/schema/expandSchema/__tests__/addLoadingTimes.test.js +0 -24
  115. package/dist/schema/expandSchema/__tests__/expandSchema.test.d.ts +0 -1
  116. package/dist/schema/expandSchema/__tests__/expandSchema.test.js +0 -96
  117. package/dist/schema/expandSchema/__tests__/i18n.test.d.ts +0 -1
  118. package/dist/schema/expandSchema/__tests__/i18n.test.js +0 -32
  119. package/dist/schema/expandSchema/__tests__/maybeUseI18n.test.d.ts +0 -1
  120. package/dist/schema/expandSchema/__tests__/maybeUseI18n.test.js +0 -98
  121. package/dist/schema/expandSchema/__tests__/processSchema.test.d.ts +0 -1
  122. package/dist/schema/expandSchema/__tests__/processSchema.test.js +0 -326
  123. package/dist/schema/expandSchema/__tests__/sortSchemaProperties.test.d.ts +0 -1
  124. package/dist/schema/expandSchema/__tests__/sortSchemaProperties.test.js +0 -182
  125. package/dist/schema/expandSchema/__tests__/util.test.d.ts +0 -1
  126. package/dist/schema/expandSchema/__tests__/util.test.js +0 -19
  127. package/dist/verifications/cleanInstance.d.ts +0 -9
  128. package/dist/verifications/cleanInstance.js +0 -15
  129. package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.d.ts +0 -1
  130. package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.js +0 -217
  131. package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.d.ts +0 -1
  132. package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.js +0 -205
  133. package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.d.ts +0 -1
  134. package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.js +0 -131
  135. package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.d.ts +0 -1
  136. package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.js +0 -49
  137. package/dist/verifications/verifyCheck/operations/__tests__/sampleBundle.json +0 -44
@@ -1,182 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const sortSchemaProperties_1 = require("../sortSchemaProperties");
4
- describe("sortSchemaProperties tests", () => {
5
- it("correctly sorts the fields by priority and groups", () => {
6
- const actual = (0, sortSchemaProperties_1.sortSchemaProperties)({
7
- first_name: {
8
- tags: ["group:name"],
9
- priority: 10,
10
- n_id: "first_name",
11
- $prop: "first_name",
12
- },
13
- last_name: {
14
- tags: ["group:name"],
15
- priority: 20,
16
- n_id: "last_name",
17
- $prop: "last_name",
18
- },
19
- gender: {
20
- tags: ["globally_unique_field", "group:gender"],
21
- priority: 5,
22
- n_id: "gender",
23
- $prop: "gender",
24
- },
25
- oof: { priority: 30, n_id: "abc123", $prop: "oof" },
26
- another_field_without_tags_and_no_nid: {
27
- priority: 50,
28
- $prop: "another_field_without_tags_and_no_nid",
29
- },
30
- another_field_without_tags: {
31
- priority: 40,
32
- n_id: "xyz789",
33
- $prop: "another_field_without_tags",
34
- },
35
- middle_name: {
36
- tags: ["group:name"],
37
- priority: 15,
38
- n_id: "middle_name",
39
- $prop: "middle_name",
40
- },
41
- });
42
- const expected = [
43
- {
44
- title: "gender",
45
- items: [
46
- {
47
- $prop: "gender",
48
- priority: 5,
49
- tags: ["globally_unique_field", "group:gender"],
50
- n_id: "gender",
51
- },
52
- ],
53
- },
54
- {
55
- title: "name",
56
- items: [
57
- {
58
- priority: 10,
59
- tags: ["group:name"],
60
- n_id: "first_name",
61
- $prop: "first_name",
62
- },
63
- {
64
- priority: 15,
65
- tags: ["group:name"],
66
- n_id: "middle_name",
67
- $prop: "middle_name",
68
- },
69
- {
70
- priority: 20,
71
- tags: ["group:name"],
72
- n_id: "last_name",
73
- $prop: "last_name",
74
- },
75
- ],
76
- },
77
- {
78
- title: "-notag-common",
79
- items: [
80
- { priority: 30, n_id: "abc123", $prop: "oof" },
81
- { priority: 40, n_id: "xyz789", $prop: "another_field_without_tags" },
82
- { priority: 50, $prop: "another_field_without_tags_and_no_nid" },
83
- ],
84
- },
85
- ];
86
- expect(actual).toStrictEqual(expected);
87
- });
88
- it("Deals with nested data", () => {
89
- const result = (0, sortSchemaProperties_1.sortSchemaProperties)({
90
- id: {
91
- priority: 100,
92
- tags: ["group:provider_product"],
93
- type: "string",
94
- description: "The unique id of the product",
95
- title: "Product ID",
96
- $prop: "id",
97
- },
98
- metadata: {
99
- $prop: "metadata",
100
- properties: {},
101
- items: {
102
- id: {
103
- priority: 100,
104
- tags: ["group:provider_product"],
105
- type: "string",
106
- description: "The unique id of the product",
107
- title: "Product ID",
108
- },
109
- },
110
- type: "object",
111
- title: "Product details",
112
- priority: 300,
113
- tags: ["group:provider_product"],
114
- description: "Additional information about the product",
115
- },
116
- });
117
- expect(result).toStrictEqual([
118
- {
119
- items: [
120
- {
121
- $prop: "id",
122
- description: "The unique id of the product",
123
- priority: 100,
124
- tags: ["group:provider_product"],
125
- title: "Product ID",
126
- type: "string",
127
- },
128
- {
129
- $prop: "metadata",
130
- description: "Additional information about the product",
131
- items: {
132
- id: {
133
- description: "The unique id of the product",
134
- priority: 100,
135
- tags: ["group:provider_product"],
136
- title: "Product ID",
137
- type: "string",
138
- },
139
- },
140
- priority: 300,
141
- properties: {},
142
- tags: ["group:provider_product"],
143
- title: "Product details",
144
- type: "object",
145
- },
146
- ],
147
- title: "provider_product",
148
- },
149
- ]);
150
- });
151
- it("makes use of sub groups within the same group", () => {
152
- const actual = (0, sortSchemaProperties_1.sortSchemaProperties)({
153
- date_of_birth: { $prop: "date_of_birth", tags: ["group:date:birth"] },
154
- month_of_birth: { $prop: "month_of_birth", tags: ["group:date:birth"] },
155
- year_of_birth: { $prop: "year_of_birth", tags: ["group:date:birth"] },
156
- date_of_expiry: { $prop: "date_of_expiry", tags: ["group:date:expiry"] },
157
- month_of_expiry: {
158
- $prop: "month_of_expiry",
159
- tags: ["group:date:expiry"],
160
- },
161
- year_of_expiry: { $prop: "year_of_expiry", tags: ["group:date:expiry"] },
162
- });
163
- expect(actual).toStrictEqual([
164
- {
165
- title: "date:birth",
166
- items: [
167
- { $prop: "date_of_birth", tags: ["group:date:birth"] },
168
- { $prop: "month_of_birth", tags: ["group:date:birth"] },
169
- { $prop: "year_of_birth", tags: ["group:date:birth"] },
170
- ],
171
- },
172
- {
173
- title: "date:expiry",
174
- items: [
175
- { $prop: "date_of_expiry", tags: ["group:date:expiry"] },
176
- { $prop: "month_of_expiry", tags: ["group:date:expiry"] },
177
- { $prop: "year_of_expiry", tags: ["group:date:expiry"] },
178
- ],
179
- },
180
- ]);
181
- });
182
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const util_1 = require("../util");
4
- describe("getConditionId", () => {
5
- it.each `
6
- iff | id
7
- ${{ country: ["NZ"] }} | ${"country=NZ"}
8
- ${{ country: ["NZ", "AU"] }} | ${"country=AU|NZ"}
9
- ${{ country: ["AU", "NZ"] }} | ${"country=AU|NZ"}
10
- ${{ country: ["NZ"], age: [17] }} | ${"age=17 & country=NZ"}
11
- ${{ country: ["NZ"], age: [17, 18] }} | ${"age=17|18 & country=NZ"}
12
- ${{ country: ["NZ", "AU"], age: [17, 18] }} | ${"age=17|18 & country=AU|NZ"}
13
- ${{}} | ${""}
14
- ${{ country: [] }} | ${"country="}
15
- ${{ country: [], age: [] }} | ${"age= & country="}
16
- `("generates IDs ($id)", ({ iff, id }) => {
17
- expect((0, util_1.getConditionId)(iff)).toBe(id);
18
- });
19
- });
@@ -1,9 +0,0 @@
1
- import type { 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 +0,0 @@
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,217 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const __1 = require("..");
4
- const operations_1 = require("../operations");
5
- const testHelpers_1 = require("../../../testHelpers");
6
- vi.mock("../operations");
7
- /**
8
- * in this test case:
9
- * - there are valid verifications for fName=Max and fName=Erika, but we don't which
10
- * verification corresponds to which value.
11
- * - there is an invalid verification (tampered with) for lName=Mustermann
12
- * - there are verifications for non-existant POs and fields, which will be skipped
13
- *
14
- * Also note:
15
- * - the verification for fName=Max is expired
16
- * - the verification for fName=Erika is "VerifiedFalse"
17
- */
18
- describe("getOwnRealVerifications", () => {
19
- beforeAll(() => {
20
- vi.fn(() => 1).mockImplementation(() => 123);
21
- (0, testHelpers_1.m)(operations_1.checkOwnVerification).mockImplementation(async ({ signature, keyId }) => {
22
- if (signature === "signatureForLastNameMustermannFromN2")
23
- return false;
24
- if (keyId === "thisOneIsInvalid")
25
- return false;
26
- return true;
27
- });
28
- });
29
- it("calls the verifyCheck function for each PO, keeping only the valid ones", async () => {
30
- const profileObjects = (0, testHelpers_1.deepPartial)([
31
- { n_id: "n1", properties: { fName: "Max", lName: "Mustermann" } },
32
- { n_id: "n2", properties: { fName: "Erika", lName: "Mustermann" } },
33
- ]);
34
- const verifications = (0, testHelpers_1.deepPartial)([
35
- {
36
- n_id: "nv1",
37
- properties: {
38
- valid_until: "2020-08-28T23:12:35.678Z", // this one has expired
39
- verifications: [
40
- {
41
- signature: "signatureForFirstNameMax",
42
- data: {
43
- field: "fName",
44
- verifier_source_id: "Ministry of pike river mine re-entry",
45
- verifier_service_id: "Minister for pike river re-entry",
46
- verifier_id: "v1",
47
- verification_date: "2020-08-28T23:11:20.592912",
48
- request_div: "x1",
49
- passed: true,
50
- source_n_id: "n1",
51
- },
52
- },
53
- ],
54
- },
55
- },
56
- {
57
- n_id: "nv2",
58
- properties: {
59
- verifications: [
60
- {
61
- signature: "signatureForFirstNameErika",
62
- data: {
63
- field: "fName",
64
- verifier_source_id: "Ministry of pike river mine re-entry",
65
- verifier_service_id: "Minister for pike river re-entry",
66
- verifier_id: "v1",
67
- verification_date: "2020-08-28T23:11:20.592912",
68
- request_div: "x2",
69
- passed: false,
70
- source_n_id: "n2",
71
- },
72
- // legacy: key_id is not specified
73
- },
74
- ],
75
- },
76
- },
77
- {
78
- n_id: "nv3",
79
- properties: {
80
- verifications: [
81
- {
82
- signature: "signatureForLastNameMustermannFromN2",
83
- data: {
84
- field: "lName",
85
- verifier_source_id: "Ministry of pike river mine re-entry",
86
- verifier_service_id: "Minister for pike river re-entry",
87
- verifier_id: "v1",
88
- verification_date: "2020-08-28T23:11:20.592912",
89
- request_div: "x3",
90
- passed: false,
91
- source_n_id: "n2", // this ver was for lName=Mustermann in n2, so doesn't apply to lName=Mustermann in n1 !
92
- },
93
- },
94
- ],
95
- },
96
- },
97
- {
98
- n_id: "nv4",
99
- properties: {
100
- verifications: [{ data: { source_n_id: "doesn't exist" } }],
101
- },
102
- },
103
- {
104
- n_id: "nv5",
105
- properties: {
106
- verifications: [
107
- { data: { source_n_id: "n2", field: "doesn't exist" } },
108
- ],
109
- },
110
- },
111
- {
112
- n_id: "nv6",
113
- properties: {
114
- verifications: [
115
- {
116
- signature: "signatureForFirstNameErika",
117
- data: {
118
- field: "fName",
119
- verifier_source_id: "Ministry of pike river mine re-entry",
120
- verifier_service_id: "Minister for pike river re-entry",
121
- verifier_id: "v1",
122
- verification_date: "2020-08-28T23:11:20.592912",
123
- request_div: "x2",
124
- passed: false,
125
- source_n_id: "n2",
126
- },
127
- key_id: "thisOneIsInvalid", // signature & data is good, but this key will fail
128
- },
129
- ],
130
- },
131
- },
132
- {
133
- n_id: "nv7",
134
- properties: {
135
- verifications: [
136
- {
137
- signature: "signatureForFirstNameErika",
138
- data: {
139
- field: "fName",
140
- verifier_source_id: "Ministry of pike river mine re-entry",
141
- verifier_service_id: "Minister for pike river re-entry",
142
- verifier_id: "v1",
143
- verification_date: "2020-08-28T23:11:20.592912",
144
- request_div: "x2",
145
- passed: false,
146
- source_n_id: "n2",
147
- },
148
- key_id: "raytio", // everything is valid, this is the right key_id
149
- },
150
- ],
151
- },
152
- },
153
- ]);
154
- const realVers = await (0, __1.getOwnRealVerifications)({
155
- profileObjects,
156
- verifications,
157
- userId: "geesepolice2002",
158
- });
159
- expect(operations_1.checkOwnVerification).toHaveBeenCalledTimes(5);
160
- // 5 times. Because this new method doesn't need to build a big matrix of possible combinations
161
- expect(realVers).toStrictEqual([
162
- {
163
- fieldName: "fName",
164
- value: "Max",
165
- belongsToNId: "n1",
166
- nID: "nv1",
167
- expired: new Date("2020-08-28T23:12:35.678Z"),
168
- metadata: undefined,
169
- provider: {
170
- dataSourceNId: "Ministry of pike river mine re-entry",
171
- date: new Date("2020-08-28T23:11:20.592Z"),
172
- serviceProviderNId: "Minister for pike river re-entry",
173
- verifierNId: "v1",
174
- },
175
- signature: "signatureForFirstNameMax",
176
- verified: true,
177
- xId: "x1",
178
- },
179
- {
180
- fieldName: "fName",
181
- value: "Erika",
182
- belongsToNId: "n2",
183
- nID: "nv2",
184
- expired: false,
185
- metadata: undefined,
186
- provider: {
187
- dataSourceNId: "Ministry of pike river mine re-entry",
188
- date: new Date("2020-08-28T23:11:20.592Z"),
189
- serviceProviderNId: "Minister for pike river re-entry",
190
- verifierNId: "v1",
191
- },
192
- signature: "signatureForFirstNameErika",
193
- verified: false,
194
- xId: "x2",
195
- },
196
- // note how lastName is not included since it's invalid
197
- // nv6 is not included because the key is invalid
198
- {
199
- fieldName: "fName",
200
- value: "Erika",
201
- belongsToNId: "n2",
202
- nID: "nv7",
203
- expired: false,
204
- metadata: undefined,
205
- provider: {
206
- dataSourceNId: "Ministry of pike river mine re-entry",
207
- date: new Date("2020-08-28T23:11:20.592Z"),
208
- serviceProviderNId: "Minister for pike river re-entry",
209
- verifierNId: "v1",
210
- },
211
- signature: "signatureForFirstNameErika",
212
- verified: false,
213
- xId: "x2",
214
- },
215
- ]);
216
- });
217
- });
@@ -1,205 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const getSomeoneElsesRealVerifications_1 = require("../getSomeoneElsesRealVerifications");
4
- const operations_1 = require("../operations");
5
- vi.mock("../operations");
6
- const checkVerificationsResp = [
7
- {
8
- verified: false,
9
- signature: "sig2",
10
- data: {
11
- field: "a",
12
- value: 1,
13
- verifier_source_id: "verifier_source_id",
14
- verifier_service_id: "verifier_service_id",
15
- verifier_id: "verifier_id",
16
- date: "date",
17
- request_div: "request_div",
18
- passed: "passed",
19
- source_n_id: "source_n_id",
20
- verification_date: "2003-05-18T11:22:33.456790",
21
- },
22
- n_id: "my_field",
23
- },
24
- {
25
- verified: true,
26
- signature: "sig",
27
- data: {
28
- field: "email_address",
29
- value: "jean@example.com",
30
- verifier_source_id: "verifier_source_id",
31
- verifier_service_id: "verifier_service_id",
32
- verifier_id: "verifier_id",
33
- date: "date",
34
- request_div: "request_div",
35
- passed: "passed",
36
- source_n_id: "source_n_id",
37
- verification_date: "2020-08-28T23:11:20.592912",
38
- metadata: {
39
- status: "pending",
40
- send_code_attempts: [
41
- {
42
- channel: "email",
43
- time: "2020-08-28T23:11:24.157Z",
44
- channel_id: "abc",
45
- },
46
- ],
47
- },
48
- },
49
- n_id: "my_email",
50
- },
51
- ];
52
- const profileObjects = [
53
- { properties: { a: 1 } },
54
- { properties: { email_address: "jean@example.com" } },
55
- {
56
- properties: {
57
- my_photo: {
58
- content: "...",
59
- content_type: "...",
60
- n_id: "n_id_of_my_ss_File",
61
- },
62
- },
63
- },
64
- ];
65
- const verifications = [
66
- {
67
- n_id: "my_email",
68
- properties: {
69
- verifications: [
70
- {
71
- data: {
72
- source: "EMAIL_ADDRESS",
73
- passed: false,
74
- request_div: "140c20e3-5146-4123-8e75-fe9064a6b71f",
75
- source_n_id: "3ec48392-4211-4c6a-92f9-50031f0f5716",
76
- verifier_source_id: "d796a383-5622-4e05-93b2-2fbe292d76fa",
77
- metadata: {
78
- url: "https://verify.twilio.com/v2/Services/VAa447486967ee88c1f59e2896f617f981/Verifications/VE398de58af34b4ef22fa24a404f30898d",
79
- send_code_attempts: [
80
- {
81
- channel: "email",
82
- time: "2020-08-28T23:11:24.157Z",
83
- channel_id: "pCmrKC4qQBSC_3m3crMctA",
84
- },
85
- ],
86
- status: "pending",
87
- id: "VE398de58af34b4ef22fa24a404f30898d",
88
- },
89
- verifier_id: "d796a383-5622-4e05-93b2-2fbe292d76fa",
90
- field: "email_address",
91
- verifier_div: "7137da93-0a53-4de7-b6df-3aa4b2b8d5e6",
92
- v_id: "d6c5246c-1141-4d0a-929f-1ed0aa00b52d",
93
- verification_date: "2020-08-28T23:11:20.592912",
94
- valid_until: "2020-08-28T23:12:35.678Z",
95
- },
96
- signature: "abcdefghijklmopqrstuvwxyz",
97
- },
98
- ],
99
- field: "email_address",
100
- initiator_n_id: "3ec48392-4211-4c6a-92f9-50031f0f5716",
101
- n_id: "my_email",
102
- },
103
- labels: ["ss_Verification", "ProfileObject"],
104
- referenceList: {},
105
- },
106
- {
107
- n_id: "my_photo",
108
- properties: {
109
- verifications: [
110
- {
111
- data: {
112
- passed: false,
113
- request_div: "a",
114
- source_n_id: "b",
115
- verifier_source_id: "c",
116
- verifier_id: "d",
117
- field: "my_photo",
118
- verifier_div: "e",
119
- v_id: "f",
120
- verification_date: "2020-12-05T11:22:33.456789",
121
- valid_until: "2020-08-28T23:12:35.678Z",
122
- },
123
- signature: "abcdefghijklmopqrstuvwxyz",
124
- },
125
- ],
126
- field: "my_photo",
127
- initiator_n_id: "3ec48392-4211-4c6a-92f9-50031f0f5716",
128
- n_id: "my_photo",
129
- },
130
- labels: ["ss_Verification", "ProfileObject"],
131
- referenceList: {},
132
- },
133
- ];
134
- describe("getSomeoneElsesRealVerifications", () => {
135
- beforeEach(() => {
136
- vi.resetAllMocks();
137
- operations_1.checkSomeoneElsesVerifications.mockResolvedValue(checkVerificationsResp);
138
- });
139
- it("returns an empty array if provided nothing", async () => {
140
- const result = await (0, getSomeoneElsesRealVerifications_1.getSomeoneElsesRealVerifications)({
141
- apiUrl: "https://example.com",
142
- profileObjects: [],
143
- verifications: [],
144
- });
145
- expect(result).toStrictEqual([]);
146
- expect(operations_1.checkSomeoneElsesVerifications).not.toHaveBeenCalled();
147
- });
148
- it("processes the user's verifications correctly", async () => {
149
- const result = await (0, getSomeoneElsesRealVerifications_1.getSomeoneElsesRealVerifications)({
150
- apiUrl: "https://example.com",
151
- profileObjects,
152
- verifications,
153
- });
154
- expect(result).toStrictEqual([
155
- {
156
- belongsToNId: "source_n_id",
157
- expired: false,
158
- fieldName: "email_address",
159
- metadata: {
160
- send_code_attempts: [
161
- {
162
- channel: "email",
163
- channel_id: "abc",
164
- time: "2020-08-28T23:11:24.157Z",
165
- },
166
- ],
167
- status: "pending",
168
- },
169
- nID: "my_email",
170
- provider: {
171
- dataSourceNId: "verifier_source_id",
172
- date: new Date("2020-08-28T23:11:20.592912Z"),
173
- serviceProviderNId: "verifier_service_id",
174
- verifierNId: "verifier_id",
175
- },
176
- signature: "sig",
177
- value: "jean@example.com",
178
- verified: "passed",
179
- xId: "request_div",
180
- },
181
- ]);
182
- expect(operations_1.checkSomeoneElsesVerifications).toHaveBeenCalledTimes(1);
183
- expect(operations_1.checkSomeoneElsesVerifications).toHaveBeenNthCalledWith(1, {
184
- apiUrl: "https://example.com",
185
- controller: undefined,
186
- toVerify: [
187
- {
188
- verifications: [
189
- { n_id: "my_email", signature: "abcdefghijklmopqrstuvwxyz" },
190
- ],
191
- data_to_verify: [{ value: "jean@example.com" }],
192
- },
193
- {
194
- verifications: [
195
- { n_id: "my_photo", signature: "abcdefghijklmopqrstuvwxyz" },
196
- ],
197
- data_to_verify: [
198
- // note how it re-created the $reference
199
- { value: { $ref: "urn:profile_object:n_id_of_my_ss_File" } },
200
- ],
201
- },
202
- ],
203
- });
204
- });
205
- });