Update README and frontend files for improved clarity and functionality
- Added a note in the README about using Taskfile for project management. - Removed the crossOrigin attribute from the WebAssembly fetch request in verifier.ts for security compliance. - Refactored the wasm_exec.js file for consistency in string usage and improved readability. - Cleaned up whitespace in the SRI generation script to enhance code clarity.
This commit is contained in:
@@ -96,7 +96,7 @@ func processSourceFile(sourcePath string) error {
|
||||
}
|
||||
|
||||
updated := string(content)
|
||||
|
||||
|
||||
// We need a way to map the asset to the SRI. For verifier.ts, we know the assets.
|
||||
assets := map[string]string{
|
||||
"wasm_exec.js": "frontend/static/verifier/wasm_exec.js",
|
||||
@@ -113,14 +113,14 @@ func processSourceFile(sourcePath string) error {
|
||||
// Find the line that mentions the asset and update the NEXT integrity string
|
||||
assetEscaped := strings.ReplaceAll(assetName, ".", "\\.")
|
||||
assetPattern := regexp.MustCompile(`['"](/verifier/)?` + assetEscaped + `['"][\s\S]*?sha384-([^'"]+)`)
|
||||
|
||||
|
||||
matches := assetPattern.FindAllStringSubmatchIndex(updated, -1)
|
||||
// Process from end to start to not mess up indices
|
||||
for i := len(matches) - 1; i >= 0; i-- {
|
||||
match := matches[i]
|
||||
oldHashStart, oldHashEnd := match[4], match[5]
|
||||
oldHash := updated[oldHashStart:oldHashEnd]
|
||||
|
||||
|
||||
if oldHash != hash {
|
||||
updated = updated[:oldHashStart] + hash + updated[oldHashEnd:]
|
||||
fmt.Printf(" Updated SRI for %s in %s\n", assetName, sourcePath)
|
||||
|
||||
Reference in New Issue
Block a user