Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/flutter-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: flutter pub get

- name: Analyze
run: flutter analyze --fatal-infos
run: flutter analyze --no-fatal-infos

- name: Run tests
run: flutter test --reporter expanded
52 changes: 52 additions & 0 deletions .github/workflows/shared-package-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Shared package CI

on:
pull_request:
branches:
- main
paths:
- "packages/openkey_shared/**"
- ".github/workflows/shared-package-ci.yml"
push:
branches:
- main
paths:
- "packages/openkey_shared/**"
- ".github/workflows/shared-package-ci.yml"
workflow_dispatch:

permissions:
contents: read

concurrency:
group: shared-package-ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
quality:
name: Analyze and test shared package
runs-on: ubuntu-latest
timeout-minutes: 20

defaults:
run:
working-directory: packages/openkey_shared

steps:
- name: Check out source
uses: actions/checkout@v4

- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true

- name: Install dependencies
run: flutter pub get

- name: Analyze
run: flutter analyze --fatal-infos

- name: Run tests
run: flutter test --reporter expanded
55 changes: 55 additions & 0 deletions docs/shared-editions-architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# OpenKey shared-edition architecture

## Goal

Maintain one implementation of the password manager while shipping two
product editions:

- **OpenKey** — the public, open-source edition.
- **OpenKey_app** — the private commercial edition with subscriptions and
additional Pro capabilities.

The editions must not maintain independent copies of cryptography, vault
persistence, synchronization, or common UI.

## Package boundary

The public repository owns packages/openkey_shared. Both applications use
this package as their shared implementation.

The public app uses a local path dependency while developing in this
repository. The private app should consume a pinned tag/commit from the public
repository, never an unpinned moving branch.

## Edition-specific adapters

Shared code must not import a billing SDK. Instead it depends on the
FeatureAccess interface.

- The public application provides FreeEditionFeatureAccess.
- The private application provides a subscription-backed implementation
populated from verified store entitlements.

Subscription screens, purchase/restore flows, billing products, and private
commercial configuration stay in the private application.

## Security and migration invariants

The extraction must preserve:

- existing encryption algorithms, KDF parameters, key wrapping, and
ciphertext formats;
- Drift schema versions, migrations, and database file locations;
- secure-storage key names and account namespace behavior;
- backup/import/export compatibility;
- authentication and server synchronization protocols.

Never combine the package extraction with a database/schema migration unless
that migration is independently tested and explicitly required.

## Rollout

This foundation change introduces the package and capability contract only.
The source extraction and app wiring are follow-up changes. They require the
private app source to be available so the two codebases can be reconciled
before any shared implementation is removed.
29 changes: 3 additions & 26 deletions lib/src/core/usecases/either.dart
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
abstract class Either<L, R> {
const Either();
T fold<T>(T Function(L l) leftFn, T Function(R r) rightFn);

bool get isLeft => this is Left<L, R>;
bool get isRight => this is Right<L, R>;

L? get left => isLeft ? (this as Left<L, R>).value : null;
R? get right => isRight ? (this as Right<L, R>).value : null;
}

class Left<L, R> extends Either<L, R> {
final L value;
const Left(this.value);

@override
T fold<T>(T Function(L l) leftFn, T Function(R r) rightFn) => leftFn(value);
}

class Right<L, R> extends Either<L, R> {
final R value;
const Right(this.value);

@override
T fold<T>(T Function(L l) leftFn, T Function(R r) rightFn) => rightFn(value);
}
/// Compatibility export. The implementation now lives in openkey_shared.
export 'package:openkey_shared/openkey_shared.dart'
show Either, Left, Right;
23 changes: 3 additions & 20 deletions lib/src/core/utils/password_strength.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
/// Simple password strength score used across OpenKey (0.0–1.0).
///
/// Matches the heuristic used when setting a master password: length plus
/// character-class mix.
double passwordStrengthScore(String password) {
if (password.isEmpty) return 0;
var score = (password.length / 12).clamp(0.0, 0.5);
if (RegExp(r'[A-Z]').hasMatch(password)) score += 0.125;
if (RegExp(r'[a-z]').hasMatch(password)) score += 0.125;
if (RegExp(r'\d').hasMatch(password)) score += 0.125;
if (RegExp(r'[^A-Za-z0-9]').hasMatch(password)) score += 0.125;
return score.clamp(0.0, 1.0);
}

/// True when the password is considered weak for vault health checks.
bool isWeakPassword(String password) {
if (password.isEmpty) return false;
if (password.length < 8) return true;
return passwordStrengthScore(password) < 0.35;
}
/// Compatibility export. The implementation now lives in openkey_shared.
export 'package:openkey_shared/openkey_shared.dart'
show passwordStrengthScore, isWeakPassword;
Loading
Loading