Skip to content

Commit 147bacb

Browse files
author
Corey B
committed
fix: force deterministic JSON order and perfect template trimming in examples
1 parent 528403a commit 147bacb

4 files changed

Lines changed: 54 additions & 207 deletions

File tree

examples/bank_statement_v2.fdd

Lines changed: 17 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -9,132 +9,42 @@
99
"VerifiableCredential"
1010
],
1111
"issuer": "did:web:spuds0588.github.io:open-fdd",
12-
"issuanceDate": "2026-04-12T04:48:42.859Z",
12+
"issuanceDate": "2026-04-12T04:55:18.670Z",
1313
"credentialSubject": {
14-
"bankName": "First National Bank",
15-
"accountHolder": "Jordan M. Castillo",
16-
"accountNumber": "••••••7821",
17-
"accountType": "Personal Checking",
18-
"statementPeriod": "March 1–31, 2026",
19-
"openingBalance": "4,218.44",
20-
"closingBalance": "3,601.17",
21-
"totalCredits": "5,200.00",
22-
"totalDebits": "5,817.27",
14+
"accountHolder": "Jane Doe",
15+
"accountNumber": "••••4242",
16+
"balance": "4,200.00",
17+
"statementDate": "2026-04-11",
2318
"transactions": [
2419
{
25-
"date": "03/01",
26-
"description": "Opening Balance",
27-
"amount": "",
28-
"balance": "4,218.44",
29-
"type": "balance"
20+
"date": "2026-04-01",
21+
"description": "Deposit - Remote Work",
22+
"amount": "+$5,000.00"
3023
},
3124
{
32-
"date": "03/03",
33-
"description": "Direct Deposit — Acme Corp Payroll",
34-
"amount": "+2,600.00",
35-
"balance": "6,818.44",
36-
"type": "credit"
25+
"date": "2026-04-02",
26+
"description": "Rent Payment",
27+
"amount": "-$1,800.00"
3728
},
3829
{
39-
"date": "03/05",
40-
"description": "Rent — AutoPay Clearwater Apartments",
41-
"amount": "-1,450.00",
42-
"balance": "5,368.44",
43-
"type": "debit"
44-
},
45-
{
46-
"date": "03/07",
47-
"description": "Whole Foods Market",
48-
"amount": "-112.34",
49-
"balance": "5,256.10",
50-
"type": "debit"
51-
},
52-
{
53-
"date": "03/10",
54-
"description": "Netflix Subscription",
55-
"amount": "-15.99",
56-
"balance": "5,240.11",
57-
"type": "debit"
58-
},
59-
{
60-
"date": "03/12",
61-
"description": "ATM Withdrawal — 5th Ave Branch",
62-
"amount": "-200.00",
63-
"balance": "5,040.11",
64-
"type": "debit"
65-
},
66-
{
67-
"date": "03/17",
68-
"description": "Direct Deposit — Acme Corp Payroll",
69-
"amount": "+2,600.00",
70-
"balance": "7,640.11",
71-
"type": "credit"
72-
},
73-
{
74-
"date": "03/18",
75-
"description": "Chase Credit Card Payment",
76-
"amount": "-1,800.00",
77-
"balance": "5,840.11",
78-
"type": "debit"
79-
},
80-
{
81-
"date": "03/22",
82-
"description": "Amazon.com",
83-
"amount": "-67.94",
84-
"balance": "5,772.17",
85-
"type": "debit"
86-
},
87-
{
88-
"date": "03/25",
89-
"description": "Spotify",
90-
"amount": "-10.99",
91-
"balance": "5,761.18",
92-
"type": "debit"
93-
},
94-
{
95-
"date": "03/28",
96-
"description": "Utility — ComEd Electric",
97-
"amount": "-98.01",
98-
"balance": "5,663.17",
99-
"type": "debit"
100-
},
101-
{
102-
"date": "03/29",
103-
"description": "Gas Station — Shell",
104-
"amount": "-62.00",
105-
"balance": "5,601.17",
106-
"type": "debit"
107-
},
108-
{
109-
"date": "03/31",
110-
"description": "Transfer to Savings",
111-
"amount": "-2,000.00",
112-
"balance": "3,601.17",
113-
"type": "debit"
114-
},
115-
{
116-
"date": "03/31",
117-
"description": "Closing Balance",
118-
"amount": "",
119-
"balance": "3,601.17",
120-
"type": "balance"
30+
"date": "2026-04-05",
31+
"description": "Coffee Shop",
32+
"amount": "-$6.50"
12133
}
12234
]
12335
},
12436
"proof": {
12537
"type": "Ed25519Signature2020",
126-
"created": "2026-04-12T04:48:42.861Z",
38+
"created": "2026-04-12T04:55:18.672Z",
12739
"proofPurpose": "assertionMethod",
12840
"verificationMethod": "did:web:spuds0588.github.io:open-fdd#key-1",
129-
"signatureValue": "lYrOkcUX+t0CfThS2M+wE38Fkpd/Frn5gdl1jBQsn/J5PYNLWP6IgxpgRhFSemrw2Y7dvtLNOXlGPxHiqIWLBg=="
41+
"signatureValue": "2ZRCWwerI3rpV2q5WnSvbEqL8IKjBYlUy35lr9FZEd7NRg5OakkS2y3n7GQtxhVerBQQ5pShYhu5VsBeaEg5Bg=="
13042
}
13143
}
13244
</script>
13345

