Skip to Content
문서SDKJavaScript / TypeScript개요·Quickstart

JavaScript / TypeScript SDK

@deplite/sdk는 Node.js 환경(서버·CLI·Electron·CI)에서 Deplite를 호출하거나, 내 앱을 Deplite의 작업 노드로 만드는 공식 SDK예요.

설치

npm install @deplite/sdk

Node.js 20+ 환경에서만 사용 가능해요.

어떤 모드로 시작할까

모드언제 쓰나시작
External내 앱·서버·CI가 Deplite를 호출API 토큰 발급 → new Deplite({ apiToken })
Embedded내 앱·기기가 Deplite의 작업 노드1회용 설치 코드 → Deplite.enroll(...)

두 모드의 자세한 비교는 인증 모드를 참고해주세요.

External — Deplite 호출하기

대시보드에서 API 토큰을 발급한 뒤, 환경변수로 주입하고 시작해요.

import { Deplite } from '@deplite/sdk' const deplite = new Deplite({ apiToken: process.env.DEPLITE_API_TOKEN! }) // 트리거 실행 const job = await deplite.triggers.run({ triggerId: process.env.TRIGGER_ID!, params: { ref: 'main' }, }) // 파일 업로드 const file = await deplite.files.upload({ file: { path: './build/app.apk' }, })

토큰은 발급 직후 1회만 노출되므로 별도의 저장 처리가 필요해요.

Embedded — 내 앱이 작업 노드 되기

대시보드에서 1회용 설치 코드를 발급한 뒤, 첫 실행에서 enroll → 결과를 안전 저장소에 보관 → 이후 실행에서는 그 자격으로 Agent 부팅이에요.

import { Deplite, DepliteAgent } from '@deplite/sdk' // 1) 1회만 — enroll 후 결과를 영구 저장 const enrollment = await Deplite.enroll({ installCode: process.env.INSTALL_CODE!, name: 'kiosk-seoul-01', }) await secureStore.save(enrollment) // identity + privateKey // 2) 매 실행마다 — 저장된 자격으로 부팅 const stored = await secureStore.load() const agent = new DepliteAgent({ identity: stored.identity, privateKey: stored.privateKey, }) for await (const event of agent.events()) { if (event.type === 'deploy') { await runJob(event.payload) await agent.jobs.reportResult({ jobId: event.payload.jobId, result: { status: 'success', exitCode: 0 }, }) } }

enroll()이 반환하는 privateKey(raw 32바이트)는 SDK가 저장하지 않으므로 암호화 후 저장하는 것을 추천드려요.
분실하면 재등록만이 답이에요.

관련 문서

최종 수정 일자: