touchid

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 5 Imported by: 0

README

touchid-go

Go wrapper for Apple's LocalAuthentication framework. Authenticate users with Touch ID on macOS.

Features

  • Context-aware - Full support for Go contexts with cancellation and timeouts
  • Policies - Support many authentication policies
  • Verbose errors - Distinct sentinel errors for precise error handling
  • Code generation - Policies and errors auto-generated from Apple headers

Installation

go get github.com/noamcohen97/touchid-go

Usage

package main

import (
    "context"
    "log"
    "time"

    "github.com/noamcohen97/touchid-go"
)

func main() {
    ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
    defer cancel()

    err := touchid.Authenticate(ctx, touchid.PolicyDeviceOwnerAuthentication, "Access your vault")
    if err != nil {
        log.Fatal(err)
    }
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAppCancel             = errors.New("app cancel")
	ErrAuthenticationFailed  = errors.New("authentication failed")
	ErrBiometryDisconnected  = errors.New("biometry disconnected")
	ErrBiometryLockout       = errors.New("biometry lockout")
	ErrBiometryNotAvailable  = errors.New("biometry not available")
	ErrBiometryNotEnrolled   = errors.New("biometry not enrolled")
	ErrBiometryNotPaired     = errors.New("biometry not paired")
	ErrCompanionNotAvailable = errors.New("companion not available")
	ErrInvalidContext        = errors.New("invalid context")
	ErrInvalidDimensions     = errors.New("invalid dimensions")
	ErrNotInteractive        = errors.New("not interactive")
	ErrPasscodeNotSet        = errors.New("passcode not set")
	ErrSystemCancel          = errors.New("system cancel")
	ErrUserCancel            = errors.New("user cancel")
	ErrUserFallback          = errors.New("user fallback")
)

Functions

func Authenticate

func Authenticate(ctx context.Context, policy Policy, reason string) error

Types

type Policy

type Policy C.int

Policy represents an LAPolicy value.

const (
	PolicyDeviceOwnerAuthentication                          Policy = C.LAPolicyDeviceOwnerAuthentication
	PolicyDeviceOwnerAuthenticationWithBiometrics            Policy = C.LAPolicyDeviceOwnerAuthenticationWithBiometrics
	PolicyDeviceOwnerAuthenticationWithBiometricsOrCompanion Policy = C.LAPolicyDeviceOwnerAuthenticationWithBiometricsOrCompanion
	PolicyDeviceOwnerAuthenticationWithBiometricsOrWatch     Policy = C.LAPolicyDeviceOwnerAuthenticationWithBiometricsOrWatch
	PolicyDeviceOwnerAuthenticationWithCompanion             Policy = C.LAPolicyDeviceOwnerAuthenticationWithCompanion
	PolicyDeviceOwnerAuthenticationWithWatch                 Policy = C.LAPolicyDeviceOwnerAuthenticationWithWatch
)

Directories

Path Synopsis
cmd
touchid command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL