Zum Inhalt springen

Einstieg

  1. Installieren Sie das Paket

    Terminal-Fenster
    bun add @capgo/capacitor-passkey
  2. Synchronisieren Sie native Projekte

    Terminal-Fenster
    bunx cap sync
  3. Fügen Sie die Plugin-Konfiguration hinzu

    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. Installieren Sie den Shim während des Bootstraps

    import { CapacitorPasskey } from '@capgo/capacitor-passkey';
    await CapacitorPasskey.autoShimWebAuthn();
  5. Halten Sie Ihren normalen WebAuthn-Flow aufrecht

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

Was die Plugin-Konfiguration tut

Was die Plugin-Konfiguration tut

Die Konfiguration wird aus plugins.CapacitorPasskey in capacitor.config.*.

  • origin: primäre HTTPS-Vertrauenspartner-URL, die vom Shim und direkt verwendet wird API
  • domains: zusätzliche Vertrauenspartner-Hostnamen, die in die native Konfiguration während des Synchronisierens eingepatcht werden
  • autoShim: defaults to true und kontrolliert die native cap sync Auto-Konfigurations-Hook

Wenn Sie das Kommando ausführen bunx cap sync, aktualisiert der Plugin die generierte native Host-Projekt:

  • iOS: Domänenzugehörigkeiten und Xcode-Zugriffsrechte verbinden, wenn erforderlich
  • Android: asset_statements Metadaten und die generierte Ressource, die vom Manifest verwendet wird

Der Hook veröffentlicht Ihre Website-Trust-Dateien nicht für Sie. Sie müssen sie noch selbst hosten:

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

Plattform-Anleitungen

Plattform-Anleitungen