跳过内容

Getting Started

GitHub

您可以使用我们的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.

如果您更喜欢手动设置,请运行以下命令安装插件,并按照以下平台特定的说明进行操作:

  1. 安装包

    终端窗口
    bun add @capgo/capacitor-app-attest
  2. 同步本机项目

    终端窗口
    bunx cap sync
  3. 配置平台要求

    • 完成 iOS 设置 为 App Attest 能力和后端验证流程而设立。
    • Complete Android 设置 为 Play Integrity Standard 和后端验证流程而设立。

这个插件提供了一个跨平台的 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-attestgoogle-play-integrity-standard
keyIdstring用于证明的关键/提供者句柄
tokenstring用于在您的后端验证的令牌

后端要求

后端要求

只有在服务器端验证时,证明才有用。

  • 永远不要相信客户端成功。
  • 要求您的后端一次性挑战/载荷值。
  • 验证 token在后端逻辑中使用平台特定的身份验证、应用程序身份和重放保护。

使用以下平台特定的后端指南:

继续从 Getting Started

Getting Started 的下一步

如果您正在使用 Getting Started 来规划安全性和合规性,连接它到 使用 @capgo/capacitor-app-attest 为 native capability 在使用 @capgo/capacitor-app-attest 中 加密 为加密实现细节 合规 为合规实现细节 Capgo 安全扫描器 为 Capgo 安全扫描器中的产品工作流程, Capgo 安全 为 Capgo 安全中的产品工作流程,