跳过内容

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-passkey` plugin in my project.

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

  1. 安装包

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

    终端窗口
    bunx cap sync
  3. 添加插件配置

    import type { CapacitorConfig } from '@capacitor/cli';
    const config: CapacitorConfig = {
    appId: 'app.capgo.passkey.example',
    appName: 'My App',
    webDir: 'dist',
    plugins: {
    CapacitorPasskey: {
    origin: 'https://signin.example.com',
    autoShim: true,
    domains: ['signin.example.com'],
    },
    },
    };
    export default config;
  4. 在引导期间安装 shim

    import { CapacitorPasskey } from '@capgo/capacitor-passkey';
    await CapacitorPasskey.autoShimWebAuthn();
  5. 保持正常的 WebAuthn 流程

    const registration = await navigator.credentials.create({
    publicKey: registrationOptions,
    });
    const authentication = await navigator.credentials.get({
    publicKey: requestOptions,
    });

插件配置的作用

插件配置的作用

配置从 plugins.CapacitorPasskeycapacitor.config.*.

  • origin: primary HTTPS relying-party origin used by the shim and direct API
  • domains:用于补充的依赖方主机名,用于在同步期间修补本地配置
  • autoShim:默认值 true 并控制本地 cap sync 自动配置钩子

Sync 为你修补了什么

插件配置的作用

当您运行时 bunx cap sync,插件会更新生成的本机主机项目:

  • iOS:需要时关联域名特权和Xcode特权编程
  • Android: asset_statements 元数据和由清单使用的生成资源

该钩子不会为您发布网站信任文件。您仍然需要托管:

  • https://your-domain/.well-known/apple-app-site-association
  • https://your-domain/.well-known/assetlinks.json

从 Getting Started 开始继续

标题为“从 Getting Started 开始继续”

如果您正在使用 Getting Started 来规划认证和账户流程,连接它到 使用 @capgo/capacitor-passkey 为原生能力在使用 @capgo/capacitor-passkey 中 @capgo/capacitor-social-login 为实现细节在 @capgo/capacitor-social-login 中 @capgo/capacitor-passkey 对于 @capgo/capacitor-passkey 的实现细节 @capgo/capacitor-native-biometric 对于 @capgo/capacitor-native-biometric 的实现细节, 双因素认证 对于双因素认证的实现细节。