@secms/sdk v0.1.0 · BETA

Official TypeScript SDK for SEcMS — type-safe, tree-shakable, auto-retry, sandbox-ready.

30초 시작

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);

Features

Type-safe

모든 응답 타입 정의. IDE 자동완성 + tsc 빌드 시 검증.

Auto-retry

429 / 5xx 자동 지수 백오프. Retry-After 헤더 존중.

Tree-shakable

ESM + CJS 듀얼 빌드. 사용하지 않는 리소스는 번들 제외.

️ Timeout

AbortController 기반 타임아웃 (기본 30s). 데드락 방지.

Sandbox

baseUrl: 'https://secms.tech/api/sandbox' 으로 즉시 시도.

Resource Pattern

client.projects.*, client.webhooks.*, client.system.*

Resource Reference

client.projects

메서드설명반환
list({summary?})전체 프로젝트 목록Project[]
get(id)단건 조회Project
create(input)atomic 생성 (cables/nodes 본문 포함)Project
update(id, input)CAS 업데이트 (expectedUpdatedAt 필수)Project
delete(id)삭제void

client.webhooks

메서드설명
list()본인 webhooks + supported_events
create({url, events, secret?})등록 (HMAC secret 자동 생성)

client.system

메서드설명
status()D1/R2/api health + uptime_pct_30d
openapi()OpenAPI 3.0 spec

Error Handling

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: 
  }
}

Sandbox Mode (No Auth)

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.

HMAC Webhook Verification

// 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
});

Configuration

옵션기본값설명
baseUrlhttps://secms.tech/apiAPI 엔드포인트
idToken(필수)Firebase ID Token
fetchglobalThis.fetchfetch 폴리필
timeoutMs30000요청 타임아웃
retries3자동 재시도 횟수

Resources

npm: @secms/sdk · GitHub: private · License: Commercial · Contact: [email protected]