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

スタートガイド

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 を提供します:

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

バックエンドの要件

「Backend requirement」セクション

アテステーションはサーバーサイドで検証して初めて意味を成します。

  • クライアント側のみの成功結果を信用しないでください。
  • バックエンドから1回限りのチャレンジ/ペイロード値を取得します。
  • 確認 token, アプリの識別情報、およびバックエンドロジックでのリプレイ攻撃対策を実装します。

プラットフォーム別のバックエンドガイドを参照してください:

Getting Startedの続きを進める

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

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