メインコンテンツへスキップ

スタートガイド

GitHub

AIアシストによるセットアップでプラグインをインストールできます。以下のコマンドを使用して、お使いの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 を1つ提供します:

  • 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バックエンドで検証するトークン

アテストーションはサーバーサイドで検証されて初めて意味を持ちます。

  • クライアント単体の成功にのみ依存しない。
  • バックエンドからワンタイムのチャレンジ/ペイロード値を要求する。
  • 確認 token、アプリのアイデンティティ、およびリプレイ攻撃対策をバックエンドロジックに実装する。

プラットフォーム固有のバックエンドガイドを使用する:

Getting Startedの続きを進める

「Getting Started からの続き」セクション

使用している場合 スタートガイド セキュリティとコンプライアンスを計画するには、これを以下と連携させてください @capgo/capacitor-app-attest の使用方法 「@capgo/capacitor-app-attest の使用」のネイティブ機能については、 暗号化 暗号化の実装詳細について コンプライアンス コンプライアンスの実装詳細について Capgo セキュリティスキャナー Capgo Security Scanner のプロダクトワークフローについては、 Capgo のセキュリティ Capgo Security におけるプロダクトワークフロー向けに。