13446
<script type="application/json" id="user-notes">
135-
{
136-
"tags": []
137-
}
47+
{}
13848
</script>
13949

14050
<template shadowrootmode="open" bind="#fdd-data, #user-notes">

examples/legal_contract.fdd

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,66 +9,28 @@
99
"VerifiableCredential"
1010
],
1111
"issuer": "did:web:spuds0588.github.io:open-fdd",
12-
"issuanceDate": "2026-04-12T04:48:42.866Z",
12+
"issuanceDate": "2026-04-12T04:55:18.680Z",
1313
"credentialSubject": {
14-
"documentTitle": "Consulting Services Agreement",
15-
"documentId": "HSL-2026-0041",
16-
"effectiveDate": "2026-05-01",
17-
"expirationDate": "2027-04-30",
18-
"party1": {
19-
"name": "Hartwell & Sons Legal Group, LLP",
20-
"role": "Service Provider",
21-
"representative": "Margaret Hartwell, Esq.",
22-
"address": "1200 Wacker Drive, Suite 800, Chicago, IL 60601"
23-
},
24-
"party2": {
25-
"name": "Meridian Tech Solutions, Inc.",
26-
"role": "Client",
27-
"representative": "Daniel Park, CEO",
28-
"address": "482 Industrial Blvd, Austin, TX 78758"
29-
},
30-
"scopeOfServices": "Corporate legal advisory, contract review, and regulatory compliance consultation as requested by Client on a month-to-month retainer basis.",
31-
"compensation": "$8,500/month retainer, billed on the 1st of each month. Hourly overage rate: $450/hour.",
32-
"governingLaw": "State of Illinois",
33-
"clauses": [
34-
{
35-
"number": "1",
36-
"title": "Term",
37-
"text": "This Agreement shall commence on the Effective Date and continue for one (1) year unless terminated earlier."
38-
},
39-
{
40-
"number": "2",
41-
"title": "Confidentiality",
42-
"text": "Both parties agree to maintain the confidentiality of all proprietary information disclosed during the engagement."
43-
},
44-
{
45-
"number": "3",
46-
"title": "Termination",
47-
"text": "Either party may terminate this Agreement with thirty (30) days written notice."
48-
},
49-
{
50-
"number": "4",
51-
"title": "Governing Law",
52-
"text": "This Agreement shall be governed by the laws of the State of Illinois."
53-
}
54-
]
14+
"contractType": "Master Service Agreement",
15+
"contractId": "ID-88-2026",
16+
"effectiveDate": "2026-04-12",
17+
"clientName": "Cyberdyne Systems",
18+
"providerName": "DigiCore Solutions",
19+
"projectScope": "Cloud Migration Phase 1",
20+
"budget": "$250,000.00"
5521
},
5622
"proof": {
5723
"type": "Ed25519Signature2020",
58-
"created": "2026-04-12T04:48:42.866Z",
24+
"created": "2026-04-12T04:55:18.681Z",
5925
"proofPurpose": "assertionMethod",
6026
"verificationMethod": "did:web:spuds0588.github.io:open-fdd#key-1",
61-
"signatureValue": "L6pVN8/fjzlL3wCxeHrcHbiMKzn2FpwwQXa+08dBR//m3TKRKtACFke6wtDhyPfChXkopX9u29CZtUVYG2QeAw=="
27+
"signatureValue": "0ptkS/EnLrPiYOhojS23KpPk83Iu5Em8L8cCP6e/CDpKawOBN6RvWDyIVuZODCjP1LwQFt29iWa46D031lOmAA=="
6228
}
6329
}
6430
</script>
6531

6632
<script type="application/json" id="user-notes">
67-
{
68-
"clientSignature": "",
69-
"clientSignatureDate": "",
70-
"reviewNotes": ""
71-
}
33+
{}
7234
</script>
7335

7436
<template shadowrootmode="open" bind="#fdd-data, #user-notes">

