@raytio/core 11.5.0 → 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 (133) hide show
  1. package/README.md +1708 -217
  2. package/dist/accessApplication/api/legacy/convertRelationships.d.ts +3 -5
  3. package/dist/accessApplication/api/legacy/convertRelationships.js +3 -3
  4. package/dist/crypto/cognitoAttributes.d.ts +3 -0
  5. package/dist/crypto/cognitoAttributes.js +15 -4
  6. package/dist/crypto/getAADecryptor.d.ts +1 -1
  7. package/dist/crypto/getAADecryptor.js +1 -3
  8. package/dist/crypto/index.d.ts +3 -0
  9. package/dist/crypto/index.js +6 -0
  10. package/dist/crypto/kdf/argon2.d.ts +67 -0
  11. package/dist/crypto/kdf/argon2.js +99 -0
  12. package/dist/crypto/kdf/index.d.ts +43 -0
  13. package/dist/crypto/kdf/index.js +106 -0
  14. package/dist/crypto/kdf/pbkdf2.d.ts +16 -0
  15. package/dist/crypto/kdf/pbkdf2.js +45 -0
  16. package/dist/crypto/kdf/twoSecretKdf.d.ts +37 -0
  17. package/dist/crypto/kdf/twoSecretKdf.js +66 -0
  18. package/dist/crypto/kdf/types.d.ts +65 -0
  19. package/dist/crypto/kdf/types.js +50 -0
  20. package/dist/crypto/kdf/utils.d.ts +59 -0
  21. package/dist/crypto/kdf/utils.js +110 -0
  22. package/dist/crypto/localSecret/format.d.ts +48 -0
  23. package/dist/crypto/localSecret/format.js +157 -0
  24. package/dist/crypto/localSecret/generator.d.ts +23 -0
  25. package/dist/crypto/localSecret/generator.js +53 -0
  26. package/dist/crypto/localSecret/index.d.ts +12 -0
  27. package/dist/crypto/localSecret/index.js +46 -0
  28. package/dist/crypto/localSecret/storage.d.ts +53 -0
  29. package/dist/crypto/localSecret/storage.js +207 -0
  30. package/dist/crypto/localSecret/types.d.ts +68 -0
  31. package/dist/crypto/localSecret/types.js +31 -0
  32. package/dist/crypto/pgpKey/encryption.d.ts +49 -0
  33. package/dist/crypto/pgpKey/encryption.js +104 -0
  34. package/dist/crypto/pgpKey/export.d.ts +59 -0
  35. package/dist/crypto/pgpKey/export.js +322 -0
  36. package/dist/crypto/pgpKey/format.d.ts +61 -0
  37. package/dist/crypto/pgpKey/format.js +143 -0
  38. package/dist/crypto/pgpKey/generator.d.ts +20 -0
  39. package/dist/crypto/pgpKey/generator.js +76 -0
  40. package/dist/crypto/pgpKey/import.d.ts +69 -0
  41. package/dist/crypto/pgpKey/import.js +239 -0
  42. package/dist/crypto/pgpKey/index.d.ts +19 -0
  43. package/dist/crypto/pgpKey/index.js +67 -0
  44. package/dist/crypto/pgpKey/signing.d.ts +44 -0
  45. package/dist/crypto/pgpKey/signing.js +71 -0
  46. package/dist/crypto/pgpKey/storage.d.ts +43 -0
  47. package/dist/crypto/pgpKey/storage.js +141 -0
  48. package/dist/crypto/pgpKey/types.d.ts +86 -0
  49. package/dist/crypto/pgpKey/types.js +25 -0
  50. package/dist/index.d.ts +1 -0
  51. package/dist/index.js +1 -0
  52. package/dist/rules/calculateScore.d.ts +1 -1
  53. package/dist/rules/convertInstanceToRuleInput.js +99 -97
  54. package/dist/rules/evaluateBadge.d.ts +36 -0
  55. package/dist/rules/evaluateBadge.js +36 -0
  56. package/dist/rules/index.d.ts +1 -0
  57. package/dist/rules/index.js +1 -0
  58. package/dist/rules/types/config.d.ts +1 -1
  59. package/dist/rules/types/dataValueTypes.d.ts +4 -4
  60. package/dist/schema/expandSchema/constants.js +1 -1
  61. package/dist/schema/expandSchema/expandSchema.d.ts +3 -3
  62. package/dist/schema/expandSchema/expandSchema.js +4 -4
  63. package/dist/schema/expandSchema/i18n.d.ts +6 -1
  64. package/dist/schema/expandSchema/i18n.js +32 -4
  65. package/dist/schema/expandSchema/maybeUseI18n.d.ts +2 -2
  66. package/dist/schema/expandSchema/maybeUseI18n.js +68 -11
  67. package/dist/schema/expandSchema/processSchema.js +14 -5
  68. package/dist/schema/expandSchema/removePrivateFields.d.ts +75 -22
  69. package/dist/schema/expandSchema/sortSchemaProperties.d.ts +4 -1
  70. package/dist/schema/expandSchema/sortSchemaProperties.js +24 -1
  71. package/dist/schema/labels.js +1 -2
  72. package/dist/util/canonicalJsonify.d.ts +7 -1
  73. package/dist/util/canonicalJsonify.js +3 -2
  74. package/dist/verifications/safeHarbour.js +5 -0
  75. package/dist/verifications/verifyCheck/getOwnRealVerifications.js +2 -0
  76. package/package.json +6 -4
  77. package/dist/__tests__/docs.test.d.ts +0 -1
  78. package/dist/__tests__/docs.test.js +0 -24
  79. package/dist/accessApplication/api/__tests__/fetchKeysForSubmission.test.d.ts +0 -1
  80. package/dist/accessApplication/api/__tests__/fetchKeysForSubmission.test.js +0 -28
  81. package/dist/accessApplication/api/__tests__/fetchPOsOrAOsForSubmission.test.d.ts +0 -1
  82. package/dist/accessApplication/api/__tests__/fetchPOsOrAOsForSubmission.test.js +0 -23
  83. package/dist/accessApplication/api/__tests__/fetchRelationshipsForSubmission.test.d.ts +0 -1
  84. package/dist/accessApplication/api/__tests__/fetchRelationshipsForSubmission.test.js +0 -27
  85. package/dist/accessApplication/api/__tests__/getMissingDataForInstance.test.d.ts +0 -1
  86. package/dist/accessApplication/api/__tests__/getMissingDataForInstance.test.js +0 -30
  87. package/dist/accessApplication/api/legacy/__tests__/convertRelationships.test.d.ts +0 -1
  88. package/dist/accessApplication/api/legacy/__tests__/convertRelationships.test.js +0 -37
  89. package/dist/rules/helpers/__tests__/addInfiniteThresholdBoundaries.test.d.ts +0 -1
  90. package/dist/rules/helpers/__tests__/addInfiniteThresholdBoundaries.test.js +0 -27
  91. package/dist/rules/helpers/__tests__/checkTypeofValue.test.d.ts +0 -1
  92. package/dist/rules/helpers/__tests__/checkTypeofValue.test.js +0 -49
  93. package/dist/rules/helpers/__tests__/getValuesFromPath.test.d.ts +0 -1
  94. package/dist/rules/helpers/__tests__/getValuesFromPath.test.js +0 -67
  95. package/dist/rules/helpers/__tests__/thresholds.test.d.ts +0 -1
  96. package/dist/rules/helpers/__tests__/thresholds.test.js +0 -32
  97. package/dist/rules/operators/__tests__/bool.test.d.ts +0 -1
  98. package/dist/rules/operators/__tests__/bool.test.js +0 -21
  99. package/dist/rules/operators/__tests__/date.test.d.ts +0 -1
  100. package/dist/rules/operators/__tests__/date.test.js +0 -81
  101. package/dist/rules/operators/__tests__/hfield.test.d.ts +0 -1
  102. package/dist/rules/operators/__tests__/hfield.test.js +0 -38
  103. package/dist/rules/operators/__tests__/hschema.test.d.ts +0 -1
  104. package/dist/rules/operators/__tests__/hschema.test.js +0 -24
  105. package/dist/rules/operators/__tests__/number.test.d.ts +0 -1
  106. package/dist/rules/operators/__tests__/number.test.js +0 -53
  107. package/dist/rules/operators/__tests__/string.test.d.ts +0 -1
  108. package/dist/rules/operators/__tests__/string.test.js +0 -74
  109. package/dist/schema/expandSchema/__tests__/addLoadingTimes.test.d.ts +0 -1
  110. package/dist/schema/expandSchema/__tests__/addLoadingTimes.test.js +0 -24
  111. package/dist/schema/expandSchema/__tests__/expandSchema.test.d.ts +0 -1
  112. package/dist/schema/expandSchema/__tests__/expandSchema.test.js +0 -96
  113. package/dist/schema/expandSchema/__tests__/i18n.test.d.ts +0 -1
  114. package/dist/schema/expandSchema/__tests__/i18n.test.js +0 -32
  115. package/dist/schema/expandSchema/__tests__/maybeUseI18n.test.d.ts +0 -1
  116. package/dist/schema/expandSchema/__tests__/maybeUseI18n.test.js +0 -98
  117. package/dist/schema/expandSchema/__tests__/processSchema.test.d.ts +0 -1
  118. package/dist/schema/expandSchema/__tests__/processSchema.test.js +0 -326
  119. package/dist/schema/expandSchema/__tests__/sortSchemaProperties.test.d.ts +0 -1
  120. package/dist/schema/expandSchema/__tests__/sortSchemaProperties.test.js +0 -182
  121. package/dist/schema/expandSchema/__tests__/util.test.d.ts +0 -1
  122. package/dist/schema/expandSchema/__tests__/util.test.js +0 -19
  123. package/dist/verifications/cleanInstance.d.ts +0 -9
  124. package/dist/verifications/cleanInstance.js +0 -15
  125. package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.d.ts +0 -1
  126. package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.js +0 -221
  127. package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.d.ts +0 -1
  128. package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.js +0 -206
  129. package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.d.ts +0 -1
  130. package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.js +0 -138
  131. package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.d.ts +0 -1
  132. package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.js +0 -49
  133. package/dist/verifications/verifyCheck/operations/__tests__/sampleBundle.json +0 -44
