@pdtf/schemas 0.5.11 → 0.5.14

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.
package/index.js CHANGED
@@ -8,8 +8,7 @@ const baspiLegalInformation = require("./src/schemas/baspi-b-legal-information.j
8
8
  const energyPerformanceCertificate = require("./src/schemas/energy-performance-certificate.json");
9
9
  const titleDeed = require("./src/schemas/title-deed.json");
10
10
  const geoJson = require("./src/schemas/GeoJSON.json");
11
- const pdtfClaim = require("./src/schemas/pdtf-claim.json");
12
- const verifiedClaim = require("./src/schemas/verified_claims-12.json");
11
+ const verifiedClaimsSchema = require("./src/schemas/pdtf-verified-claims.json");
13
12
 
14
13
  const subSchemas = {
15
14
  "https://homebuyingandsellinggroup.co.uk/schemas/baspi-a-material-facts.json":
@@ -19,14 +18,15 @@ const subSchemas = {
19
18
  "https://homebuyingandsellinggroup.co.uk/schemas/energy-performance-certificate.json":
20
19
  energyPerformanceCertificate,
21
20
  "https://geojson.org/schema/GeoJSON.json": geoJson,
22
- "https://homebuyingandsellinggroup.co.uk/schemas/title-deed.json": titleDeed
21
+ "https://homebuyingandsellinggroup.co.uk/schemas/title-deed.json": titleDeed,
23
22
  };
24
23
 
25
24
  const propertyPackSchema = dereference(propertyPack, (id) => subSchemas[id]);
26
25
 
27
26
  const ajv = new Ajv({
28
27
  allErrors: true,
29
- strictSchema: false
28
+ // schema contains additional baspiRef and RDSRef metadata which is not strictly valid
29
+ strictSchema: false,
30
30
  });
31
31
  // Adds date formats among other types to the validator.
32
32
  addFormats(ajv);
@@ -36,7 +36,7 @@ const validator = ajv.compile(propertyPackSchema);
36
36
  const getSubschema = (path) => {
37
37
  const pathArray = path.split("/").slice(1);
38
38
  if (pathArray.length < 1) {
39
- return schema;
39
+ return propertyPackSchema;
40
40
  }
41
41
  return pathArray.reduce((propertyPackSchema, pathElement) => {
42
42
  return propertyPackSchema.properties[pathElement];
@@ -44,7 +44,14 @@ const getSubschema = (path) => {
44
44
  };
45
45
 
46
46
  const getSubschemaValidator = (path) => {
47
- return ajv.getSchema(path) || ajv.compile(getSubschema(path));
47
+ const subSchema = getSubschema(path);
48
+ let validator = ajv.getSchema(path);
49
+ if (!validator && subSchema.$id) validator = ajv.getSchema(subSchema.$id);
50
+ if (!validator) {
51
+ ajv.addSchema(subSchema, path);
52
+ validator = ajv.getSchema(path);
53
+ }
54
+ return validator;
48
55
  };
49
56
 
50
57
  const getTitleAtPath = (schema, path, rootPath = path) => {
@@ -97,6 +104,5 @@ module.exports = {
97
104
  getSubschema,
98
105
  getSubschemaValidator,
99
106
  getTitleAtPath,
100
- pdtfClaim,
101
- verifiedClaim
107
+ verifiedClaimsSchema,
102
108
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdtf/schemas",
3
- "version": "0.5.11",
3
+ "version": "0.5.14",
4
4
  "description": "Property Data Trust Framework Schemas and Utilities",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -0,0 +1,42 @@
1
+ {
2
+ "verification": {
3
+ "trust_framework": "uk_pdtf",
4
+ "time": "2022-01-25T13:16:44.527Z",
5
+ "evidence": [
6
+ {
7
+ "verification_method": {
8
+ "type": "auth"
9
+ },
10
+ "type": "vouch",
11
+ "attestation": {
12
+ "voucher": {
13
+ "name": "Maria Harris"
14
+ },
15
+ "type": "digital_attestation"
16
+ }
17
+ },
18
+ {
19
+ "type": "document",
20
+ "attachments": [
21
+ {
22
+ "digest": {
23
+ "alg": "md5",
24
+ "value": "randomHashValue"
25
+ },
26
+ "url": "https://fakeFileStore.com/some/kind/of/file",
27
+ "desc": "proofOfAddress.pdf"
28
+ }
29
+ ]
30
+ }
31
+ ]
32
+ },
33
+ "claims": {
34
+ "/propertyPack/materialFacts/propertyToBeSold/councilTax": {
35
+ "councilTaxBand": "D",
36
+ "councilTaxAffectingAlterations": {
37
+ "yesNo": "Yes",
38
+ "details": "Extension added in 2005 to add bedroom with ensuite shower room. Certificate of Compliance issued 17th Feb 2006 and council tax updated"
39
+ }
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "verification": {
3
+ "time": "2022-01-25T07:52:14.318Z",
4
+ "trust_framework": "uk_pdtf",
5
+ "evidence": [
6
+ {
7
+ "type": "electronic_record",
8
+ "record": {
9
+ "source": {
10
+ "name": "Royal Mail Postcode Address File record via ideal-postcodes.co.uk"
11
+ },
12
+ "type": "postcode_address_file"
13
+ }
14
+ }
15
+ ]
16
+ },
17
+ "claims": {
18
+ "/propertyPack/materialFacts/address": {
19
+ "address1": "3 The Hollys",
20
+ "address2": "Birtley",
21
+ "town": "CHESTER LE STREET",
22
+ "county": "County Durham",
23
+ "postcode": "DH3 1QN"
24
+ }
25
+ }
26
+ }
@@ -2,15 +2,17 @@
2
2
  "$schema": "https://homebuyingandsellinggroup.co.uk/schemas/property-pack.json",
3
3
  "uprn": 100000059583,
4
4
  "propertyPack": {
5
- "sellers": [
6
- {
7
- "name": { "firstName": "John", "lastName": "Davies" },
8
- "dateOfBirth": "1975-12-25",
9
- "mobileNumber": "07777 222333",
10
- "email": "john@theseller.com",
11
- "address": { "address1": "10 Downend Park", "postcode": "BS7 9PU" }
12
- }
13
- ],
5
+ "sellers": {
6
+ "sellerInformation": [
7
+ {
8
+ "name": { "firstName": "John", "lastName": "Davies" },
9
+ "dateOfBirth": "1975-12-25",
10
+ "mobileNumber": "07777 222333",
11
+ "email": "john@theseller.com",
12
+ "address": { "address1": "10 Downend Park", "postcode": "BS7 9PU" }
13
+ }
14
+ ]
15
+ },
14
16
  "materialFacts": {
15
17
  "address": {
16
18
  "address1": "10 Downend Park",
@@ -23,7 +25,7 @@
23
25
  "energyEfficiencyRating": "A"
24
26
  },
25
27
  "delayFactors": {
26
- "yesNo": "No"
28
+ "hasDelayFactors": { "yesNo": "No" }
27
29
  },
28
30
  "ownership": {
29
31
  "ownershipType": "Freehold"
@@ -367,6 +369,9 @@
367
369
  "consumerProtectionRegulationsDeclaration": {
368
370
  "consumerProtectionRegulationsResponse": true
369
371
  }
372
+ },
373
+ "energyPerformanceCertificate": {
374
+ "certificate": { "currentEnergyRating": "B" }
370
375
  }
371
376
  }
372
377
  }
@@ -0,0 +1,25 @@
1
+ {
2
+ "verification": {
3
+ "trust_framework": "uk_pdtf",
4
+ "time": "2022-01-25T13:05:03.108Z",
5
+ "evidence": [
6
+ {
7
+ "type": "vouch",
8
+ "attestation": {
9
+ "type": "digital_attestation",
10
+ "voucher": {
11
+ "name": "Maria Harris"
12
+ }
13
+ },
14
+ "verification_method": {
15
+ "type": "auth"
16
+ }
17
+ }
18
+ ]
19
+ },
20
+ "claims": {
21
+ "/propertyPack/materialFacts/propertyToBeSold/delayFactors/hasDelayFactors": {
22
+ "yesNo": "No"
23
+ }
24
+ }
25
+ }
@@ -4,10 +4,13 @@
4
4
  "type": "object",
5
5
  "title": "Energy Performance Certificate and Recommendations Schema, supporting data retrieved from https://epc.opendatacommunities.org ",
6
6
  "description": "Mirrors the Domestic EPC Glossary at https://epc.opendatacommunities.org/docs/guidance#glossary",
7
+ "required": ["certificate"],
7
8
  "properties": {
8
9
  "certificate": {
9
10
  "type": "object",
11
+ "required": ["currentEnergyRating"],
10
12
  "properties": {
13
+ "certificateNumber": { "type": "string" },
11
14
  "address": { "type": "string" },
12
15
  "address1": { "type": "string" },
13
16
  "address2": { "type": "string" },
@@ -0,0 +1,417 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://homebuyingandsellinggroup.co.uk/schemas/pdtf-verified-claims.json",
4
+ "definitions": {
5
+ "date_type": {
6
+ "type": "string",
7
+ "format": "date"
8
+ },
9
+ "time_type": {
10
+ "type": "string",
11
+ "format": "date-time"
12
+ },
13
+ "document_number": {
14
+ "type": "string"
15
+ },
16
+ "document_details": {
17
+ "type": "object",
18
+ "properties": {
19
+ "type": {
20
+ "type": "string"
21
+ },
22
+ "document_number": {
23
+ "$ref": "#/definitions/document_number"
24
+ },
25
+ "number": {
26
+ "$ref": "#/definitions/document_number"
27
+ },
28
+ "personal_number": {
29
+ "type": "string"
30
+ },
31
+ "serial_number": {
32
+ "type": "string"
33
+ },
34
+ "date_of_issuance": {
35
+ "$ref": "#/definitions/date_type"
36
+ },
37
+ "date_of_expiry": {
38
+ "$ref": "#/definitions/date_type"
39
+ },
40
+ "issuer": {
41
+ "type": "object",
42
+ "properties": {
43
+ "name": {
44
+ "type": "string"
45
+ },
46
+ "formatted": {
47
+ "type": "string"
48
+ },
49
+ "street_address": {
50
+ "type": "string"
51
+ },
52
+ "locality": {
53
+ "type": "string"
54
+ },
55
+ "region": {
56
+ "type": "string"
57
+ },
58
+ "postal_code": {
59
+ "type": "string"
60
+ },
61
+ "country": {
62
+ "type": "string"
63
+ },
64
+ "country_code": {
65
+ "type": "string"
66
+ },
67
+ "jurisdiction": {
68
+ "type": "string"
69
+ }
70
+ }
71
+ }
72
+ }
73
+ },
74
+ "validation_method": {
75
+ "type": "object",
76
+ "properties": {
77
+ "type": {
78
+ "type": "string"
79
+ }
80
+ }
81
+ },
82
+ "verification_method": {
83
+ "type": "object",
84
+ "properties": {
85
+ "type": {
86
+ "type": "string"
87
+ }
88
+ }
89
+ },
90
+ "evidence": {
91
+ "type": "object",
92
+ "properties": {
93
+ "type": {
94
+ "type": "string",
95
+ "enum": ["document", "electronic_record", "vouch"]
96
+ },
97
+ "attachments": {
98
+ "$ref": "#/definitions/attachments"
99
+ }
100
+ },
101
+ "required": ["type"],
102
+ "allOf": [
103
+ {
104
+ "if": {
105
+ "properties": {
106
+ "type": {
107
+ "const": "document"
108
+ }
109
+ }
110
+ },
111
+ "then": {
112
+ "properties": {
113
+ "validation_method": {
114
+ "$ref": "#/definitions/validation_method"
115
+ },
116
+ "verification_method": {
117
+ "$ref": "#/definitions/verification_method"
118
+ },
119
+ "verifier": {
120
+ "type": "object",
121
+ "properties": {
122
+ "organization": {
123
+ "type": "string"
124
+ },
125
+ "txn": {
126
+ "type": "string"
127
+ }
128
+ }
129
+ },
130
+ "time": {
131
+ "$ref": "#/definitions/time_type"
132
+ },
133
+ "document_details": {
134
+ "$ref": "#/definitions/document_details"
135
+ }
136
+ }
137
+ },
138
+ "else": {}
139
+ },
140
+ {
141
+ "if": {
142
+ "properties": {
143
+ "type": {
144
+ "value": "electronic_record"
145
+ }
146
+ }
147
+ },
148
+ "then": {
149
+ "properties": {
150
+ "validation_method": {
151
+ "$ref": "#/definitions/validation_method"
152
+ },
153
+ "verification_method": {
154
+ "$ref": "#/definitions/verification_method"
155
+ },
156
+ "verifier": {
157
+ "type": "object",
158
+ "properties": {
159
+ "organization": {
160
+ "type": "string"
161
+ },
162
+ "txn": {
163
+ "type": "string"
164
+ }
165
+ }
166
+ },
167
+ "time": {
168
+ "$ref": "#/definitions/time_type"
169
+ },
170
+ "record": {
171
+ "type": "object",
172
+ "properties": {
173
+ "type": {
174
+ "type": "string"
175
+ },
176
+ "personal_number": {
177
+ "type": "string"
178
+ },
179
+ "created_at": {
180
+ "$ref": "#/definitions/date_type"
181
+ },
182
+ "date_of_expiry": {
183
+ "$ref": "#/definitions/date_type"
184
+ },
185
+ "source": {
186
+ "type": "object",
187
+ "properties": {
188
+ "name": {
189
+ "type": "string"
190
+ },
191
+ "formatted": {
192
+ "type": "string"
193
+ },
194
+ "street_address": {
195
+ "type": "string"
196
+ },
197
+ "locality": {
198
+ "type": "string"
199
+ },
200
+ "region": {
201
+ "type": "string"
202
+ },
203
+ "postal_code": {
204
+ "type": "string"
205
+ },
206
+ "country": {
207
+ "type": "string"
208
+ },
209
+ "country_code": {
210
+ "type": "string"
211
+ },
212
+ "jurisdiction": {
213
+ "type": "string"
214
+ }
215
+ }
216
+ }
217
+ }
218
+ }
219
+ }
220
+ },
221
+ "else": {}
222
+ },
223
+ {
224
+ "if": {
225
+ "properties": {
226
+ "type": {
227
+ "value": "vouch"
228
+ }
229
+ }
230
+ },
231
+ "then": {
232
+ "properties": {
233
+ "validation_method": {
234
+ "$ref": "#/definitions/validation_method"
235
+ },
236
+ "verification_method": {
237
+ "$ref": "#/definitions/verification_method"
238
+ },
239
+ "verifier": {
240
+ "type": "object",
241
+ "properties": {
242
+ "organization": {
243
+ "type": "string"
244
+ },
245
+ "txn": {
246
+ "type": "string"
247
+ }
248
+ }
249
+ },
250
+ "time": {
251
+ "$ref": "#/definitions/time_type"
252
+ },
253
+ "attestation": {
254
+ "type": "object",
255
+ "properties": {
256
+ "type": {
257
+ "type": "string",
258
+ "const": "digital_attestation"
259
+ },
260
+ "reference_number": {
261
+ "type": "string"
262
+ },
263
+ "personal_number": {
264
+ "type": "string"
265
+ },
266
+ "date_of_issuance": {
267
+ "$ref": "#/definitions/date_type"
268
+ },
269
+ "date_of_expiry": {
270
+ "$ref": "#/definitions/date_type"
271
+ },
272
+ "voucher": {
273
+ "type": "object",
274
+ "properties": {
275
+ "name": {
276
+ "type": "string"
277
+ },
278
+ "birthdate": {
279
+ "$ref": "#/definitions/date_type"
280
+ },
281
+ "formatted": {
282
+ "type": "string"
283
+ },
284
+ "street_address": {
285
+ "type": "string"
286
+ },
287
+ "locality": {
288
+ "type": "string"
289
+ },
290
+ "region": {
291
+ "type": "string"
292
+ },
293
+ "postal_code": {
294
+ "type": "string"
295
+ },
296
+ "country": {
297
+ "type": "string"
298
+ },
299
+ "occupation": {
300
+ "type": "string"
301
+ },
302
+ "organization": {
303
+ "type": "string"
304
+ }
305
+ }
306
+ }
307
+ }
308
+ }
309
+ }
310
+ },
311
+ "else": {}
312
+ }
313
+ ]
314
+ },
315
+ "digest": {
316
+ "type": "object",
317
+ "properties": {
318
+ "alg": {
319
+ "type": "string"
320
+ },
321
+ "value": {
322
+ "type": "string",
323
+ "contentEncoding": "base64"
324
+ }
325
+ },
326
+ "required": ["alg", "value"]
327
+ },
328
+ "external_attachment": {
329
+ "type": "object",
330
+ "properties": {
331
+ "desc": {
332
+ "type": "string"
333
+ },
334
+ "digest": {
335
+ "$ref": "#/definitions/digest"
336
+ },
337
+ "url": {
338
+ "type": "string",
339
+ "format": "uri"
340
+ },
341
+ "access_token": {
342
+ "type": ["string", "null"]
343
+ },
344
+ "expires_in": {
345
+ "type": "integer",
346
+ "minimum": 1
347
+ }
348
+ },
349
+ "required": ["digest", "url"]
350
+ },
351
+ "attachments": {
352
+ "type": "array",
353
+ "minItems": 1,
354
+ "items": {
355
+ "$ref": "#/definitions/external_attachment"
356
+ }
357
+ },
358
+ "verified_claims_def": {
359
+ "type": "object",
360
+ "properties": {
361
+ "verification": {
362
+ "type": "object",
363
+ "properties": {
364
+ "trust_framework": {
365
+ "type": "string",
366
+ "const": "uk_pdtf"
367
+ },
368
+ "time": {
369
+ "$ref": "#/definitions/time_type"
370
+ },
371
+ "evidence": {
372
+ "type": "array",
373
+ "minItems": 1,
374
+ "items": {
375
+ "oneOf": [
376
+ {
377
+ "$ref": "#/definitions/evidence"
378
+ }
379
+ ]
380
+ }
381
+ }
382
+ },
383
+ "required": ["trust_framework"],
384
+ "additionalProperties": true
385
+ },
386
+ "claims": {
387
+ "type": "object",
388
+ "patternProperties": {
389
+ "^(/|([a-zA-Z0-9/-]+)+$)": { "type": "object" }
390
+ },
391
+ "minProperties": 1,
392
+ "additionalProperties": false
393
+ }
394
+ },
395
+ "required": ["verification", "claims"],
396
+ "additionalProperties": false
397
+ }
398
+ },
399
+ "type": "object",
400
+ "required": ["verified_claims"],
401
+ "properties": {
402
+ "verified_claims": {
403
+ "anyOf": [
404
+ {
405
+ "$ref": "#/definitions/verified_claims_def"
406
+ },
407
+ {
408
+ "type": "array",
409
+ "items": {
410
+ "$ref": "#/definitions/verified_claims_def"
411
+ }
412
+ }
413
+ ]
414
+ }
415
+ },
416
+ "additionalProperties": false
417
+ }
@@ -18,15 +18,15 @@
18
18
  "propertyPack": {
19
19
  "title": "Property Pack",
20
20
  "type": "object",
21
- "required": ["sellers"],
22
21
  "properties": {
23
22
  "sellers": {
24
23
  "RDSRef": "",
25
- "title": "The sellers",
24
+ "title": "Information about the sellers",
26
25
  "type": "object",
26
+ "required": ["sellerInformation"],
27
27
  "properties": {
28
28
  "sellerInformation": {
29
- "title": "Information about the sellers",
29
+ "title": "",
30
30
  "type": "array",
31
31
  "minItems": 1,
32
32
  "items": {
@@ -41,7 +41,7 @@
41
41
  ],
42
42
  "properties": {
43
43
  "name": {
44
- "title": "Name",
44
+ "title": "",
45
45
  "type": "object",
46
46
  "required": ["firstName", "lastName"],
47
47
  "properties": {
@@ -4,11 +4,11 @@
4
4
  "definitions": {
5
5
  "date_type": {
6
6
  "type": "string",
7
- "pattern": "^(?:(?:(?:(?:(?:[1-9]\\d)(?:0[48]|[2468][048]|[13579][26])|(?:(?:[2468][048]|[13579][26])00))(\\/|-|\\.)(?:0?2\\1(?:29)))|(?:(?:[1-9]\\d{3})(\\/|-|\\.)(?:(?:(?:0?[13578]|1[02])\\2(?:31))|(?:(?:0?[13-9]|1[0-2])\\2(?:29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\\2(?:0?[1-9]|1\\d|2[0-8])))))$"
7
+ "format": "date"
8
8
  },
9
9
  "time_type": {
10
10
  "type": "string",
11
- "pattern": "^(?:[\\+-]?\\d{4}(?!\\d{2}\\b))(?:(-?)(?:(?:0[1-9]|1[0-2])(?:\\1(?:[12]\\d|0[1-9]|3[01]))?|W(?:[0-4]\\d|5[0-2])(?:-?[1-7])?|(?:00[1-9]|0[1-9]\\d|[12]\\d{2}|3(?:[0-5]\\d|6[1-6])))(?:[T\\s](?:(?:(?:[01]\\d|2[0-3])(?:(:?)[0-5]\\d)?|24\\:?00)(?:[\\.,]\\d+(?!:))?)?(?:\\2[0-5]\\d(?:[\\.,]\\d+)?)?(?:[zZ]|(?:[\\+-])(?:[01]\\d|2[0-3]):?(?:[0-5]\\d)?)?)?)?$"
11
+ "format": "date-time"
12
12
  },
13
13
  "document_number": {
14
14
  "type": "string"
@@ -77,7 +77,7 @@
77
77
  "type": {
78
78
  "type": "string"
79
79
  },
80
- "policy":{
80
+ "policy": {
81
81
  "type": "string"
82
82
  },
83
83
  "procedure": {
@@ -94,7 +94,7 @@
94
94
  "type": {
95
95
  "type": "string"
96
96
  },
97
- "policy":{
97
+ "policy": {
98
98
  "type": "string"
99
99
  },
100
100
  "procedure": {
@@ -123,15 +123,13 @@
123
123
  "$ref": "#/definitions/attachments"
124
124
  }
125
125
  },
126
- "required": [
127
- "type"
128
- ],
126
+ "required": ["type"],
129
127
  "allOf": [
130
128
  {
131
129
  "if": {
132
130
  "properties": {
133
131
  "type": {
134
- "value": "electronic_signature"
132
+ "const": "electronic_signature"
135
133
  }
136
134
  }
137
135
  },
@@ -157,6 +155,7 @@
157
155
  "if": {
158
156
  "properties": {
159
157
  "type": {
158
+ "type": "string",
160
159
  "pattern": "^(id_)*document$"
161
160
  }
162
161
  }
@@ -200,7 +199,7 @@
200
199
  "if": {
201
200
  "properties": {
202
201
  "type": {
203
- "value": "electronic_record"
202
+ "const": "electronic_record"
204
203
  }
205
204
  }
206
205
  },
@@ -269,7 +268,7 @@
269
268
  "type": "string"
270
269
  },
271
270
  "jurisdiction": {
272
- "type": "string"
271
+ "type": "string"
273
272
  }
274
273
  }
275
274
  }
@@ -283,7 +282,7 @@
283
282
  "if": {
284
283
  "properties": {
285
284
  "type": {
286
- "value": "vouch"
285
+ "const": "vouch"
287
286
  }
288
287
  }
289
288
  },
@@ -372,7 +371,7 @@
372
371
  "if": {
373
372
  "properties": {
374
373
  "type": {
375
- "value": "utility_bill"
374
+ "const": "utility_bill"
376
375
  }
377
376
  }
378
377
  },
@@ -424,10 +423,7 @@
424
423
  "contentEncoding": "base64"
425
424
  }
426
425
  },
427
- "required": [
428
- "alg",
429
- "value"
430
- ]
426
+ "required": ["alg", "value"]
431
427
  },
432
428
  "external_attachment": {
433
429
  "type": "object",
@@ -450,10 +446,7 @@
450
446
  "minimum": 1
451
447
  }
452
448
  },
453
- "required": [
454
- "digest",
455
- "url"
456
- ]
449
+ "required": ["digest", "url"]
457
450
  },
458
451
  "embedded_attachment": {
459
452
  "type": "object",
@@ -469,10 +462,7 @@
469
462
  "contentEncoding": "base64"
470
463
  }
471
464
  },
472
- "required": [
473
- "content_type",
474
- "content"
475
- ]
465
+ "required": ["content_type", "content"]
476
466
  },
477
467
  "attachments": {
478
468
  "type": "array",
@@ -503,7 +493,7 @@
503
493
  "assurance_process": {
504
494
  "type": "object",
505
495
  "properties": {
506
- "policy":{
496
+ "policy": {
507
497
  "type": "string"
508
498
  },
509
499
  "procedure": {
@@ -532,9 +522,7 @@
532
522
  }
533
523
  }
534
524
  },
535
- "required": [
536
- "trust_framework"
537
- ],
525
+ "required": ["trust_framework"],
538
526
  "additionalProperties": true
539
527
  },
540
528
  "claims": {
@@ -542,30 +530,27 @@
542
530
  "minProperties": 1
543
531
  }
544
532
  },
545
- "required": [
546
- "verification",
547
- "claims"
548
- ],
533
+ "required": ["verification", "claims"],
549
534
  "additionalProperties": false
550
535
  },
551
536
  "distributed_claims_available_def": {
552
537
  "type": "object",
553
538
  "properties": {},
554
539
  "additionalProperties": {
555
- "$ref": "verified_claims_request-12.json#definitions/verified_claims_def"
540
+ "$ref": "#/definitions/verified_claims_def"
556
541
  }
557
542
  },
558
543
  "aggregated_claims": {
544
+ "type": "object",
559
545
  "properties": {
560
546
  "JWT": {
561
547
  "type": "string"
562
548
  }
563
549
  },
564
- "required": [
565
- "JWT"
566
- ]
550
+ "required": ["JWT"]
567
551
  },
568
552
  "distributed_claims": {
553
+ "type": "object",
569
554
  "properties": {
570
555
  "endpoint": {
571
556
  "type": "string"
@@ -574,10 +559,7 @@
574
559
  "type": "string"
575
560
  }
576
561
  },
577
- "required": [
578
- "endpoint",
579
- "access_token"
580
- ]
562
+ "required": ["endpoint", "access_token"]
581
563
  },
582
564
  "_claim_sources": {
583
565
  "anyOf": [
@@ -590,6 +572,8 @@
590
572
  ]
591
573
  }
592
574
  },
575
+ "type": "object",
576
+ "required": ["verified_claims"],
593
577
  "properties": {
594
578
  "verified_claims": {
595
579
  "anyOf": [
@@ -634,4 +618,4 @@
634
618
  }
635
619
  }
636
620
  }
637
- }
621
+ }
@@ -0,0 +1,63 @@
1
+ const jp = require("jsonpointer");
2
+ const Ajv = require("ajv");
3
+ const addFormats = require("ajv-formats");
4
+
5
+ const { getSubschemaValidator, getTitleAtPath } = require("../../index.js");
6
+
7
+ const verifiedClaimsSchema = require("../schemas/pdtf-verified-claims.json");
8
+ const exampleElectronicRecord = require("../examples/exampleElectronicRecord.json");
9
+ const exampleVouch = require("../examples/exampleVouch.json");
10
+ const exampleDocumentedVouch = require("../examples/exampleDocumentedVouch.json");
11
+
12
+ const ajv = new Ajv({
13
+ allErrors: true,
14
+ strictSchema: false
15
+ });
16
+ addFormats(ajv);
17
+
18
+ const validator = ajv.compile(verifiedClaimsSchema);
19
+
20
+ test("valid vouch sample is valid", () => {
21
+ const isValid = validator({ verified_claims: exampleVouch });
22
+ expect(isValid).toBe(true);
23
+ });
24
+
25
+ test("valid electronic record sample is valid", () => {
26
+ const isValid = validator({ verified_claims: exampleElectronicRecord });
27
+ expect(isValid).toBe(true);
28
+ });
29
+
30
+ test("valid documented vouch sample is valid", () => {
31
+ const isValid = validator({ verified_claims: exampleDocumentedVouch });
32
+ expect(isValid).toBe(true);
33
+ });
34
+
35
+ test("claim with missing claims is invalid", () => {
36
+ const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
37
+ delete clonedVouch.claims;
38
+ const isValid = validator({ verified_claims: clonedVouch });
39
+ expect(isValid).toBe(false);
40
+ });
41
+
42
+ test.only("claim with invalid claims path is invalid", () => {
43
+ const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
44
+ const originalPath = Object.keys(clonedVouch.claims)[0];
45
+ const data = clonedVouch.claims[originalPath];
46
+ clonedVouch.claims = { "invalidPath//of?someKind": data };
47
+ const isValid = validator({ verified_claims: clonedVouch });
48
+ expect(isValid).toBe(false);
49
+ });
50
+
51
+ test("verification with invalid evidence type is invalid", () => {
52
+ const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
53
+ clonedVouch.verification.evidence[0].type = "something invalid";
54
+ const isValid = validator({ verified_claims: clonedVouch });
55
+ expect(isValid).toBe(false);
56
+ });
57
+
58
+ test("verification with no framework type is invalid", () => {
59
+ const clonedVouch = JSON.parse(JSON.stringify(exampleVouch));
60
+ delete clonedVouch.verification.trust_framework;
61
+ const isValid = validator({ verified_claims: clonedVouch });
62
+ expect(isValid).toBe(false);
63
+ });
@@ -5,9 +5,9 @@ const {
5
5
  validator,
6
6
  getSubschema,
7
7
  getSubschemaValidator,
8
- getTitleAtPath
8
+ getTitleAtPath,
9
9
  } = require("../../index.js");
10
- const examplePropertyPack = require("./examplePropertyPack.json");
10
+ const examplePropertyPack = require("../examples/examplePropertyPack.json");
11
11
 
12
12
  test("exports a property pack schema", () => {
13
13
  expect(propertyPackSchema).not.toBeNull();
@@ -15,7 +15,6 @@ test("exports a property pack schema", () => {
15
15
 
16
16
  test("sample is valid", () => {
17
17
  const isValid = validator(examplePropertyPack);
18
- console.log(validator.errors);
19
18
  expect(isValid).toBe(true);
20
19
  });
21
20
 
@@ -38,11 +37,27 @@ test("sample with missing dependent required fields is invalid", () => {
38
37
  expect(isValid).toBe(false);
39
38
  });
40
39
 
40
+ test("correctly gets a top level subschema", () => {
41
+ const subschema = getSubschema("/propertyPack");
42
+ expect(subschema.title).toBe("Property Pack");
43
+ });
44
+
41
45
  test("correctly gets a subschema", () => {
42
46
  const subschema = getSubschema("/propertyPack/materialFacts/notices");
43
47
  expect(subschema.title).toBe("Notices which Affect the Property");
44
48
  });
45
49
 
50
+ test("correctly gets a subschema validator which is already cached", () => {
51
+ const validator = getSubschemaValidator(
52
+ "/propertyPack/energyPerformanceCertificate"
53
+ );
54
+ expect(validator).not.toBeNull();
55
+ const anotherValidator = getSubschemaValidator(
56
+ "/propertyPack/energyPerformanceCertificate"
57
+ );
58
+ expect(anotherValidator).not.toBeNull();
59
+ });
60
+
46
61
  test("correctly gets a working subschema validator", () => {
47
62
  const path = "/propertyPack/materialFacts/notices";
48
63
  const validator = getSubschemaValidator(path);
@@ -1,27 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://homebuyingandsellinggroup.co.uk/schemas/pdtf-claim.json",
4
- "type": "object",
5
- "title": "Property Data Trust Framework Claim",
6
- "description": "PDTF verified claims are implemented in accordance with the OpenID Connect Verified Claims model, within which the actual claims object should conform to this schema to ensure the necessary metadata is attached",
7
- "properties": {
8
- "schema": {
9
- "type": "string",
10
- "format": "uri",
11
- "description": "The $id of the JSONSchema against which the path and data have been generated, for example https://homebuyingandsellinggroup.co.uk/schemas/0.1.0/pdtf.json"
12
- },
13
- "path": {
14
- "type": "string",
15
- "description": "The JSON Pointer reference to the location in the schema corresponding to the new data as defined at https://datatracker.ietf.org/doc/html/rfc6901, for example /propertyPack/propertyToBeSold/address"
16
- },
17
- "data": {
18
- "type": "string",
19
- "description": "A JSON object representing the segment of the overall data structure which is being provided."
20
- },
21
- "attribution": {
22
- "type": "string",
23
- "description": "Details of any attribution, copyright or licencing requirements relating to the provided data"
24
- }
25
- },
26
- "required": ["schema", "path", "data"]
27
- }