Files
software-station/frontend/src/lib/verifier.ts
Sudo-Ivan 4c60e3cf4a
All checks were successful
renovate / renovate (push) Successful in 2m8s
CI / build (push) Successful in 10m24s
Update asset verification and user experience
- Added SRI hash injection during frontend build to improve security.
- Updated ESLint configuration to include 'navigator' as a global variable.
- Introduced a new `settingsStore` to manage user preferences for asset verification.
- Enhanced `SoftwareCard` and `VerificationModal` components to display contributor information and security checks.
- Updated `verificationStore` to handle expanded toast notifications for detailed verification steps.
- Implemented a new `CodeBlock` component for displaying code snippets with syntax highlighting.
- Improved API documentation and added new endpoints for fetching software and asset details.
2025-12-27 16:29:05 -06:00

31 lines
742 B
TypeScript

import type { VerificationResult } from './types';
export async function loadVerifier() {
if (typeof window === 'undefined') return null;
if ((window as any).verifySHA256) return (window as any).verifySHA256;
const go = new (window as any).Go();
const result = await WebAssembly.instantiateStreaming(
fetch('/verifier/verifier.wasm'),
go.importObject
);
go.run(result.instance);
return (window as any).verifySHA256;
}
export async function verifyAsset(
data: ArrayBuffer,
expectedHash: string
): Promise<VerificationResult> {
const verify = await loadVerifier();
if (!verify) {
return {
valid: false,
steps: [],
error: 'WASM verifier not available',
};
}
return verify(new Uint8Array(data), expectedHash);
}