examples/medical_lab_result.fdd

Lines changed: 17 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"VerifiableCredential"
1010
],
1111
"issuer": "did:web:spuds0588.github.io:open-fdd",
12-
"issuanceDate": "2026-04-12T04:48:42.864Z",
12+
"issuanceDate": "2026-04-12T04:55:18.677Z",
1313
"credentialSubject": {
1414
"patientName": "Alexandra Rivera",
1515
"dateOfBirth": "1987-03-22",
@@ -20,63 +20,40 @@
2020
"reportDate": "2026-04-10",
2121
"results": [
2222
{
23-
"test": "Hemoglobin (HGB)",
24-
"value": "13.8",
25-
"unit": "g/dL",
26-
"referenceRange": "12.0–16.0",
27-
"flag": "Normal"
28-
},
29-
{
30-
"test": "White Blood Cell Count",
31-
"value": "9.2",
32-
"unit": "K/uL",
33-
"referenceRange": "4.5–11.0",
34-
"flag": "Normal"
35-
},
36-
{
37-
"test": "Platelet Count (PLT)",
38-
"value": "142",
39-
"unit": "K/uL",
40-
"referenceRange": "150–400",
41-
"flag": "Low"
42-
},
43-
{
44-
"test": "Glucose (Fasting)",
45-
"value": "118",
23+
"test": "Glucose, Fasting",
24+
"result": "94",
4625
"unit": "mg/dL",
47-
"referenceRange": "7099",
48-
"flag": "High"
26+
"range": "70-99",
27+
"status": "Normal"
4928
},
5029
{
51-
"test": "Cholesterol Total",
52-
"value": "201",
53-
"unit": "mg/dL",
54-
"referenceRange": "<200",
55-
"flag": "Borderline"
30+
"test": "Hemoglobin A1c",
31+
"result": "5.4",
32+
"unit": "%",
33+
"range": "< 5.7",
34+
"status": "Normal"
5635
},
5736
{
58-
"test": "HDL Cholesterol",
59-
"value": "62",
37+
"test": "Cholesterol, Total",
38+
"result": "212",
6039
"unit": "mg/dL",
61-
"referenceRange": ">40",
62-
"flag": "Normal"
40+
"range": "< 200",
41+
"status": "Borderline High"
6342
}
6443
]
6544
},
6645
"proof": {
6746
"type": "Ed25519Signature2020",
68-
"created": "2026-04-12T04:48:42.864Z",
47+
"created": "2026-04-12T04:55:18.678Z",
6948
"proofPurpose": "assertionMethod",
7049
"verificationMethod": "did:web:spuds0588.github.io:open-fdd#key-1",
71-
"signatureValue": "zYsuQ+vfunqtiv+WSIHCNS0hwj1TTYV9vDpYfS/+fdh2zpHPkTXdfGa63XNOVtzdV/rgjmEzo6Nc+1sKlF65CQ=="
50+
"signatureValue": "DyYV2nnqZNTr1h5jM7p791MGQ53i3kg4uTTbH2LEdghg3mgguPUSdXo97KexvCbg6dmghT0U4/QK0ra3vMfGBw=="
7251
}
7352
}
7453
</script>
7554

7655
<script type="application/json" id="user-notes">
77-
{
78-
"physicianNotes": ""
79-
}
56+
{}
8057
</script>
8158

8259
<template shadowrootmode="open" bind="#fdd-data, #user-notes">

lib/node-fdd/src/sign.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,15 @@ export function signFdd(data, template, privateKeyPem, issuerUri, mutableData =
3232
template = template.trim();
3333
const privateKey = crypto.createPrivateKey(privateKeyPem);
3434

35-
// Build the Verifiable Credential wrapper (without proof first)
36-
const vc = {
37-
"@context": [
38-
"https://www.w3.org/2018/credentials/v1",
39-
"https://www.w3.org/2018/credentials/examples/v1"
40-
],
41-
"type": ["VerifiableCredential"],
42-
"issuer": issuerUri,
43-
"issuanceDate": new Date().toISOString(),
44-
"credentialSubject": data
45-
};
35+
const vc = {};
36+
vc["@context"] = [
37+
"https://www.w3.org/2018/credentials/v1",
38+
"https://www.w3.org/2018/credentials/examples/v1"
39+
];
40+
vc["type"] = ["VerifiableCredential"];
41+
vc["issuer"] = issuerUri;
42+
vc["issuanceDate"] = new Date().toISOString();
43+
vc["credentialSubject"] = data;
4644

4745
// Hash the deterministic payload (VC without proof + template)
4846
const payload = JSON.stringify(vc) + '\n---template---\n' + template;

0 commit comments

Comments
 (0)