Integration Guide¶
As a Zig Dependency¶
Add zig-ctap2 as a dependency in your build.zig.zon:
.dependencies = .{
.zig_ctap2 = .{
.url = "https://github.com/Jesssullivan/zig-ctap2/archive/refs/heads/main.tar.gz",
},
},
Then in build.zig:
const ctap2_dep = b.dependency("zig_ctap2", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("zig-ctap2", ctap2_dep.module("zig-ctap2"));
As a C Static Library¶
Build the library:
Link against zig-out/lib/libctap2.a and include include/ctap2.h:
#include "ctap2.h"
int main() {
int count = ctap2_device_count();
printf("Found %d FIDO2 devices\n", count);
return 0;
}
Compile:
Swift Integration (Xcode)¶
- Add zig-ctap2 as a git submodule or copy
libctap2.a+ctap2.hinto your project - Add
ctap2.hto your bridging header - Link
libctap2.ain your target's build settings - Add
IOKit.frameworkandCoreFoundation.frameworkto linked frameworks - Add USB entitlement to your
.entitlementsfile
import Foundation
let deviceCount = ctap2_device_count()
print("Found \(deviceCount) FIDO2 devices")
Git Submodule¶
WebView or Native App Integration¶
For WebView, browser-shell, or native app integrations, keep the responsibilities separate: zig-ctap2 handles external-authenticator CTAP2 USB HID operations through C FFI; the host application remains responsible for WebAuthn JSON, origin/RP policy, mediation UX, attestation policy, and credential persistence.