# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.3.3] - 2026-07-25

### Fixed

- **The README stated the previous version.** The at-a-glance `Version` row is a static duplicate of
  `package.json.version`, so it drifted the moment the version was bumped — it shipped stale in eight of the
  fleet's packages at once. The row, and any native version string, now move with the release.

## [2.3.2] - 2026-07-25

> **Entry-point repair.** Every declared entry point of 2.3.1 fails to load under real Node
> resolution — `require()`, `import`, and the `./web` subpath all throw. This is a packaging fault, not
> a behaviour change: no exported signature moves. **These changes require a version bump before
> publishing.**

### Fixed

- **CommonJS entry was unloadable.** `main`/`exports["."].require` pointed at `dist/plugin.cjs.js` — a
  CommonJS bundle with a `.js` extension inside a `"type": "module"` package, which Node parses as ESM.
  Every `require('capacitor-biometric-authentication')` died with
  `exports is not defined in ES module scope`. The artifact is now emitted as `dist/plugin.cjs`, and
  `require()` returns all 7 exports.
- **ESM entry was unloadable.** The emitted `dist/esm/**` used extensionless relative specifiers, which
  Node ESM rejects, so `import 'capacitor-biometric-authentication'` threw `ERR_MODULE_NOT_FOUND`. All
  relative specifiers in `src/` now carry explicit `.js` extensions, and `tsconfig.json` moved to
  `module`/`moduleResolution: "NodeNext"` so the compiler rejects a regression.
- **The `./web` subpath resolved to a file that does not exist.** The rollup web build marked
  `./adapters/CapacitorAdapter` external, leaving `dist/web.js` importing `dist/adapters/CapacitorAdapter`,
  a path absent from the tarball. Only `@capacitor/core` stays external now; `dist/web.js` is
  self-contained.
- **Types were unusable under `moduleResolution: "NodeNext"`.** The shipped `.d.ts` files carried the
  same extensionless specifiers, producing six `TS2835` errors in any consumer with `skipLibCheck: false`.
- **`homepage` pointed at `https://biometric-auth.dev`, which does not resolve** — so npm's
  documentation link was dead. It now points at the package's docs site.
- **`bugs.url` pointed at a private repository's issue tracker**, a 404 for every user. Replaced with a
  reachable email address.

### Changed

- **`CHANGELOG.md` now ships in the package.** npm does not include it automatically and it was absent
  from the `files` allowlist, so no installed copy carried release history.
- **Source maps are no longer published** (24 `.map` files previously shipped), and the TypeScript
  `src/` tree was dropped from `files` — it was unreachable through the `exports` map. The tarball fell
  from 239 kB to 108 kB.
- **`README.md` renamed from `Readme.md`.** A `files` entry naming `README.md` resolves on macOS and
  misses on a case-sensitive filesystem.
- **`keywords` no longer claims `cordova`.** No Cordova adapter ships; loading one throws.
- Added `funding`, `sideEffects: false`, an `exports["./package.json"]` subpath, and a `typecheck`
  script.

### Known limitations

- `BiometryType` is still re-exported from the package root with `export type`, so it has no runtime
  value there. Fixing that adds a runtime export and therefore warrants a minor bump — see
  `docs/REPORTED-ISSUES.md` (ISSUE-001). Compare against the string values in the meantime.
- Native (iOS/Android) server verification is still unwired — see 2.3.1 below.

## [2.3.1] - 2026-05-27

> **Patch — iOS build fix.** Fixes a missing import that stopped the iOS plugin from compiling in a
> consuming Xcode build. No API changes; web and Android behavior are unchanged.

### Fixed

- **iOS:** added the missing `import UIKit` in `BiometricAuthPlugin.swift`. The device-fingerprint
  helper references `UIScreen` and `UIDevice` (UIKit symbols) that were not in scope, so the 2.3.0
  plugin failed to compile under Xcode (`cannot find 'UIScreen'/'UIDevice' in scope`). This is a pure
  compile fix — no behavior or API change.

### Known limitations (carried over from 2.3.0)

- Native (iOS/Android) WebAuthn assertions are not yet wired for end-to-end **server** verification:
  the Capacitor bridge does not forward `webAuthnOptions` (the server challenge / stored credential id)
  down to native, and the native `register()` ceremony is not exposed on the JS surface. **Web**
  server-verification works today; native server-verification is planned for **2.4.0**.

## [2.3.0] - 2026-05-26

> **Security release.** Fixes issues where web authentication could appear to succeed without a
> server-verifiable proof of identity, and where native crypto failures could surface placeholder
> signatures. **Versions `< 2.3.0` are deprecated.** Upgrade, and verify `result.webAuthnResponse`
> on your server (e.g. `webauthn-server-buildkit`).

### Security

- **Web:** `authenticate()` now returns the real WebAuthn assertion/attestation in
  `result.webAuthnResponse` (standard JSON, verifiable by `webauthn-server-buildkit`). A successful
  client ceremony is explicitly NOT proof of identity — your server MUST verify it against the
  challenge it issued.
- **Web:** enforces a secure context (HTTPS/localhost) → `INSECURE_CONTEXT`; defaults
  `userVerification` to `required`; propagates real WebAuthn errors instead of swallowing them.
- **Android:** binds the Keystore signing key to `BiometricPrompt` via a `CryptoObject` and signs
  inside `onAuthenticationSucceeded`; emits real CBOR `none` attestation; derives the user-verified
  flag from the actual authentication type; encrypts the session token with a Keystore AES-GCM key.
  All placeholder/fake-signature fallbacks removed — crypto failures now return honest errors.
- **iOS:** gates the Secure-Enclave signing key with biometrics (`.biometryCurrentSet`); stores the
  session token + sign count in the Keychain (no `UserDefaults`); persists lockout state;
  `deleteCredentials` now also removes signing keys. Placeholder-signature fallbacks removed.
- Removed dead security-theater code that shipped a hardcoded encryption key
  (`SessionManager`/`CredentialManager`) and an unused web-plugin class.
- Error `details` are sanitized to `{ name }` (no raw error objects / stack traces).

### Added

- `BiometricAuthResult.webAuthnResponse` + `webAuthnCeremony` (`'registration' | 'authentication'`).
- Error codes `INSECURE_CONTEXT`, `NO_CREDENTIALS`, `USER_FALLBACK`, `PASSCODE_NOT_SET`;
  `BiometryType.OPTIC_ID` (Apple Vision Pro).
- Internal debug-gated logger (`configure({ debug: true })`).

### Changed

- Updated all dev dependencies to latest stable (TypeScript 6, ESLint 10, jsdom 29, Capacitor 8.3.x,
  Vitest 4.1.x, Rollup 4.60.x). `peerDependencies.@capacitor/core` stays `^8.0.1` (no breaking change
  for consumers).
- `engines.node` lowered from `>=24.13.0` to `>=18.0.0`.
- Canonicalized error codes — `BIOMETRIC_UNAVAILABLE` / `LOCKOUT` / `UNKNOWN_ERROR` are now deprecated
  aliases of `NOT_AVAILABLE` / `LOCKED_OUT` / `UNKNOWN`.
- Modernized the TypeScript build for TS 6 (`moduleResolution: bundler`).

### Removed

- Dead modules `src/web.ts`, `src/utils/session.ts`, `src/utils/webauthn.ts`, legacy
  `src/definitions.ts`, and the ambiguous `toArrayBuffer` helper (none were part of the public API).

### Documentation

- Corrected the README and all `docs/` to the real public API (the `BiometricAuth` default export,
  returned-not-thrown results, canonical error codes, seconds-based `sessionDuration`) with honest
  client-vs-server verification framing throughout.

### Notes

- The native Android/iOS changes were written by inspection and require on-device verification by the
  maintainer before relying on them in production.

## [2.2.0] - 2026-01-21

### Added

- AI Integration Guide (`AI-INTEGRATION-GUIDE.md`) for AI development agents
- Complete full-stack integration examples with `webauthn-server-buildkit` backend

### Changed

- Updated all dependencies to latest versions
- Updated Capacitor peer dependency to ^8.0.1
- Updated ESLint configuration to use `typescript-eslint` (removed deprecated `@eslint/js`)
- Fixed package.json exports order (types first for proper TypeScript resolution)
- Updated minimum iOS version to iOS 13.0 in documentation
- Updated Capacitor version references from 7.x to 8.x

### Documentation

- Added prominent AI Integration Guide link at top of README
- Updated CLAUDE.md with current version and dates
- Added link to backend package for complete authentication system

## [2.1.4] - 2025-12-12

### Fixed

- **CRITICAL Android/iOS Fix**: Finally resolved "BiometricAuth.then() is not implemented on android" error
  - **Root Cause**: On native platforms, calling `registerPlugin('BiometricAuth')` creates a SECOND proxy that conflicts with the auto-registered native plugin, causing `.then()` interception errors
  - **CapacitorAdapter**: Now uses `Capacitor.Plugins.BiometricAuth` on native platforms (already registered) instead of calling `registerPlugin()` again
  - **CapacitorAdapter**: Only calls `registerPlugin()` on web platforms where no native plugin exists
  - **index.ts**: Removed ALL web plugin registration code - it was causing conflicts on native platforms
  - The exported `BiometricAuth` API now cleanly delegates to the appropriate adapter without touching Capacitor's plugin registry

## [2.1.3] - 2025-12-12

### Fixed

