- 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.
31 lines
742 B
TypeScript
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);
|
|
}
|