From d59d280cb64e97378ced0a3280aa325e4e759dd0 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 27 Mar 2025 14:50:41 -0700 Subject: [PATCH] Fix missing crypto module required by older versions of Node. --- src/bin/server.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bin/server.ts b/src/bin/server.ts index d999ce9..7ae3bb4 100755 --- a/src/bin/server.ts +++ b/src/bin/server.ts @@ -2,9 +2,10 @@ //! SPDX-FileCopyrightText: 2025 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later -import { readFile, unlink, writeFile } from 'node:fs/promises' import { launch, Browser, Page } from 'puppeteer' +import { subtle } from 'node:crypto' import { lookup } from 'node:dns/promises' +import { readFile, unlink, writeFile } from 'node:fs/promises' import * as http from 'node:http' import { hostname } from 'node:os' import { join } from 'node:path' @@ -162,7 +163,7 @@ await page.waitForFunction(async (): Promise => { }) const src = `${NanoPow};window.NanoPow=NanoPow;` -const hash = await crypto.subtle.digest('SHA-256', Buffer.from(src)) +const hash = await subtle.digest('SHA-256', Buffer.from(src)) const enc = `sha256-${Buffer.from(hash).toString('base64')}` await page.setContent(` -- 2.34.1