]> zoso.dev Git - nano-pow.git/commitdiff
Fix missing crypto module required by older versions of Node.
authorChris Duncan <chris@zoso.dev>
Thu, 27 Mar 2025 21:50:41 +0000 (14:50 -0700)
committerChris Duncan <chris@zoso.dev>
Thu, 27 Mar 2025 21:50:41 +0000 (14:50 -0700)
src/bin/server.ts

index d999ce90fd468430336fe67c01c67a1d1e935f4b..7ae3bb497085d9cda015051d74ff18c7df4c1190 100755 (executable)
@@ -2,9 +2,10 @@
 //! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@zoso.dev>
 //! 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<GPUAdapter | null> => {
 })
 
 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(`