跳过内容

Getting Started

GitHub
  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 自动配置钩子

什么样的同步补丁为你

标题:什么样的同步补丁为你

当你运行 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, 和 双因素认证 为实现细节在 双因素认证