feat(recipes): auth recipe help_url 一律必填(不分冷熱門)
每個 required_secret 必須有 help_url(官方文件連結 http(s)://),POST /auth-recipes 驗證缺則 400。讓 AI/使用者設定 credential 時直接讀官方來源,不必猜/不會搜錯。 薄殼原則:驗證在 API,CLI/MCP 等介面 push auth recipe 自動受約束。 種子 23/23 已含 help_url。SDD: auth-recipe.md「help_url 一律必填」。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -209,6 +209,17 @@ recipesRouter.post('/auth-recipes', async (c) => {
|
|||||||
if (!body.required_secrets?.length) return c.json({ success: false, error: 'required_secrets 必填' }, 400);
|
if (!body.required_secrets?.length) return c.json({ success: false, error: 'required_secrets 必填' }, 400);
|
||||||
if (!body.inject) return c.json({ success: false, error: 'inject 必填' }, 400);
|
if (!body.inject) return c.json({ success: false, error: 'inject 必填' }, 400);
|
||||||
|
|
||||||
|
// help_url 一律必填(不分冷熱門服務):每個 secret 都要留官方文件連結,
|
||||||
|
// 讓 AI/使用者不必猜該去哪設定、也不會搜到錯誤來源(壓測 §recipe 設定說明)。
|
||||||
|
const missingHelp = body.required_secrets.filter(s => !s.help_url || !/^https?:\/\//.test(s.help_url));
|
||||||
|
if (missingHelp.length > 0) {
|
||||||
|
return c.json({
|
||||||
|
success: false,
|
||||||
|
error: `每個 required_secret 必須有 help_url(官方文件連結,http(s)://)。缺:${missingHelp.map(s => s.key).join(', ')}`,
|
||||||
|
requires: 'help_url',
|
||||||
|
}, 400);
|
||||||
|
}
|
||||||
|
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const existing = await c.env.RECIPES.get(`auth_recipe:${service}`, 'json') as AuthRecipeDefinition | null;
|
const existing = await c.env.RECIPES.get(`auth_recipe:${service}`, 'json') as AuthRecipeDefinition | null;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user