Getting Started
复制一个包含安装步骤和该插件的完整 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辅助设置来安装插件。使用以下命令将Capgo技能添加到您的AI工具中:
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 -
配置平台要求
This plugin provides one cross-platform API while keeping native platform security:
- Android:Google Play Integrity Standard__CAPGO_KEEP_0__
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);统一响应形状
并在iOS和Android上返回相同的键字段:createAttestation() 字段 createAssertion() 类型
| 描述 | and return the same key fields on iOS and Android: | __CAPGO_KEEP_0__ |
|---|---|---|
platform | 'ios' | 'android' | 'web' | 原生平台生成的令牌 |
format | AttestationFormat | apple-app-attest 或 google-play-integrity-standard |
keyId | string | 用于证明的密钥/提供者句柄 |
token | string | 用于在您的后端验证的令牌 |
后端要求
标题:后端要求只有在服务器端验证时,证明才有用。
- 永远不要相信客户端成功的结果。
- 要求您的后端提供一次性挑战/载荷值。
- 在后端逻辑中验证
token在后端逻辑中验证应用标识和重放保护
使用平台特定的后端指南:
继续从 Getting Started
标题为“继续从 Getting Started”如果您正在使用 Getting Started 以规划安全性和合规性为目的,连接它到 使用 @capgo/capacitor-app-attest 为 Using @capgo/capacitor-app-attest 中的本机功能 加密 为加密的实现细节 合规性 关于 Compliance 的实现细节 Capgo 安全扫描器 关于 Capgo 安全扫描器的产品工作流程, 和 Capgo 安全 关于 Capgo 安全的产品工作流程, 和