hotfix for cf deploy error #5168

This commit is contained in:
lloydzhou
2024-08-02 15:55:26 +08:00
parent dfc36e5210
commit 753bf3b924
4 changed files with 22 additions and 5 deletions

View File

@@ -43,7 +43,7 @@ async function handle(
export const GET = handle;
export const POST = handle;
export const runtime = "nodejs";
export const runtime = "edge";
export const preferredRegion = [
"arn1",
"bom1",

View File

@@ -1,14 +1,17 @@
import { createHash, createHmac } from "node:crypto";
import hash from "hash.js";
// 使用 SHA-256 和 secret 进行 HMAC 加密
function sha256(message: any, secret = "", encoding?: string) {
return createHmac("sha256", secret)
return hash
.hmac(hash.sha256 as any, secret)
.update(message)
.digest(encoding as any);
}
// 使用 SHA-256 进行哈希
function getHash(message: any, encoding = "hex") {
return createHash("sha256")
return hash
.sha256()
.update(message)
.digest(encoding as any);
}