@designbasekorea/figma-license-core
v0.1.0
Published
Figma plugin license core and status manager for reusable license workflows
Downloads
27
Readme
@designbasekorea/figma-license-core
Figma 플러그인의 라이선스 검증/비활성화/상태 동기화를 공통으로 처리하는 패키지입니다.
핵심 포인트
LicenseCore: 순수 로직 (상태, 검증, 에러 매핑, 활성화 제한 판별)FigmaStorageAdapter/FigmaNotifierAdapter: Figma 전용 어댑터FigmaLicenseStatusManager:initialize,verify-license,deactivate-license메시지 처리LicenseConfig주입 방식으로 플러그인별 하드코딩 제거
빠른 시작
import { createFigmaLicenseStatusManager } from '@designbasekorea/figma-license-core';
const statusManager = createFigmaLicenseStatusManager({
config: {
productId: 'my-plugin',
endpoint: 'https://api.example.com/license/verify',
deactivateEndpoint: 'https://api.example.com/license/deactivate',
instanceName: figma.root?.name || 'figma-plugin',
usageLimit: 20,
storagePrefix: 'my-plugin-license',
},
});
statusManager.bindToOnMessage(async (msg) => {
if ((msg as { type?: string }).type === 'process') {
// 기존 플러그인 로직
}
});
await statusManager.initialize();UI 이벤트 계약
UI -> Main
initializeverify-license(licenseKey포함)deactivate-license
Main -> UI
update-plugin-statuslicense-verification-resultlicense-deactivation-result
에러는 errorCode 값으로 전달됩니다.
ACTIVATION_LIMIT_REACHEDINVALID_LICENSEPRODUCT_MISMATCHNETWORK_ERRORSTORAGE_ERRORSERVER_ERRORUNKNOWN_ERROR
