Make dashboard demo fixtures testable
Browse files- index.html +23 -1
index.html
CHANGED
|
@@ -482,6 +482,20 @@
|
|
| 482 |
await finish();
|
| 483 |
};
|
| 484 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 485 |
async function finish() {
|
| 486 |
let verdict = 'NEEDS_REVIEW';
|
| 487 |
let reason = 'DEMO MODE: This browser-only page does not read or authenticate document contents. A professional credential decision requires OCR/forensics, issuer registry checks, revocation checks, and a server-signed audit certificate.';
|
|
@@ -490,12 +504,20 @@
|
|
| 490 |
let ror_id = '--';
|
| 491 |
|
| 492 |
const allowedTypes = ['application/pdf', 'image/png', 'image/jpeg'];
|
| 493 |
-
const
|
|
|
|
| 494 |
if (!fileTypeKnown) {
|
| 495 |
verdict = 'REJECTED';
|
| 496 |
status_code = 'UNSUPPORTED_TYPE';
|
| 497 |
reason = 'Unsupported file type. Upload a PDF, PNG, or JPEG credential for a production server-side audit.';
|
| 498 |
log('SYSTEM: REJECTED - Unsupported file type for audit intake.');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 499 |
} else {
|
| 500 |
log('SYSTEM: DEMO ONLY - File content was not sent to a trusted audit service.');
|
| 501 |
log('SYSTEM: NEEDS REVIEW - No browser-side approval is issued.');
|
|
|
|
| 482 |
await finish();
|
| 483 |
};
|
| 484 |
|
| 485 |
+
function inferDemoOutcome(uploadedFile) {
|
| 486 |
+
const name = uploadedFile.name.toLowerCase();
|
| 487 |
+
const demoBlacklist = [
|
| 488 |
+
{ pattern: 'graham', issuer: 'Graham International University' },
|
| 489 |
+
{ pattern: 'giu', issuer: 'Graham International University' },
|
| 490 |
+
{ pattern: 'pacific', issuer: 'Pacific Western University' },
|
| 491 |
+
{ pattern: 'fake', issuer: 'Pacific Western University' },
|
| 492 |
+
{ pattern: 'fraud', issuer: 'Pacific Western University' },
|
| 493 |
+
{ pattern: 'belford', issuer: 'Belford University' },
|
| 494 |
+
{ pattern: 'almeda', issuer: 'Almeda University' }
|
| 495 |
+
];
|
| 496 |
+
return demoBlacklist.find(item => name.includes(item.pattern));
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
async function finish() {
|
| 500 |
let verdict = 'NEEDS_REVIEW';
|
| 501 |
let reason = 'DEMO MODE: This browser-only page does not read or authenticate document contents. A professional credential decision requires OCR/forensics, issuer registry checks, revocation checks, and a server-signed audit certificate.';
|
|
|
|
| 504 |
let ror_id = '--';
|
| 505 |
|
| 506 |
const allowedTypes = ['application/pdf', 'image/png', 'image/jpeg'];
|
| 507 |
+
const allowedExtensions = ['.pdf', '.png', '.jpg', '.jpeg'];
|
| 508 |
+
const fileTypeKnown = allowedTypes.includes(file.type) || allowedExtensions.some(ext => file.name.toLowerCase().endsWith(ext));
|
| 509 |
if (!fileTypeKnown) {
|
| 510 |
verdict = 'REJECTED';
|
| 511 |
status_code = 'UNSUPPORTED_TYPE';
|
| 512 |
reason = 'Unsupported file type. Upload a PDF, PNG, or JPEG credential for a production server-side audit.';
|
| 513 |
log('SYSTEM: REJECTED - Unsupported file type for audit intake.');
|
| 514 |
+
} else if (inferDemoOutcome(file)) {
|
| 515 |
+
const fixture = inferDemoOutcome(file);
|
| 516 |
+
verdict = 'REJECTED';
|
| 517 |
+
status_code = 'DEMO_BLACKLIST_MATCH';
|
| 518 |
+
issuer = fixture.issuer;
|
| 519 |
+
reason = `${fixture.issuer} matches the public demo blacklist fixture. This is a browser-side demo result only; production rejection still requires a server-signed audit trail.`;
|
| 520 |
+
log(`SYSTEM: DEMO REJECTED - ${fixture.issuer} matched the local demo blacklist fixture.`);
|
| 521 |
} else {
|
| 522 |
log('SYSTEM: DEMO ONLY - File content was not sent to a trusted audit service.');
|
| 523 |
log('SYSTEM: NEEDS REVIEW - No browser-side approval is issued.');
|