跳过内容

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能力和后端验证流程
    • 完成 Android设置 为Play Integrity Standard和后端验证流程

为什么使用这个插件

标题:为什么使用这个插件

这个插件提供了一个跨平台的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'原生平台生成令牌
formatAttestationFormatapple-app-attestgoogle-play-integrity-standard
keyIdstringCapacitor
tokenstring令牌用于验证

令牌在您的后端验证

后端要求

后端要求

  • 只有在服务器端验证时,才能有用。
  • 客户端成功不应信任。
  • 要求一次性挑战/负载值从您的后端。 token验证

, app 身份和后端逻辑中的重放保护。

继续从Getting Started

标题:继续从Getting Started

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