#!/usr/bin/env node /** * Fmode 云资源(华为云 STS 部署) — 辅助脚本(零 npm 依赖,Node>=18 自带 fetch) * Copyright (c) 未来飞马 MPL-2.0 * * 用法:node index.mjs [jsonPayload] */ const BASE = "https://server.fmode.cn"; async function call(method, path, body, token) { const headers = { "content-type": "application/json" }; if (token) headers["authorization"] = "Bearer " + token; const res = await fetch(BASE + path, { method, headers, body: body ? JSON.stringify(body) : undefined, }); const text = await res.text(); // 脱敏输出:token/密钥不打印 const safe = text.replace(/(token|authorization|accessKey|secretKey|securityToken)["'\s:]+([^",}]+)/gi, "$1:***"); console.log(safe); return res; } const [action, raw] = process.argv.slice(2); let payload = {}; try { if (raw) payload = JSON.parse(raw); } catch { payload = { _raw: raw }; } // 示例端点: POST 取 STS {token, projectId} → accessKey/secretKey/securityToken/expiresAt/obsPath