From 4946c9f2be07f7414330846340da9df491613126 Mon Sep 17 00:00:00 2001 From: xiaomoziyi <823346486@qq.com> Date: Sat, 11 Apr 2026 12:19:44 +0800 Subject: [PATCH 1/2] feat(cloudflare): respect explicit APP_PID for umbrella-registered instances When an instance has been pre-registered out-of-band with an umbrella PID (e.g. staging-aigne-hub-media-kit, which shares the Payment Kit umbrella SK+PSK), auto-registration would otherwise overwrite the canonical PID with a fresh SK-derived DID on first request. Respect an explicit APP_PID binding in ensureRegistered and short-circuit before calling registerApp, so the canonical PID is preserved. Co-Authored-By: Claude Opus 4.6 (1M context) --- cloudflare/src/worker.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cloudflare/src/worker.ts b/cloudflare/src/worker.ts index bac89fc..fde06cd 100644 --- a/cloudflare/src/worker.ts +++ b/cloudflare/src/worker.ts @@ -95,8 +95,15 @@ let registeredInstanceDid: string | null = null; async function ensureRegistered(env: Env): Promise { if (registeredInstanceDid) return registeredInstanceDid; + // Explicit APP_PID wins — caller has already registered the instance out-of-band + // (e.g. staging-aigne-hub where the umbrella PID is pre-registered with SK+PSK). + // Skip auto-registration so we don't overwrite the canonical PID with the SK-derived DID. + if (env.APP_PID) { + registeredInstanceDid = env.APP_PID; + return registeredInstanceDid; + } if (!env.AUTH_SERVICE || !env.APP_SK) { - return env.APP_PID || ''; + return ''; } try { const result = await env.AUTH_SERVICE.registerApp({ From ec91c26175d7d4e892f5b33f0101a18a98c8f6be Mon Sep 17 00:00:00 2001 From: xiaomoziyi <823346486@qq.com> Date: Tue, 14 Apr 2026 17:01:02 +0800 Subject: [PATCH 2/2] ci: staging aigne hub --- cloudflare/wrangler.staging.toml | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 cloudflare/wrangler.staging.toml diff --git a/cloudflare/wrangler.staging.toml b/cloudflare/wrangler.staging.toml new file mode 100644 index 0000000..e2256e7 --- /dev/null +++ b/cloudflare/wrangler.staging.toml @@ -0,0 +1,46 @@ +name = "staging-aigne-hub-media-kit" +main = "src/worker.ts" +compatibility_date = "2024-12-01" +compatibility_flags = ["nodejs_compat"] + +[assets] +directory = "./public" +not_found_handling = "none" +html_handling = "none" +binding = "ASSETS" + +[vars] +ENVIRONMENT = "staging" +APP_NAME = "AIGNE Hub Media Kit (staging)" +APP_PID = "zNKWm5HBgaTLptTZBzjHo6PPFAp8X3n8pabY" +APP_PREFIX = "/image-bin" +MAX_UPLOAD_SIZE = "500MB" +ALLOWED_FILE_TYPES = ".jpeg,.png,.gif,.svg,.webp,.bmp,.ico,.mp4,.mov,.webm" +USE_AI_IMAGE = "false" +AIGNE_HUB_URL = "https://hub.aigne.io" + +# Service Binding to DID Connect Auth Worker — staging blocklet-service +[[services]] +binding = "AUTH_SERVICE" +service = "blocklet-service-staging" +entrypoint = "BlockletServiceRPC" + +[[r2_buckets]] +binding = "R2_UPLOADS" +bucket_name = "staging-aigne-hub-media-kit" + +[[d1_databases]] +binding = "DB" +database_name = "staging-aigne-hub-media-kit" +database_id = "92773574-63d9-4ffa-a065-4ff5583b6289" +migrations_dir = "migrations" + +[triggers] +crons = ["0 * * * *"] + +# Secrets (already set on the deployed Worker; re-set only if rotated): +# APP_SK — 64-byte hex; same umbrella SK as Payment Kit +# CF_ACCOUNT_ID — Cloudflare account ID +# R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, R2_ORIGIN_DOMAIN (if using S3-compat) +# UNSPLASH_KEY, UNSPLASH_SECRET +# AIGNE_HUB_API_KEY