signops 0.4.1
signops: ^0.4.1 copied to clipboard
SignOps in a Flutter app: Approve (push approval of sign-ins, keys in the Android Keystore and iOS Secure Enclave), passkeys and push open reporting.
SignOps for Flutter #
SignOps in a Flutter app: Approve (a push to the user's trusted phone, answered with a key that never leaves it), passkeys on your own domain, and push open reporting. The native work is the SignOps Android and iOS SDKs, compiled into this plugin: keys in the Android Keystore (StrongBox when the phone has it) and the iOS Secure Enclave, the fingerprint, face or passcode check before every approval.
dependencies:
signops: ^0.4.1
Android 9 and iOS 16 or later.
import 'package:signops/signops.dart';
final signops = SignOps('pk_live_...'); // the publishable key; secret keys stay on your server
// After your own login. The token comes from your server: POST /v1/approve/enroll-token { user_id }.
await signops.approve.enroll(tokenFromYourServer, (await FirebaseMessaging.instance.getToken())!);
// When an approve push arrives, or the app opens: show the ready-made screen.
final id = SignOps.approveRequestId(message.data);
Navigator.of(context).push(MaterialPageRoute(builder: (_) => Scaffold(
body: ApproveScreen(signops: signops, requestId: id, onDone: (status) => Navigator.of(context).pop()),
)));
// Or build your own screen.
final req = (await signops.approve.pending()).first;
await signops.approve.approve(req, '47'); // fingerprint or face first, then a signed answer
FirebaseMessaging.instance.onTokenRefresh.listen(signops.approve.updatePushToken);
FirebaseMessaging.onMessageOpenedApp.listen((m) => signops.push.opened(m.data));
await signops.passkeys.register(registrationTokenFromYourServer);
final signedIn = await signops.passkeys.signIn(); // send signedIn.signopsToken to your server
Errors are SignOpsException with code: the API's codes, or cancelled, not_enrolled, no_lock, auth_failed, no_passkey, passkey_error, no_activity.
Before it works #
- Android:
MainActivityextendsFlutterFragmentActivity(the fingerprint check needs it), andminSdk = 28inandroid/app/build.gradle.kts. - iOS:
platform :ios, '16.0'in the Podfile,NSFaceIDUsageDescriptionin Info.plist; for passkeys the Associated Domains entrywebcredentials:<your domain>. - Passkeys: the app added under Passkeys, Setup in the dashboard, and the files it shows hosted on your domain.
Maintainers #
android/src/main/kotlin/com/signops/sdk and ios/signops/Sources/signops/sdk are copies of the native SDKs made by node ../sync-native.mjs. Edit the originals in packages/android and packages/ios. flutter test runs the Dart tests with the channel mocked.