Official TypeScript SDK for SEcMS — type-safe, tree-shakable, auto-retry, sandbox-ready.
npm i @secms/sdk
# or pnpm add @secms/sdk · yarn add @secms/sdk
import { SecmsClient } from '@secms/sdk';
const client = new SecmsClient({
baseUrl: 'https://secms.tech/api',
idToken: process.env.SECMS_TOKEN!,
});
const projects = await client.projects.list();
console.log(projects);
모든 응답 타입 정의. IDE 자동완성 + tsc 빌드 시 검증.
429 / 5xx 자동 지수 백오프. Retry-After 헤더 존중.
ESM + CJS 듀얼 빌드. 사용하지 않는 리소스는 번들 제외.
AbortController 기반 타임아웃 (기본 30s). 데드락 방지.
baseUrl: 'https://secms.tech/api/sandbox' 으로 즉시 시도.
client.projects.*, client.webhooks.*, client.system.*
| 메서드 | 설명 | 반환 |
|---|---|---|
list({summary?}) | 전체 프로젝트 목록 | Project[] |
get(id) | 단건 조회 | Project |
create(input) | atomic 생성 (cables/nodes 본문 포함) | Project |
update(id, input) | CAS 업데이트 (expectedUpdatedAt 필수) | Project |
delete(id) | 삭제 | void |
| 메서드 | 설명 |
|---|---|
list() | 본인 webhooks + supported_events |
create({url, events, secret?}) | 등록 (HMAC secret 자동 생성) |
| 메서드 | 설명 |
|---|---|
status() | D1/R2/api health + uptime_pct_30d |
openapi() | OpenAPI 3.0 spec |
import { SecmsApiError } from '@secms/sdk';
try {
await client.projects.get('non-existent');
} catch (err) {
if (err instanceof SecmsApiError) {
console.error(err.code, err.status, err.message);
// err.code: 'PROJECT_NOT_FOUND'
// err.status: 404
// err.detail:
}
}
const sandbox = new SecmsClient({
baseUrl: 'https://secms.tech/api/sandbox',
idToken: 'sandbox', // any string works
});
const projects = await sandbox.projects.list();
// Returns 3 mock projects — no real data touched.
// Server-side (Node / Deno / CF Worker)
import { verifyWebhook } from '@secms/sdk/webhook';
app.post('/secms-hook', async (req, res) => {
const body = await req.text();
const sig = req.headers['x-secms-signature'];
const ok = await verifyWebhook(body, sig, process.env.SECMS_HOOK_SECRET!);
if (!ok) return res.status(401).send('Invalid signature');
// ... process payload
});
| 옵션 | 기본값 | 설명 |
|---|---|---|
baseUrl | https://secms.tech/api | API 엔드포인트 |
idToken | (필수) | Firebase ID Token |
fetch | globalThis.fetch | fetch 폴리필 |
timeoutMs | 30000 | 요청 타임아웃 |
retries | 3 | 자동 재시도 횟수 |
npm: @secms/sdk · GitHub: private · License: Commercial · Contact: [email protected]