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 -
配置平台要求
为什么使用这个插件
标题:为什么使用这个插件这个插件提供了一个跨平台的API,同时保持原生平台安全性:
- iOS:Apple App Attest(
DeviceCheck) - Android:Google Play Integrity StandardAPI
- No custom client-side crypto scheme
- 后端检查的标准化输出
使用
使用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 | Capacitor |
token | string | 令牌用于验证 |
令牌在您的后端验证
后端要求后端要求
- 只有在服务器端验证时,才能有用。
- 客户端成功不应信任。
- 要求一次性挑战/负载值从您的后端。
token验证
, app 身份和后端逻辑中的重放保护。
继续从Getting Started
标题:继续从Getting Started如果您正在使用 Getting Started 来规划安全性和合规性,连接它与 使用@capgo/capacitor-app-attest 为native能力在使用@capgo/capacitor-app-attest 加密 加密 合规 为 Compliance 的实现细节 Capgo 安全扫描器 为 Capgo 安全扫描器中的产品工作流程 Capgo 安全 为 Capgo 安全中的产品工作流程