- **Android/iOS Runtime Fix**: Comprehensive fix for "BiometricAuth.then() is not implemented on android" error
  - **CapacitorAdapter**: Added `pluginInitialized` flag to avoid checking plugin truthiness (which triggers Capacitor's proxy `.then()` interception)
  - **BiometricAuthCore**: Added `ensureInitialized()` method to prevent race conditions where methods are called before async initialization completes
  - **index.ts**: Removed problematic `Capacitor.Plugins['BiometricAuth']` access that triggered proxy on native platforms
  - **index.ts**: Used `queueMicrotask()` to delay web plugin registration until after Capacitor initialization
  - Early exit for native platforms - no longer attempts any plugin registration on Android/iOS
  - All public async methods now await initialization before accessing adapter

## [2.1.2] - 2025-12-12

### Fixed

- **Android/iOS Runtime Fix**: Fixed "BiometricAuth already registered" and "BiometricAuth.then() not implemented" errors
  - Plugin registration now only happens on web platform
  - Added platform detection to skip registration on native platforms (Android/iOS)
  - Added check to prevent duplicate plugin registration
  - Native platforms use their own plugin implementations, web uses JavaScript fallback

## [2.1.1] - 2025-12-11

### Fixed

- **Android Build Fix**: Changed `getInt()` to `optInt()` in `BiometricAuthPlugin.java` for default value support
  - Fixed compilation error in `generateKeyPair()` method for `keySize` parameter
  - Fixed compilation error in `generateKeyPair()` method for `authenticationValidityDuration` parameter
  - Fixed compilation error in `generateSecretKeyForCrypto()` method for `authenticationValidityDuration` parameter
  - Android's `JSONObject.getInt()` doesn't support default values, `optInt()` does

## [2.1.0] - 2025-12-11

### Added

- Windows Hello support in ElectronAdapter via WebAuthn API
- Unified encoding utilities (`src/utils/encoding.ts`) for base64/ArrayBuffer conversions
- Unified error handler utilities (`src/utils/error-handler.ts`) for consistent error handling
- Comprehensive test suite (76 tests for utilities)
- Full WebAuthn options support for web platform
- Real cryptographic signature generation on Android using Android Keystore ECDSA keys
- Real cryptographic signature generation on iOS using Keychain SecKey ECDSA keys
- WebAuthn-compliant authenticatorData generation on Android and iOS
- Proper attestation object generation with CBOR encoding on Android and iOS
- Public key export in registration responses for backend verification
- Lockout enforcement on iOS with configurable maxAttempts and lockoutDuration
- Dynamic origin generation using actual app package/bundle identifier
- New `webAuthnOptions` property in `BiometricAuthOptions` interface
- Separate `register()` method for explicit credential creation (web platform)
- Support for all WebAuthn creation options (challenge, RP config, user info, algorithms, attestation)
- Support for all WebAuthn authentication options (challenge, credentials, verification, timeout)
- Utility functions for WebAuthn data conversion
- Credential storage mechanism for managing registered credentials
- Intelligent authentication flow that automatically chooses between registration and authentication

### Fixed

- **CRITICAL**: iOS `register()` method now properly exposed in Objective-C bridge
- Session duration inconsistency fixed (300s → 3600s default)
- Session duration units standardized to seconds (was incorrectly milliseconds in core)
- Memory leak in BiometricAuthCore from uncleaned setTimeout callbacks
- Hardcoded WebAuthn origin in Android replaced with dynamic package-based origin
- Hardcoded WebAuthn origin in iOS replaced with dynamic bundle identifier
- Mock "mobile_signature" replaced with real ECDSA signatures on both platforms
- Mock "mobile_attestation" replaced with real attestation objects on both platforms
- Empty authenticatorData replaced with proper WebAuthn-compliant format
- Duplicate biometrics return in iOS (was returning both "touchId" and "fingerprint")
- Duplicate imports in Android BiometricAuthPlugin.java
- Session timeout now properly cleared on logout and new authentication
- Type definitions consolidated into canonical `src/types/` directory
- WebAuthn implementation now follows the specification correctly
- Proper separation between credential creation and assertion

### Security

- All cryptographic operations now use platform-specific secure enclaves (Android Keystore, iOS Keychain)
- Signatures are generated using biometric-protected ECDSA P-256 keys
- Challenge data is properly signed for WebAuthn compliance
- Sign count is tracked and incremented for replay attack prevention

### Changed

- ElectronAdapter now supports Windows (win32) platform via Windows Hello
- Error handling consolidated across all adapters
- `authenticate()` method now intelligently determines whether to register new credentials or authenticate existing ones
- Web implementation now properly uses `navigator.credentials.get()` for authentication
- Improved error handling with specific WebAuthn error mapping

## [1.0.0] - 2024-01-XX

### Added

- Initial release of Capacitor Biometric Auth plugin
- Web implementation using Web Authentication API (WebAuthn)
- Android native implementation using BiometricPrompt API
- iOS native implementation using LocalAuthentication framework
- Secure session management with configurable duration
- Credential storage with encryption support
- TypeScript definitions with full type safety
- Support for multiple biometric types:
  - Fingerprint (Android/iOS)
  - Face ID (iOS)
  - Face Authentication (Android)
  - Device credentials as fallback
- Comprehensive configuration options:
  - Session duration
  - UI customization
  - Fallback methods
  - Max attempts and lockout duration
- Session management utilities for web platform
- Example React application demonstrating all features
- Full documentation and contributing guidelines

### Security

- Implemented AES-GCM encryption for web platform credentials
- Android Keystore integration for secure credential storage
- iOS Keychain integration for secure credential storage
- Session tokens with configurable expiration

## [0.0.1] - 2024-01-XX (Upcoming)

### Notes

- Initial beta release
- Requires Capacitor 8.x
- Minimum Android API 23 (Android 6.0)
- Minimum iOS 13.0
- Supports latest web browsers with WebAuthn support
