This commit is contained in:
ggyy
2026-08-07 09:21:09 +08:00
parent 08f9cfb20d
commit 3006f342c8
5 changed files with 83 additions and 4 deletions

50
.github/workflows/update-edgekey.yml vendored Normal file
View File

@@ -0,0 +1,50 @@
name: Update EdgeKey
on:
workflow_dispatch:
workflow_call:
permissions:
contents: write
concurrency:
group: update-edgekey
cancel-in-progress: false
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout instance repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Sync from upstream
shell: bash
run: |
set -euo pipefail
# Keep instance-specific Cloudflare bindings and compatibility flags.
if [ -f wrangler.jsonc ]; then
cp wrangler.jsonc "$RUNNER_TEMP/wrangler.current.jsonc"
fi
git fetch https://github.com/34892002/edgeKey.git main
git reset --hard FETCH_HEAD
if [ -f "$RUNNER_TEMP/wrangler.current.jsonc" ]; then
cp "$RUNNER_TEMP/wrangler.current.jsonc" wrangler.jsonc
fi
git config user.name "EdgeKey Updater"
git config user.email "actions@github.com"
if git diff --quiet; then
echo "EdgeKey is already up to date."
else
git add -A
git commit -m "Update EdgeKey from upstream"
fi
git push --force-with-lease origin "HEAD:${GITHUB_REF_NAME}"

View File

@@ -1,5 +1,16 @@
# Change Log
## v1.5.4 (2026-08-07)
### Bug Fixes
- **payment:** 修复 EdgeKey 与同一 Cloudflare 账号下的 HashPay Worker 通信时被 `error code: 1042` 拦截的问题。
- **payment:** HashPay 网关返回非 JSON 响应时,记录 HTTP 状态、响应类型与响应摘要,便于排查上游或网络错误。
### Improvements
- **ci:** 新增可手动触发的 EdgeKey 上游同步工作流;升级时保留实例的 `wrangler.jsonc` 配置。
## v1.5.3 (2026-07-22)
### Improvements

View File

@@ -1,4 +1,4 @@
import { externalServiceError } from "../../lib/app-error";
import { externalServiceError, isAppError } from "../../lib/app-error";
import { logger } from "../../lib/logger";
import type { PaymentProviderAdapter, CreatePaymentInput, CreatePaymentResult, VerifyNotifyResult } from "./provider";
@@ -187,8 +187,26 @@ export function createHashpayAdapter(config: HashpayConfig): PaymentProviderAdap
},
body: requestBody,
});
json = (await response.json()) as HashpayResponse;
const responseText = await response.text();
try {
json = JSON.parse(responseText) as HashpayResponse;
} catch {
const responsePreview = responseText.replace(/\s+/g, " ").trim().slice(0, 300);
logger.warn("hashpay.invalid_response", {
status: response.status,
contentType: response.headers.get("content-type"),
responsePreview,
});
throw externalServiceError(
`HashPay 网关返回非 JSON 响应HTTP ${response.status}${responsePreview || "空响应"}`,
"HASHPAY_INVALID_RESPONSE"
);
}
} catch (err) {
if (isAppError(err)) {
throw err;
}
throw externalServiceError(
`HashPay 请求失败: ${err instanceof Error ? err.message : String(err)}`,
"HASHPAY_INVALID_RESPONSE"

View File

@@ -1,5 +1,5 @@
{
"version": "1.5.3",
"version": "1.5.4",
"scripts": {
"dev": "vike dev",
"build": "bun run db:generate && vike build",

View File

@@ -3,7 +3,7 @@
"name": "edge-key",
"compatibility_date": "2026-03-12",
"main": "virtual:photon:cloudflare:server-entry",
"compatibility_flags": ["nodejs_compat"],
"compatibility_flags": ["nodejs_compat", "global_fetch_strictly_public"],
"observability": {
"enabled": true,
"head_sampling_rate": 0.1