スタートガイド
インストール手順と、このプラグインの完全なMarkdownガイドを含むセットアッププロンプトをコピーします。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-app-attest`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/app-attest/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
インストール
「インストール」セクション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.手動セットアップを希望する場合は、以下のコマンドを実行してプラグインをインストールし、下記のプラットフォーム別の手順に従ってください:
-
パッケージをインストール
ターミナル bun add @capgo/capacitor-app-attest -
ネイティブプロジェクトを同期
ターミナル bunx cap sync -
プラットフォーム要件の設定
- 完了 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' | トークンを生成したネイティブプラットフォーム |
format | AttestationFormat | apple-app-attest または google-play-integrity-standard |
keyId | string | アテステーションに使用されるキー/プロバイダーハンドル |
token | string | バックエンドで検証するためのトークン |
バックエンドの要件
「Backend requirement」セクションアテステーションはサーバーサイドで検証して初めて意味を成します。
- クライアント側のみの成功結果を信用しないでください。
- バックエンドから1回限りのチャレンジ/ペイロード値を取得します。
- 確認
token, アプリの識別情報、およびバックエンドロジックでのリプレイ攻撃対策を実装します。
プラットフォーム別のバックエンドガイドを参照してください:
Getting Startedの続きを進める
「Getting Started からの続き」セクション使用している場合 スタートガイド セキュリティとコンプライアンスを計画するには、これを以下と連携させてください @capgo/capacitor-app-attest の使用方法 @capgo/capacitor-app-attest を使用してネイティブ機能を利用する場合: 暗号化 暗号化の実装詳細について コンプライアンス コンプライアンスの実装詳細について Capgo セキュリティスキャナー Capgo Security Scanner のプロダクトワークフローについては、 Capgo のセキュリティ Capgo Security におけるプロダクトワークフロー向けに。