Skip to content

Commit 02c6ff9

Browse files
committed
fix schema example
1 parent b0609ee commit 02c6ff9

File tree

1 file changed

+1
-156
lines changed

1 file changed

+1
-156
lines changed

example/standard_schemas.js

Lines changed: 1 addition & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,10 @@
11
import Schema from '../src/modules/schema';
22
import { validateCredentialSchema, expandJSONLD } from '../src/utils/vc';
33

4-
import bolSchema from '../src/utils/vc/schemas/bol';
54
import prCardSchema from '../src/utils/vc/schemas/pr_card';
6-
import qpInbonSchema from '../src/utils/vc/schemas/qp_inbond';
7-
import healthWorkerPassportSchema from '../src/utils/vc/schemas/health_worker_passport';
8-
import infectionDiagnosisSchema from '../src/utils/vc/schemas/infection_diagnosis';
95
import immunityEventRecordSchema from '../src/utils/vc/schemas/immunity_event_record';
106
import noInfectionSchema from '../src/utils/vc/schemas/non_infection_check';
117

12-
// Schema from here https://github.com/w3c-ccg/vc-examples/blob/master/plugfest-2020/vendors/mavennet/credentials/BillOfLading.json
13-
const bolCred = {
14-
'@context': [
15-
'https://www.w3.org/2018/credentials/v1',
16-
'https://schema.org/',
17-
'https://mavennet.github.io/contexts/bill-of-lading-v1.0.jsonld',
18-
],
19-
id: 'http://neo-flow.com/credentials/e94a16cb-35b2-4301-9fb6-7af3d8fe7b81',
20-
type: ['VerifiableCredential', 'BillOfLadingCredential'],
21-
name: 'Bill of Lading',
22-
description: 'Detailed shipment document provided by the carrier to the receiver of products.',
23-
issuer: 'did:v1:test:nym:z6MkfG5HTrBXzsAP8AbayNpG3ZaoyM4PCqNPrdWQRSpHDV6J',
24-
issuanceDate: '2020-04-09T21:13:13Z',
25-
credentialSubject: {
26-
productIdentifier: '3a185b8f-078a-4646-8343-76a45c2856a5',
27-
bolNumber: 'BOL000104976',
28-
carrier: 'did:v1:test:nym:z6MkhdmzFu659ZJ4XKj31vtEDmjvsi5yDZG5L7Caz63oP39k',
29-
recipient: 'did:v1:test:nym:z6MknQLHcwKwopce5ji1Ftsurn8mNL58wTxZB238uEMsegUj',
30-
transportType: 'Pipeline',
31-
originAddress: {
32-
address: 'Quebec, CAN',
33-
latitude: 52.9399,
34-
longitude: 73.5491,
35-
},
36-
deliveryAddress: {
37-
address: 'Chicago, USA',
38-
latitude: 41.8781,
39-
longitude: 87.6298,
40-
},
41-
valuePerItem: 46,
42-
totalOrderValue: 126500,
43-
freightChargeTerms: 'Freight Prepaid',
44-
expectedDeliveryDates: '2020-04-12',
45-
comments: '',
46-
},
47-
};
48-
498
// Schema from here https://github.com/w3c-ccg/vc-examples/blob/master/plugfest-2020/vendors/sicpa/credentials/PermanentResidentCard.json
509
const credPRCard = {
5110
'@context': [
@@ -80,119 +39,11 @@ const credPRCard = {
8039
description: 'Government of Example Permanent Resident Card.',
8140
};
8241

83-
const qPInbondCred = {
84-
'@context': [
85-
'https://www.w3.org/2018/credentials/v1',
86-
'https://schema.org/',
87-
'https://mavennet.github.io/contexts/qp-in-bond-v1.0.jsonld',
88-
],
89-
id: 'http://neo-flow.com/credentials/3aee17e7-8c50-4551-a8b4-9bc129c106e8',
90-
type: ['VerifiableCredential', 'QPInbondCredential'],
91-
name: 'QP Inbond',
92-
description: 'Permit document for import/export of shipments that have not been cleared by US Customs.',
93-
issuer: 'did:v1:test:nym:z6MkhdmzFu659ZJ4XKj31vtEDmjvsi5yDZG5L7Caz63oP39k',
94-
issuanceDate: '2020-04-09T21:13:43Z',
95-
credentialSubject: {
96-
productIdentifier: '3a185b8f-078a-4646-8343-76a45c2856a5',
97-
inBondNumber: '123456789',
98-
inBondType: 'IT (61)',
99-
portOfEntry: 'Superior, WI, USA',
100-
carrier: 'did:v1:test:nym:z6MkhdmzFu659ZJ4XKj31vtEDmjvsi5yDZG5L7Caz63oP39k',
101-
irsNumber: '12345678-01',
102-
transportType: 'Pipeline',
103-
recipient: 'did:v1:test:nym:z6MknQLHcwKwopce5ji1Ftsurn8mNL58wTxZB238uEMsegUj',
104-
originAddress: {
105-
address: 'Quebec, CAN',
106-
latitude: 52.9399,
107-
longitude: 73.5491,
108-
},
109-
deliveryAddress: {
110-
address: 'Chicago, USA',
111-
latitude: 41.8781,
112-
longitude: 87.6298,
113-
},
114-
bolNumber: 'BOL000104976',
115-
valuePerItem: 46,
116-
totalOrderValue: 126500,
117-
expectedDeliveryDates: '2020-04-12',
118-
comment: 'None',
119-
},
120-
};
121-
122-
// Schema from here https://docs.google.com/document/d/1F5TLvAqCxj1kaPuPe6JhdECixwpbhKpEAb8eeQuDGT4/edit#heading=h.kdkhzpmqto5s
123-
const healthCareWorkerCred = {
124-
'@context': [
125-
'https://www.w3.org/2018/credentials/v1',
126-
'https://www.w3.org/2018/credentials/examples/v1',
127-
'https://schema.org/',
128-
],
129-
id: 'https://example.com/credentials/1872',
130-
type: ['VerifiableCredential', 'HealthCareWorkerPassportCredential'],
131-
issuer: 'did:v1:test:nym:z6MkhdmzFu659ZJ4XKj31vtEDmjvsi5yDZG5L7Caz63oP39k',
132-
issuanceDate: '2020-04-09T21:13:43Z',
133-
credentialSubject: {
134-
firstName: 'John',
135-
lastName: 'Smith',
136-
photo: 'https://example.com/photos/102',
137-
biometricTemplate: {
138-
fingerprint: 'c2856a76a785b8fa185a45c',
139-
retina: '8fa185a45cc2856a76a785b',
140-
},
141-
degreeHeld: [
142-
{
143-
institution: 'Albany Medical College',
144-
degree: 'MD',
145-
},
146-
],
147-
licenses: [
148-
{
149-
licenseName: 'Medical License',
150-
licenser: 'New York',
151-
licensedFor: 'USA',
152-
expiresDate: '2020-11-25',
153-
},
154-
],
155-
},
156-
};
157-
158-
// Schema from here https://docs.google.com/document/d/1F5TLvAqCxj1kaPuPe6JhdECixwpbhKpEAb8eeQuDGT4/edit#heading=h.ppf3i61y3kbc
159-
const infectionDiagnosisCred = {
160-
'@context': [
161-
'https://www.w3.org/2018/credentials/v1',
162-
'https://www.w3.org/2018/credentials/examples/v1',
163-
'https://schema.org/',
164-
],
165-
id: 'https://example.com/credentials/1872',
166-
type: ['VerifiableCredential', 'InfectionDiagnosisCredential'],
167-
issuer: 'did:v1:test:nym:z6MkhdmzFu659ZJ4XKj31vtEDmjvsi5yDZG5L7Caz63oP39k',
168-
issuanceDate: '2020-04-09T21:13:43Z',
169-
credentialSubject: {
170-
firstName: 'John',
171-
firstInitial: 'J',
172-
lastName: 'Smith',
173-
lastInitial: 'S',
174-
yearOfBirth: 1990,
175-
photo: 'https://example.com/photos/102',
176-
biometricTemplate: {
177-
fingerprint: 'c2856a76a785b8fa185a45c',
178-
retina: '8fa185a45cc2856a76a785b',
179-
},
180-
diagnosisCode: 'CodeA',
181-
diagnosisTime: '2020-02-13T20:20:39+00:00',
182-
diagnosisLocation: 'New York City, New York, USA',
183-
diagnosedBy: 'Anne Lyons, MD',
184-
diagnosisFacility: 'Cedar Sinai Memorial Hospital',
185-
diagnosisMethods: ['personal interview and observation', 'rRT-PCR'],
186-
declaredSafeDate: '2020-03-15',
187-
},
188-
};
189-
19042
// Schema from here https://docs.google.com/document/d/1F5TLvAqCxj1kaPuPe6JhdECixwpbhKpEAb8eeQuDGT4/edit#heading=h.uuhsd64qh6k2
19143
const immunityEventRecordCred = {
19244
'@context': [
19345
'https://www.w3.org/2018/credentials/v1',
19446
'https://www.w3.org/2018/credentials/examples/v1',
195-
'https://schema.org/',
19647
],
19748
id: 'https://example.com/credentials/1872',
19849
type: ['VerifiableCredential', 'ImmunityEventRecordCredential'],
@@ -223,7 +74,6 @@ const noInfectionCred = {
22374
'@context': [
22475
'https://www.w3.org/2018/credentials/v1',
22576
'https://www.w3.org/2018/credentials/examples/v1',
226-
'https://schema.org/',
22777
],
22878
id: 'https://example.com/credentials/1872',
22979
type: ['VerifiableCredential', 'NoInfectionCredential'],
@@ -252,20 +102,15 @@ const noInfectionCred = {
252102
async function validateSchema(schema, credential) {
253103
console.log('Validating schema:', schema.description);
254104
await Schema.validateSchema(schema);
255-
console.log('Validating credential against schema...');
105+
console.log('Validating credential against schema...', credential);
256106

257107
const expanded = await expandJSONLD(credential);
258108
validateCredentialSchema(expanded, schema, credential['@context']);
259109
console.log('Success!');
260110
}
261111

262112
async function main() {
263-
await validateSchema(bolSchema, bolCred);
264113
await validateSchema(prCardSchema, credPRCard);
265-
await validateSchema(qpInbonSchema, qPInbondCred);
266-
await validateSchema(healthWorkerPassportSchema, healthCareWorkerCred);
267-
268-
await validateSchema(infectionDiagnosisSchema, infectionDiagnosisCred);
269114
await validateSchema(immunityEventRecordSchema, immunityEventRecordCred);
270115
await validateSchema(noInfectionSchema, noInfectionCred);
271116

0 commit comments

Comments
 (0)