@@ -1,221 +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
- verification_type_id: "vertype id2",
69
- request_div: "x2",
70
- passed: false,
71
- source_n_id: "n2",
72
- },
73
- // legacy: key_id is not specified
74
- },
75
- ],
76
- },
77
- },
78
- {
79
- n_id: "nv3",
80
- properties: {
81
- verifications: [
82
- {
83
- signature: "signatureForLastNameMustermannFromN2",
84
- data: {
85
- field: "lName",
86
- verifier_source_id: "Ministry of pike river mine re-entry",
87
- verifier_service_id: "Minister for pike river re-entry",
88
- verifier_id: "v1",
89
- verification_date: "2020-08-28T23:11:20.592912",
90
- request_div: "x3",
91
- passed: false,
92
- source_n_id: "n2", // this ver was for lName=Mustermann in n2, so doesn't apply to lName=Mustermann in n1 !
93
- },
94
- },
95
- ],
96
- },
97
- },
98
- {
99
- n_id: "nv4",
100
- properties: {
101
- verifications: [{ data: { source_n_id: "doesn't exist" } }],
102
- },
103
- },
104
- {
105
- n_id: "nv5",
106
- properties: {
107
- verifications: [
108
- { data: { source_n_id: "n2", field: "doesn't exist" } },
109
- ],
110
- },
111
- },
112
- {
113
- n_id: "nv6",
114
- properties: {
115
- verifications: [
116
- {
117
- signature: "signatureForFirstNameErika",
118
- data: {
119
- field: "fName",
120
- verifier_source_id: "Ministry of pike river mine re-entry",
121
- verifier_service_id: "Minister for pike river re-entry",
122
- verifier_id: "v1",
123
- verification_date: "2020-08-28T23:11:20.592912",
124
- request_div: "x2",
125
- passed: false,
126
- source_n_id: "n2",
127
- },
128
- key_id: "thisOneIsInvalid", // signature & data is good, but this key will fail
129
- },
130
- ],
131
- },
132
- },
133
- {
134
- n_id: "nv7",
135
- properties: {
136
- verifications: [
137
- {
138
- signature: "signatureForFirstNameErika",
139
- data: {
140
- field: "fName",
141
- verifier_source_id: "Ministry of pike river mine re-entry",
142
- verifier_service_id: "Minister for pike river re-entry",
143
- verifier_id: "v1",
144
- verification_date: "2020-08-28T23:11:20.592912",
145
- request_div: "x2",
146
- passed: false,
147
- source_n_id: "n2",
148
- },
149
- key_id: "raytio", // everything is valid, this is the right key_id
150
- },
151
- ],
152
- },
153
- },
154
- ]);
155
- const realVers = await (0, __1.getOwnRealVerifications)({
156
- profileObjects,
157
- verifications,
158
- userId: "geesepolice2002",
159
- });
160
- expect(operations_1.checkOwnVerification).toHaveBeenCalledTimes(5);
161
- // 5 times. Because this new method doesn't need to build a big matrix of possible combinations
162
- expect(realVers).toStrictEqual([
163
- {
164
- fieldName: "fName",
165
- value: "Max",
166
- belongsToNId: "n1",
167
- nID: "nv1",
168
- expired: new Date("2020-08-28T23:12:35.678Z"),
169
- metadata: undefined,
170
- provider: {
171
- dataSourceNId: "Ministry of pike river mine re-entry",
172
- date: new Date("2020-08-28T23:11:20.592Z"),
173
- serviceProviderNId: "Minister for pike river re-entry",
174
- verificationTypeId: undefined,
175
- verifierNId: "v1",
176
- },
177
- signature: "signatureForFirstNameMax",
178
- verified: true,
179
- xId: "x1",
180
- },
181
- {
182
- fieldName: "fName",
183
- value: "Erika",
184
- belongsToNId: "n2",
185
- nID: "nv2",
186
- expired: false,
187
- metadata: undefined,
188
- provider: {
189
- dataSourceNId: "Ministry of pike river mine re-entry",
190
- date: new Date("2020-08-28T23:11:20.592Z"),
191
- serviceProviderNId: "Minister for pike river re-entry",
192
- verificationTypeId: "vertype id2",
193
- verifierNId: "v1",
194
- },
195
- signature: "signatureForFirstNameErika",
196
- verified: false,
197
- xId: "x2",
198
- },
199
- // note how lastName is not included since it's invalid
200
- // nv6 is not included because the key is invalid
201
- {
202
- fieldName: "fName",
203
- value: "Erika",
204
- belongsToNId: "n2",
205
- nID: "nv7",
206
- expired: false,
207
- metadata: undefined,
208
- provider: {
209
- dataSourceNId: "Ministry of pike river mine re-entry",
210
- date: new Date("2020-08-28T23:11:20.592Z"),
211
- verificationTypeId: undefined,
212
- serviceProviderNId: "Minister for pike river re-entry",
213
- verifierNId: "v1",
214
- },
215
- signature: "signatureForFirstNameErika",
216
- verified: false,
217
- xId: "x2",
218
- },
219
- ]);
220
- });
221
- });
@@ -1,206 +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
- verificationTypeId: undefined,
176
- },
177
- signature: "sig",
178
- value: "jean@example.com",
179
- verified: "passed",
180
- xId: "request_div",
181
- },
182
- ]);
183
- expect(operations_1.checkSomeoneElsesVerifications).toHaveBeenCalledTimes(1);
184
- expect(operations_1.checkSomeoneElsesVerifications).toHaveBeenNthCalledWith(1, {
185
- apiUrl: "https://example.com",
186
- controller: undefined,
187
- toVerify: [
188
- {
189
- verifications: [
190
- { n_id: "my_email", signature: "abcdefghijklmopqrstuvwxyz" },
191
- ],
192
- data_to_verify: [{ value: "jean@example.com" }],
193
- },
194
- {
195
- verifications: [
196
- { n_id: "my_photo", signature: "abcdefghijklmopqrstuvwxyz" },
197
- ],
198
- data_to_verify: [
199
- // note how it re-created the $reference
200
- { value: { $ref: "urn:profile_object:n_id_of_my_ss_File" } },
201
- ],
202
- },
203
- ],
204
- });
205
- });
206
- });
@@ -1,138 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const __1 = require("..");
7
- const util_1 = require("../../../../util");
8
- const checkOwnVerification_1 = require("../checkOwnVerification");
9
- const sampleBundle_json_1 = __importDefault(require("./sampleBundle.json"));
10
- global.fetch = vi.fn().mockImplementation(async (url) => ({
11
- text: async () => url.endsWith("raytio.pem")
12
- ? `-----BEGIN PUBLIC KEY-----
13
- MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAn9QtCqYa3H3ipFFU0xP3
14
- n6r7KHS3GMbh0h/xzel57HhCIaXDYjUeUtgUNtzm+uElb/qzGn50xQRzVqO32vKB
15
- ZAW2kYyZ2+R5ruk9CSxr7K4Vk1FtDMcUCzqxm0eycFD2xbLsN3feRc3BMjfdaQ7P
16
- OMAquVHxDqSHlL8hv3VEoPHyRz04ipGAlRzVCEQPQ8sZDNsgXo76OzLGlT4bEUGn
17
- mzH+FhS6DGts+X5b5ZW1iCzQTNZM3yzk947dyMsJVHwx+VyTT/o8D6/zWrZnmjK+
18
- lGOihted4AmvJePcF0kWP5XXpXiX12dRsluhXkIXkgmj9MuoxkdeqGuAxiZUVc5a
19
- zWfZao3Y3O5UwtRIEJOeZmr6EkYfdhg+JuDjacZ53Dg6WduX+5nG7/UqpepqtmHe
20
- R0Wsi2K8nXxkFkZmPy+s7e4+ABjN+IRrQYUJALziMjskqjxll8zKn+4Phmk8dIJw
21
- Gut0BoM+DIwDu0uZaUprz7fSgNmYHHEiIFbOMVHiOn8oZAZbJXXbUbFIUYXA8u9+
22
- J1Z+QEpgw+rhGzOf/TSeHfMC9nNbWgYglluAJusWf2XwG/t/VlhtzviHCVGEL7HQ
23
- jQE5DrM7vaTg6Gu9bjKuoeLIRzbOYK6qAWFoa0CLcN84PLjhDSRw2duatP08hcWg
24
- jTgOkLWnBFE7NyRU93uPp68CAwEAAQ==
25
- -----END PUBLIC KEY-----`
26
- : `-----BEGIN PUBLIC KEY-----
27
- MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAgee+uBOgOsbwjMvGN1/HqpGXGJLol0Pc2KhI1fh1NBq+UGhk8PqgDd5wHZikbmrtVkvp/maIh+mbIdehY/RCftMylvebCf4Qf+5SWzQsmB1o6nBUbwJzYE2XyvxRiNLhdIeE+GgfdpA5S3l0cDJ5B/1TagITmQUjThwTxDYZ6jlGJJ4NSjqlqeQrHhGWRLVQPWU8bYysX3jt3/uiv4tSn3TheLGY1TMlbFrVF2Spv1WxuqMZ4bX1mIotK3yEB3TaZSZaOwlUcEZ4xY+J4Vl+ZlrOgYbmzFd7UFh9UZbYZUkNSEfddEnFNFlFG3YQVt8UAumPBVJELdjiaRjTj/K462GAFyOcbcw9wcl69fPBnieBo2m2Dqf6U3wcrnvTnkMwjCewWXCH6FdbC4OllBZVNrfn6zf9yX0J8ZEDEcw9ZsNLVkyl2U+Ya/h5CQt43ip/1eNM5LpTbfqBTtAH7iUO4L9rxuSJFA2Q9kZfof6kYO9EGgMFB+GM47/Q068+IiTpifvPno4ilnowyS4hbLiyOs2yudW79flaz0a7rq5dLdSg9Mm5k7ETBm7WguDcocaiETmuYTJT2PozAGOC3+EPw5N7mQff4ecx/880FWYKQmU9Asav1V49DWSnG0ZXQ7U24dG8ANeAgKddDviJGlshSsjKrz8LJqeoNQu30iSGZhUCAwEAAQ==
28
- -----END PUBLIC KEY-----`,
29
- }));
30
- describe("checkOwnVerification", () => {
31
- it.each `
32
- keyId | result
33
- ${undefined} | ${false}
34
- ${"whatever/raytio"} | ${false}
35
- ${"whatever/somethingElse"} | ${true}
36
- `("returns $result for a PO with keyId=$keyId", async ({ keyId, result }) => {
37
- //
38
- // This is an important integration test from ca. 2021-12-02.
39
- // If it is failing, it means our code no longer matches the
40
- // backend, and all existing verifications will be erroneously
41
- // considered invalid
42
- //
43
- // UPDATED (see #1534). 3-26-25 We've added a new field `verification_type_id` in a verification object
44
- const signature = `AzUQUmBKv88kehDKySMLiAjSRFNNQNLmdwv5u0fa89uzDGeNH3L7Jc2Kduw5rY09AHU6PIzxvlXE
45
- 5KCy8k/0hPp/Gu9js1rWdcgJ0L5FLIIYEj2zSHZNthLEdi1mzLLiCbG2gvCPma0pZWobNJ/pSuMR
46
- JvzDQuENZ4rbvacLfWl/E0NneC3weuxc2PRacsTObrDIQvjSNOOns59cO53V6sPWSk5/9Zuxd2l5
47
- TsJ46MrtLlmN68Yg4IrQ0bWY3VATV98z1ZQJJbJCygzJgchzyxl1N82jD8FXKv0hF5WaGnK/cnHv
48
- mVWcSm2D1EFAunctjdiEyETMemy6q/MPk8l/tkPB0I5q1aeahck9MllAIF78gu4XSYERyjVxTmMk
49
- Zw/qdfvT22oeCL1ZXt0V5FZLKT6Ds7ueA0BTBl/0Uo4vVUS5rWOj3dkAIZo5i65ApeCrdxrq2Jmj
50
- 41XujSbGRq5kte6C6UTnVZcyiab2dS1+yKDqdC9BchphZPvjqxc90tUBlsbeMeOMqlGxcWK4ejdM
51
- kRblIeSeZE3UoiMQbLTV/1HCZMY/G8cFCEt78JxknrjpQ/7r45IMFoBi8LuZTVQqO7nTMs5ZILIR
52
- QoA6x6GzJrhbuR4VE1af0FdllfB8yhfxSuCsQxAsENrpcbeRCuYgm5RsVWBRNaaKosE3FT1Rmyw=
53
- `;
54
- // nId of this ver is "44371109-1a5c-41e7-b213-ff3befe194fc"
55
- const verObject = {
56
- v_id: "38d1d86f-ba46-4322-852d-c8d37eb9c84a",
57
- field: "phone_number",
58
- passed: false,
59
- schema: "ss_Phone_Number",
60
- source: "PHONE_NUMBER",
61
- metadata: {
62
- id: "VEd2b5fd534bc323e3fdc57605078028db",
63
- url: "https://verify.twilio.com/v2/Services/VAa447486967ee88c1f59e2896f617f981/Verifications/VEd2b5fd534bc323e3fdc57605078028db",
64
- status: "pending",
65
- send_code_attempts: [
66
- {
67
- time: "2024-11-01T05:28:29.864Z",
68
- channel: "sms",
69
- attempt_sid: "VLdc4496dcd3fa274a015cc2f7e106f72a",
70
- },
71
- ],
72
- },
73
- request_div: "a2998be0-59af-49fe-90fc-fc92a5fa7a8a",
74
- source_n_id: "3a2c916d-03d6-4243-a43a-2a7a8a61b867",
75
- verifier_id: "d796a383-5622-4e05-93b2-2fbe292d76fa",
76
- verifier_div: "0d61af52-35da-4676-a125-39997a7a1428",
77
- verification_date: "2024-11-01T05:28:25.846877+00:00",
78
- verifier_source_id: "d796a383-5622-4e05-93b2-2fbe292d76fa",
79
- verifier_service_id: "",
80
- verification_type_id: "fde35030-930e-48b8-b00c-77bf8e87933e",
81
- };
82
- const value = 6421446202;
83
- const userId = "c3920a9f-24fa-4101-a634-685b471c7d4d";
84
- expect(await (0, checkOwnVerification_1.checkOwnVerification)({
85
- value,
86
- signature,
87
- userId,
88
- verObject,
89
- keyId,
90
- })).toBe(result);
91
- });
92
- it("errors if you forget to supply the uId", async () => {
93
- await expect(() => (0, checkOwnVerification_1.checkOwnVerification)({
94
- value: "",
95
- signature: "",
96
- userId: "",
97
- verObject: {},
98
- keyId: undefined,
99
- })).rejects.toThrow(new Error("No userId supplied"));
100
- });
101
- it.each `
102
- keyId
103
- ${"../../malicious.pem"}
104
- ${"https://example.com/malicious.pem"}
105
- `("errors if you supply an invalid keyId", async ({ keyId }) => {
106
- await expect(() => (0, checkOwnVerification_1.checkOwnVerification)({
107
- value: "whatever",
108
- signature: "whatever",
109
- userId: "whatever",
110
- verObject: {},
111
- keyId,
112
- })).rejects.toThrow(new Error("Invalid key ID"));
113
- });
114
- });
115
- describe("checkSignature", () => {
116
- it("works", async () => {
117
- // same test as the backend
118
- // see https://gitlab.com/raytio/mono/-/blob/devo/common/signing/tests/test_sign.py#L104
119
- const jwk = {
120
- kty: "RSA",
121
- alg: "PS512",
122
- key_ops: ["verify"],
123
- ext: true,
124
- n: "wD6Oy9Wts0BAI7ObvxD73MNppefO3XMEMSZSxi1JTyfmavzV59rXMleRK5IBoY7ghOyy33-6131qQyh6cfbz5q67mHmTBEJmOccmw1hbl7SVSUHXOuUGUq5C7p3qnxeUhOFtxBlhMdIj0vkZ923lPHZpw9Yhit-RlLwW01Qnh-mGNmWMuUqrcj-WDb0WbIxjkaUR_DEIELkFiD9nF56mv3A6bMX_-ZJaF21ChD_b8qy_unQhNWrrUUwGzUaEMyw1dbPnvQ1iouMADlRlDBojZB0rWveK0PswqnUy3bB9dqVjpn50lN3CgdGeOPVVOcaLHhX0OLOCERpZY0hbuajfGIORMqnvF1dZJ_0OPrm-etpHK3ngK2qJ-mSjobd9DP_KISe2hAWs0FU4wbgG8U4VgcjYCkuABSh9c3xMEA5xyXV8iwGjTdmsOf4AvbBj1vY1dJVBYeGHuVRm-SxWepoVbYYDPg0366sYiim9IcQG0olxqAfkglB4yAmqYfp_kxqL2Cb8ysgyioHe9vmZDTbfTTm00qVAVKr2bctAgI787VEpS7Ou_2QTPIxYlsQCa-MbdgtUoXQ6__VdRklEaiQ_IFLBZzg5lFNBbF1Qytgav-BLfjZR31T5fhhougzrjBrtDGsSiV8qIvr5ZBfeJCatm1N_atbdjfWG7njoQMRwV5c",
125
- e: "AQAB",
126
- };
127
- const cryptoKey = await crypto.subtle.importKey("jwk", jwk, { name: "RSA-PSS", hash: "SHA-512" }, false, ["verify"]);
128
- const data = "This is definitely true";
129
- const signature = "V0r2KI4TBTwyzV8fCmGIL6x3t11ROhG9UJts1VZiap94wXEnEP+TNQ6qVV1v8bWY9uoubYLNzzuVfbn4q1J1ERNJWEM469/A8zNRiptDEmrlfSMBHE2Ahrwn5h0nSjxttOGazqitX+Ir0Qo0itNINpIa5cRC4ttyumauSKFcaGhFHGCuOpQz4xPoCR6ww2UtEvfvomTI5PYedG2XzhOJioZ8P9QtgKDnt+mp5Baq5avRtDpK+gZ8zOHXW8YL5d/oO16K6HDdYe4nGjr4MQU93HJjzQVEtsZqtvwf2BznVSuChGd0kedlal2uIrDQ4H4l6Td1TqW+FJp+EHVdbdrbk+Gql2GwiDAVsIPHDDGfaeIZQSStbr9VgQSm0feqtRlI627VCQ5ewAd1+tEgRiVTz74ya8tmc62WzTF5dbSYkQtllc/SJNWxaMQ+MEBrDyatfRrurTeTXwnRROJ/idJFKGKdxQichNdiuqL/CnBQJc3oYzQNoQXAmIUGDelISY5+XgHKXDs9YX4AVbru/Ina3E86TIekLVOUqg7TJi1hLAdF3RANp48uXk7LuIffzcff5sBUQ0vtHVtyTFwd2Jmt1CiEd9DitMNQT5cjM21IC6uJ4HZ6Ni/fd0N9frZ6Svknd/MMsbM7aqt8z6IgREqYdGY2XLYZCeZ0qmCGW243v3A=";
130
- const stringifiedData = (0, util_1.canonicalJsonify)(data);
131
- expect(await (0, checkOwnVerification_1.checkSignature)(cryptoKey, signature, stringifiedData)).toBe(true);
132
- });
133
- });
134
- describe("checkJsonSignature", () => {
135
- it("can verify a bundled verification", async () => {
136
- expect(await (0, __1.checkJsonSignature)(sampleBundle_json_1.default.data, sampleBundle_json_1.default.signature, sampleBundle_json_1.default.key_id)).toBe(true);
137
- });
138
- });
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const checkSomeoneElsesVerifications_1 = require("../checkSomeoneElsesVerifications");
4
- const toVerify = [
5
- {
6
- verifications: [{ signature: "sig1", n_id: "nid1" }],
7
- data_to_verify: [{ value: "val1" }],
8
- },
9
- {
10
- verifications: [{ signature: "sig2", n_id: "nid2" }],
11
- data_to_verify: [{ value: "val2" }],
12
- },
13
- ];
14
- describe("checkSomeoneElsesVerifications", () => {
15
- it("calls the API and filters out garbage", async () => {
16
- global.fetch = vi
17
- .fn()
18
- .mockImplementation()
19
- // first fetch request
20
- .mockImplementationOnce(async () => ({
21
- json: async () => [{ verified: true }, { verified: false }, {}, {}],
22
- }));
23
- const result = await (0, checkSomeoneElsesVerifications_1.checkSomeoneElsesVerifications)({
24
- apiUrl: "https://example.com",
25
- toVerify,
26
- });
27
- expect(fetch).toHaveBeenCalledTimes(1);
28
- expect(fetch).toHaveBeenCalledWith("https://example.com/extract_verify/v2/verify_check", {
29
- body: JSON.stringify(toVerify),
30
- method: "POST",
31
- signal: undefined,
32
- });
33
- // note how empty objects were filtered out
34
- expect(result).toStrictEqual([{ verified: true }, { verified: false }]);
35
- });
36
- it("throws an error if the API rejects", async () => {
37
- global.fetch = vi
38
- .fn()
39
- .mockImplementation()
40
- // first fetch request
41
- .mockImplementationOnce(async () => ({
42
- json: async () => ({ message: "An API error" }),
43
- }));
44
- await expect(() => (0, checkSomeoneElsesVerifications_1.checkSomeoneElsesVerifications)({
45
- apiUrl: "https://example.com",
46
- toVerify,
47
- })).rejects.toThrow(new Error("An API error"));
48
- });
49
- });
@@ -1,44 +0,0 @@
1
- {
2
- "__comment": "This belongs to 10feb22 🦈",
3
- "bundle_version": 1,
4
- "data": {
5
- "n_id": "f4220899-4af7-4f66-8a00-1bc13936096b",
6
- "schema": "ss_NZ_Company",
7
- "fields": {
8
- "nzbn": {
9
- "verifiers": [
10
- { "verifier_id": "185e9cdc-e8fb-4147-b996-3c2dd60fab59" },
11
- { "verifier_id": "185e9cdc-e8fb-4147-b996-3c2dd60fab59" }
12
- ],
13
- "derivations": []
14
- },
15
- "entity_type_description": {
16
- "verifiers": [
17
- { "verifier_id": "185e9cdc-e8fb-4147-b996-3c2dd60fab59" },
18
- { "verifier_id": "185e9cdc-e8fb-4147-b996-3c2dd60fab59" }
19
- ],
20
- "derivations": [],
21
- "value": "NZ Limited Company"
22
- },
23
- "entity_status_description": {
24
- "verifiers": [
25
- { "verifier_id": "185e9cdc-e8fb-4147-b996-3c2dd60fab59" },
26
- { "verifier_id": "185e9cdc-e8fb-4147-b996-3c2dd60fab59" }
27
- ],
28
- "derivations": [],
29
- "value": "Registered"
30
- },
31
- "nz_legal_entity_name": {
32
- "verifiers": [
33
- { "verifier_id": "185e9cdc-e8fb-4147-b996-3c2dd60fab59" },
34
- { "verifier_id": "185e9cdc-e8fb-4147-b996-3c2dd60fab59" }
35
- ],
36
- "derivations": [],
37
- "value": "DEPARTMENT OF CONVERSATION LIMITED"
38
- }
39
- },
40
- "valid_until": "2022-03-13T02:26:20.468171"
41
- },
42
- "key_id": "any string/raytio",
43
- "signature": "AiWWrL+S1paYOqJiOtU3qwLTCkkZjwDq3FuHl7oy14IATYOhCeHLf+ca44X1Wc6pYpTQckjKnJZL\nkfgiwNE97aymWIOc+ZZGEb5YhXRNO+inTV4k5zppaDN3n3YAGzn7zMxleh3+opzJqncNaJtpZ0Wv\na9Pu/m4WjyT5ee3Myz6VOOMuVkcaTL4FD8XT7NdCh0ybRevAZ5R9xl0YuWMhvNpf3P6ieTikHXYN\nkKbPTnAhNdBmqV4njSIR66M82Ek0d9VcsX4zhmlhpdCmGRlXLgHEyMCF4iHlCIxSeKtGaOm2QK2R\nOV/lN3VScDNWyD8lPBipcj++5ZGII6BnFFG8LlT3gY/Y/wt8KeH/xgdu0a7Lt6J/BOiGLFfscUmb\nH5K5t48gnQ5BQS+Cf/yhayMV49LlGiK9m1iPlbmuJH1L2/ZM+iLsIrSTGCU0Rpbkw7qvm0dkUNYf\nhvlj/RnUxcy0Lr/84CzLvBhFMmBX+RHlcPrCWpIiibsdaD81kRyvLY2TASLFTeHajfr+UvtP3LVs\n8NGwRQHd6c2/ptxv3ERRUnDtNASatsLe67ZHg9SeF3BDhMHZwU1neYyrBI1TMECasFli5rP5gviq\nC8ZwFQ9lnDDTidWBF8GjRl6ope4wIuNBBkOsIIeyqIJE5BRUH4LhVUnN1be696uCKnWOyOo7fkc=\n"
44
- }