Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
25c8b90
Refactor: Migrate to Pigeon for type-safe platform communication
chamodanethra Dec 12, 2025
dd84467
feat: Refactor native error handling and add ECIES encryption to exam…
chamodanethra Dec 12, 2025
2667951
feat: Add Hex and Raw key formats and return raw bytes
chamodanethra Dec 13, 2025
6b41f69
feat(example): Separate public key and signature format options
chamodanethra Dec 13, 2025
88a6b83
refactor: Refactor API with granular configuration and expanded results
chamodanethra Dec 13, 2025
90de0cd
fix(ios, macos): Correct key creation to return RSA key
chamodanethra Dec 13, 2025
2ddcdb2
feat: Add `keyFormat` option to `createSignature` to specify public k…
chamodanethra Dec 13, 2025
61b5ed1
refactor(android): Improve biometric type detection and simplify enum
chamodanethra Dec 13, 2025
f99400d
feat(ios): Add key migration from Keychain to Secure Enclave
chamodanethra Dec 13, 2025
83b5618
Refactor: Clean up code and apply consistent formatting
chamodanethra Dec 13, 2025
8f3fda5
feat(ios, macos): Format public keys to SPKI (X.509) standard
chamodanethra Dec 13, 2025
d6d777c
add missing import
chamodanethra Dec 13, 2025
a0fc968
fix(macos): Use bundle-specific keychain identifiers
chamodanethra Dec 13, 2025
fa7ec80
refactor: Remove unused `BiometricError` cases and simplify example UI
chamodanethra Dec 14, 2025
a9647fa
fix(keys): Correct key existence and validity checks
chamodanethra Dec 14, 2025
a406e03
feat: Add `biometricKeyExists` method and update example app
chamodanethra Dec 14, 2025
2b48c48
feat(docs): Update README with unified API and improved platform details
chamodanethra Dec 14, 2025
7e8e76a
Refactor: Rename `getBiometricAvailability` to `biometricAuthAvailable`
chamodanethra Dec 14, 2025
d47bce6
feat: Add `deleteKeys()` method and improve API documentation
chamodanethra Dec 14, 2025
20ef282
Refactor: Always refresh document list after viewing details
chamodanethra Dec 14, 2025
2d7c24b
dart format .
chamodanethra Dec 14, 2025
6ccb057
feat: Add `getKeyInfo()` method to retrieve detailed key information
chamodanethra Dec 15, 2025
f9b5cd4
chore: Bump version to 9.0.0 and improve code generation
chamodanethra Dec 15, 2025
7ffdc6a
chore: Remove development team from example app Xcode projects
chamodanethra Dec 15, 2025
00c9344
dart format .
chamodanethra Dec 15, 2025
4f3fb90
docs: Update release date in CHANGELOG.md
chamodanethra Dec 16, 2025
2461650
chore: Temporarily disable format check in CI
chamodanethra Dec 16, 2025
bafbd71
refine: Improve Pigeon code generation and handle nullability
chamodanethra Dec 18, 2025
bcf68da
feat: Add Windows support via Windows Hello
chamodanethra Dec 18, 2025
9ad2837
feat(windows): add key/signature formatting and improve Windows Hello UX
chamodanethra Dec 18, 2025
830eb53
Refactor: Unify platform-specific configurations into consolidated co…
chamodanethra Dec 18, 2025
c901dd2
updating documentations.
chamodanethra Dec 18, 2025
57b316e
Add Windows platform support for other example apps.
chamodanethra Dec 18, 2025
743ebe8
Refactor(windows): Migrate to Pigeon for type-safe native communication
chamodanethra Dec 18, 2025
d066b48
dart format .
chamodanethra Dec 18, 2025
4202f47
feat: Remove default widget tests from example apps
chamodanethra Dec 18, 2025
ae209fb
Refactor(api): Convert `biometricAuthAvailable` and `deleteKeys` to a…
chamodanethra Dec 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
## [9.0.0] - 2025-12-18

* **Breaking**: Method signature changes:
- `createKeys()` now takes `config`, `keyFormat`, `promptMessage` parameters
- `createSignature()` now takes `payload`, `config`, `signatureFormat`, `keyFormat`, `promptMessage` parameters
- `decrypt()` now takes `payload`, `payloadFormat`, `config`, `promptMessage` parameters

* Moved cross-platform parameters into unified config objects:
- `signatureType`, `enforceBiometric`, `setInvalidatedByBiometricEnrollment`, `useDeviceCredentials` now in `CreateKeysConfig`
- Each field is documented with which platform(s) it applies to

