هذا هو العميل المرجعي لواجهة GhostDeploy Universal Node Hosting API، gds.api/1 (GDS-1 §10،
spec/api/openapi.yaml). يعمل على Node 18+ ويحتوي على دون تبعيات تشغيل. يستخدم فقط node:tls,
node:http و node:crypto.
نموذج الأمان
- HTTPS فقط، بشهادة مثبّتة. لا يستخدم العميل
https.request ولا يثق بأي جهة إصدار شهادات.
- يفتح اتصال TLS بنفسه باستخدام
tls.connect.
- عند
secureConnect يقارن قيمة SHA-256 لشهادة DER الخاصة بالنظير مع البصمة المثبّتة، في زمن ثابت.
- ولا يسلّم المقبس إلى
node:http (createConnection).
- لا تُكتب أي بايتات من الطلب قبل ذلك، بما في ذلك رمز bearer.
- عند عدم التطابق يطلق
FingerprintMismatchError. البصمة إلزامية، ولا يمكن تعطيل التحقق.
- لا وكيل، ولا وكيل مشترك. يحصل كل طلب على اتصال خاص به مثبّت من جديد.
- الأخطاء. تطلق أخطاء الخادم
APIError باستخدام .status و .code، وهو رمز gds.api/1. توجد 429 تُعاد محاولة الاستجابة مع تراجع تدريجي.
- التحقق من PoP.
verifyPop() يشغّل دائماً كل الفحوص، بما في ذلك توقيع ed25519. توفّر مكتبة التشفير المدمجة في Node خوارزمية ed25519.
الاستخدام
import { Client, verifyPop } from "@ghostdeploy/client";
const c = new Client({ baseUrl: "https://203.0.113.10:8790", fingerprint: "57dc07ba...dd3", token: "gd_<id>_<secret>" });
await c.capabilities(); // works without a token
await c.listInstances(); await c.getInstance("alice"); await c.status("alice"); await c.events("alice", 50);
await c.profiles(); await c.benchmark(); await c.offers(); await c.openapi();
const op = await c.stop("alice"); // start / restart / startSigners / backup / action(name, action)
await c.waitOperation(op, { timeoutMs: 300_000 });
await c.deploy({ name: "carol", profile: "cold-smartnode", chain_id: 20778 });
await c.deleteInstance("carol");
await c.smartnodeKeygen("alice", "v1");
const pkg = await c.smartnodePop("alice", "v1", "0xYourOwnerAddress");
verifyPop(pkg, { expectedOwner: "0xYourOwnerAddress", expectedChainId: 20778 }); // BEFORE signing
verifyPop يتحقق مما يلي:
- بيانات الاستدعاء هي بالضبط
0x01 || RLP([vote_pubkey, pop]). في حالة التدوير يكون
0x06 || RLP([rotated_id, vote_pubkey, pop]).
validator_id == sha256(vote_pubkey).
to هو سجل Smartnode.
- توقعات المالك والسلسلة والتكوين الاختيارية متطابقة.
- توقيع ed25519 على
sha256("PQAI-G4-POP-V1" || chainID[32] || genesis[32] || owner[20] || key[32]) صالح.
البناء والاختبار
cd sdk/typescript
npm install # dev only: typescript + @types/node
npm test # tsc, then node --test on dist/test/*.test.js
npm run test:src # Node 22.18+/23.6+: run the .ts sources directly (type stripping), no build step
تستخدم المصادر صيغة TypeScript القابلة للمحو فقط وتستورد مع امتدادات .ts . rewriteRelativeImportExtensions
يحوّل تلك الاستيرادات إلى .js في dist/.
test/integration.test.ts يبني sdk/testserver باستخدام go build ويشغّل الخادم الحقيقي internal/api على 127.0.0.1، بجذر مؤقت وبيان 20778 المضمّن. لا يلمس الشبكة ولا يشغّل أوامر نظام. يُتخطّى عند غياب Go. اضبط GHOSTDEPLOY_GO لاختيار سلسلة أدوات.