-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathverify.html
More file actions
119 lines (101 loc) · 3.96 KB
/
Copy pathverify.html
File metadata and controls
119 lines (101 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html>
<head>
<title>QWED Certificate Verifier</title>
<style>
body {
font-family: Arial;
max-width: 800px;
margin: 50px auto;
padding: 20px;
}
textarea {
width: 100%;
height: 200px;
padding: 10px;
font-family: monospace;
}
.preview {
color: #8a5a00;
background: #fff8e1;
padding: 20px;
border-radius: 5px;
border: 1px solid #ffb300;
}
.invalid {
color: red;
background: #ffebee;
padding: 20px;
border-radius: 5px;
border: 1px solid red;
}
button {
background: #00C853;
color: white;
border: none;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
border-radius: 5px;
margin-top: 10px;
}
button:hover {
background: #009624;
}
h1 {
color: #333;
}
</style>
</head>
<body>
<h1>Certificate Structure Preview</h1>
<p>Paste your <code>credential.json</code> content below to inspect its structure.</p>
<p><strong>Important:</strong> this static page does not make a cryptographic authenticity claim. Use the Python verifier for trusted signature verification.</p>
<textarea id="credentialInput" placeholder='{"@context": ...}'></textarea>
<br>
<button onclick="verifyCertificate()">Inspect Certificate</button>
<div id="result" style="margin-top: 20px;"></div>
<script>
async function verifyCertificate() {
const resultDiv = document.getElementById('result');
resultDiv.innerHTML = "Inspecting...";
try {
const input = document.getElementById('credentialInput').value.trim();
if (!input) throw new Error("Please paste a credential JSON.");
const credential = JSON.parse(input);
const didResponse = await fetch('https://qwed-ai.com/.well-known/did.json');
if (!didResponse.ok) {
throw new Error("Could not fetch DID document. Verification must fail closed.");
}
const didDoc = await didResponse.json();
const isIssuerValid = credential.issuer === 'did:web:qwed-ai.com';
const isModulesValid = credential.credentialSubject?.modulesCertified === 11;
if (isIssuerValid && isModulesValid) {
const subject = credential.credentialSubject;
resultDiv.innerHTML = `
<div class="preview">
<h2>Certificate Structure Looks Plausible</h2>
<p><strong>Student:</strong> ${subject.name}</p>
<p><strong>Course:</strong> ${subject.courseTitle}</p>
<p><strong>Completed:</strong> ${subject.completionDate}</p>
<p><strong>Modules:</strong> ${subject.modulesCertified}/11</p>
<p><small>Issued by: ${credential.issuer}</small></p>
<p><small>DID document loaded from: ${didDoc.id}</small></p>
<p><strong>Next step:</strong> run the Python verifier to confirm signature authenticity.</p>
</div>
`;
} else {
resultDiv.innerHTML = `
<div class="invalid">
<h2>Invalid Certificate Structure</h2>
<p>Issuer or module count mismatch.</p>
</div>
`;
}
} catch (e) {
resultDiv.innerHTML = `<div class="invalid"><strong>Error:</strong> ${e.message}</div>`;
}
}
</script>
</body>
</html>