### Architecture - Type-safe Communication with Pigeon
* **Breaking**: Migrated entire platform communication layer to [Pigeon](https://pub.dev/packages/pigeon).
* **Breaking**: Replaced raw string/map returns with structured strongly-typed objects:
- `KeyCreationResult`: Contains `publicKey`, `error`, and `code`.
- `SignatureResult`: Contains `signature`, `publicKey`, `error`, and `code`.
- `DecryptResult`: Contains `decryptedData`, `error`, and `code`.
- `BiometricAvailability`: detailed availability status including enrolled biometric types and error reasons.
* **Breaking**: Standardized `BiometricError` enum across all platforms.

### API Improvements
* **Breaking**: `biometricAuthAvailable()` now returns a `BiometricAvailability` object instead of a raw string.
* Removed legacy `signature_options.dart`, `decryption_options.dart` and old config classes.
* Enhanced error handling with specific error codes (e.g., `userCanceled`, `notEnrolled`, `lockedOut`) instead of generic strings.
* **New `getKeyInfo()` method**: Retrieve detailed information about existing biometric keys without creating a signature.
- Returns `KeyInfo` object with: `exists`, `isValid`, `algorithm`, `keySize`, `isHybridMode`, `publicKey`, `decryptingPublicKey`.
- Accepts `checkValidity` parameter to verify key hasn't been invalidated by biometric changes.
- Accepts `keyFormat` parameter to specify output format (base64, pem, hex).
* **New `KeyInfo` class**: Exported via Pigeon for type-safe key metadata.
* `biometricKeyExists()` is now a convenience wrapper around `getKeyInfo()`.

### Improved
* Cleaner, simpler API with fewer method parameters
* Better documentation of platform-specific options
* Updated all example projects to use new API

## [8.5.0] - 2025-12-09

### Added - macOS Platform Support
Expand Down
113 changes: 86 additions & 27 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,53 +168,112 @@ All examples demonstrate:

### Initialize Biometric Service
```dart
import 'package:biometric_signature/key_material.dart';
import 'package:biometric_signature/biometric_signature.dart';

final biometric = BiometricSignature();

// Check availability
final available = await biometric.biometricAuthAvailable();
final availability = await biometric.biometricAuthAvailable();
if (availability.canAuthenticate ?? false) {
print('Biometrics available: ${availability.availableBiometrics}');
}

// Create keys
// Create keys (RSA by default)
final keyResult = await biometric.createKeys(
keyFormat: KeyFormat.pem,
androidConfig: AndroidConfig(
useDeviceCredentials: false,
signatureType: AndroidSignatureType.RSA,
),
iosConfig: IosConfig(
useDeviceCredentials: false,
signatureType: IOSSignatureType.RSA,
promptMessage: 'Authenticate to create keys',
config: CreateKeysConfig(
signatureType: SignatureType.rsa,
useDeviceCredentials: true,
setInvalidatedByBiometricEnrollment: true,
enforceBiometric: true,
enableDecryption: false, // Android only
),
);

final pemPublicKey = keyResult?.publicKey.asString();
if (keyResult.code == BiometricError.success) {
print('Public Key: ${keyResult.publicKey}');
}
```

### Get Key Info
```dart
// Check key existence with metadata
final info = await biometric.getKeyInfo(
checkValidity: true,
keyFormat: KeyFormat.pem,
);

if (info.exists && (info.isValid ?? true)) {
print('Algorithm: ${info.algorithm}, Size: ${info.keySize} bits');
print('Hybrid Mode: ${info.isHybridMode}');
print('Public Key: ${info.publicKey}');
}
```

### Sign Data
```dart
final signatureResult = await biometric.createSignature(
SignatureOptions(
payload: 'data_to_sign',
promptMessage: 'Authenticate to continue',
keyFormat: KeyFormat.raw,
final result = await biometric.createSignature(
payload: 'data_to_sign',
promptMessage: 'Authenticate to sign',
signatureFormat: SignatureFormat.base64,
keyFormat: KeyFormat.pem,
config: CreateSignatureConfig(
allowDeviceCredentials: true,
),
);

final signatureBase64 = signatureResult?.signature.toBase64();
if (result.code == BiometricError.success) {
print('Signature: ${result.signature}');
}
```

### Decrypt Data
```dart
final decryptResult = await biometric.decrypt(
payload: encryptedBase64,
payloadFormat: PayloadFormat.base64,
promptMessage: 'Authenticate to decrypt',
config: DecryptConfig(
allowDeviceCredentials: false,
),
);

if (decryptResult.code == BiometricError.success) {
print('Decrypted: ${decryptResult.decryptedData}');
}
```

### Error Handling
```dart
try {
final signatureResult = await biometric.createSignature(options);
final signatureHex = signatureResult?.signature.toHex();
} on PlatformException catch (e) {
if (e.code == 'AUTH_FAILED') {
// Handle authentication failure
} else if (e.code == 'CANCELLED') {
// Handle user cancellation
}
final result = await biometric.createSignature(
payload: 'data_to_sign',
promptMessage: 'Authenticate',
);

switch (result.code) {
case BiometricError.success:
print('Signed: ${result.signature}');
break;
case BiometricError.userCanceled:
print('User cancelled authentication');
break;
case BiometricError.keyInvalidated:
print('Key invalidated - re-enrollment required');
break;
case BiometricError.lockedOut:
print('Too many attempts - locked out');
break;
default:
print('Error: ${result.code} - ${result.error}');
}
```

### Delete Keys
```dart
final deleted = await biometric.deleteKeys();
if (deleted) {
print('All biometric keys removed');
}
```

Expand All @@ -232,7 +291,7 @@ Found an issue or want to improve an example? Contributions are welcome!

1. Fork the repository
2. Create your feature branch
3. Test your changes on both platforms
3. Test your changes on all platforms
4. Submit a pull request

## 📄 License
Expand Down
Loading