본문 바로가기

시작하기

GitHub

AI-Assisted Setup으로 플러그인을 설치할 수 있습니다. 다음 명령어로 AI 도구에 Capgo 스킬을 추가하세요:

터미널 창
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

그런 다음 아래 프롬프트를 사용하세요:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-app-attest` plugin in my project.

수동 설정을 선호한다면, 다음 명령어를 실행하여 플러그인을 설치하고 아래의 플랫폼별 지침을 따르세요:

  1. 패키지 설치

    터미널 창
    bun add @capgo/capacitor-app-attest
  2. 네이티브 프로젝트 동기화

    터미널 창
    bunx cap sync
  3. 플랫폼 요구 사항 설정

    • 전체 iOS 설정 App Attest 기능 및 백엔드 검증 플로우를 위해.
    • 전체 Android 설정 Play Integrity Standard 및 백엔드 검증 플로우를 위해.
import { AppAttest } from '@capgo/capacitor-app-attest';
const support = await AppAttest.isSupported();
if (!support.isSupported) throw new Error('Attestation unavailable');
const prepared = await AppAttest.prepare();
const attestation = await AppAttest.createAttestation({
keyId: prepared.keyId,
challenge: serverNonce,
});
await sendAttestationToBackend(attestation);
const assertion = await AppAttest.createAssertion({
keyId: storedKeyId,
payload: requestHash,
});

자주 하는 실수

“흔한 실수” 섹션
  • 백엔드 검증 필수: 기기 내의 attestation blob만 믿지 말고, 반드시 서버에서 검증하세요.
  • Play Integrity 프로젝트 번호: Android Standard API는 README에 있는 Google Cloud 프로젝트 번호가 필요합니다.
  • 키 저장: 사용 storeKeyId() 로그아웃할 때 삭제해 오래된 키가 남지 않도록 하세요.

이 플러그인을 사용하는 이유

“이 플러그인을 사용하는 이유” 섹션

이 플러그인은 네이티브 플랫폼 보안을 유지하면서 단일 크로스플랫폼 API를 제공합니다:

  • iOS: Apple App Attest (DeviceCheck)
  • Android: Google Play Integrity Standard API
  • 커스텀 클라이언트 측 암호화 방식 불필요
  • 백엔드 검증을 위한 정규화된 출력값
import { AppAttest } from '@capgo/capacitor-app-attest';
const support = await AppAttest.isSupported();
if (!support.isSupported) {
throw new Error(`Attestation not supported on ${support.platform}`);
}
const prepared = await AppAttest.prepare();
const registration = await AppAttest.createAttestation({
keyId: prepared.keyId,
challenge: 'backend-one-time-registration-challenge',
});
const assertion = await AppAttest.createAssertion({
keyId: prepared.keyId,
payload: 'backend-one-time-request-payload',
});
console.log(registration.platform, registration.format, registration.token);
console.log(assertion.platform, assertion.format, assertion.token);

createAttestation() 및 createAssertion() iOS와 Android에서 동일한 키 필드를 반환합니다:

필드유형설명
platform'ios' | 'android' | 'web'토큰을 생성한 네이티브 플랫폼
formatAttestationFormatapple-app-attest 또는 google-play-integrity-standard
keyIdstring어테스테이션에 사용되는 키/프로바이더 핸들
tokenstring백엔드에서 검증할 토큰

Attestation은 서버 측에서 검증할 때만 유용합니다.

  • 클라이언트만 성공했다고 신뢰하지 마세요.
  • 백엔드에서 일회용 challenge/payload 값을 받도록 하세요.
  • 검증 token, 앱 식별 및 재전송 방지를 백엔드 로직에서 검증하세요.

플랫폼별 백엔드 가이드를 참고하세요:

사용 중이라면 시작하기 보안 및 컴플라이언스 계획을 세우려면, 다음 항목과 연결하세요: @capgo/capacitor-app-attest 사용하기 @capgo/capacitor-app-attest 사용 시 네이티브 기능을 위해, 암호화 암호화 구현 상세 정보: 컴플라이언스 컴플라이언스 구현 상세 정보: Capgo 보안 스캐너 Capgo Security Scanner에서 제품 워크플로우는, 그리고 Capgo 보안 Capgo Security의 제품 워크플로를 위해.