├── .github ├── ISSUE_TEMPLATE │ ├── bug.yml │ └── feature.yml └── workflows │ ├── flutter.yml │ ├── jekyll-gh-pages.yml │ └── rust.yml ├── .gitignore ├── .metadata ├── .tool-versions ├── .vscode └── launch.json ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── polypass │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-night │ │ │ └── styles.xml │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── polypass_android.iml ├── proguard-rules.pro └── settings.gradle ├── assets └── polypass.png ├── build.yaml ├── debian ├── debian.yaml └── gui │ ├── Polypass-128.png │ ├── Polypass-64.png │ ├── Polypass.desktop │ └── Polypass.png ├── images ├── generator.png ├── home.png └── vault.png ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Podfile ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings └── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-App-1024x1024@1x.png │ │ ├── Icon-App-20x20@1x.png │ │ ├── Icon-App-20x20@2x.png │ │ ├── Icon-App-20x20@3x.png │ │ ├── Icon-App-29x29@1x.png │ │ ├── Icon-App-29x29@2x.png │ │ ├── Icon-App-29x29@3x.png │ │ ├── Icon-App-40x40@1x.png │ │ ├── Icon-App-40x40@2x.png │ │ ├── Icon-App-40x40@3x.png │ │ ├── Icon-App-60x60@2x.png │ │ ├── Icon-App-60x60@3x.png │ │ ├── Icon-App-76x76@1x.png │ │ ├── Icon-App-76x76@2x.png │ │ └── Icon-App-83.5x83.5@2x.png │ └── LaunchImage.imageset │ │ ├── Contents.json │ │ ├── LaunchImage.png │ │ ├── LaunchImage@2x.png │ │ ├── LaunchImage@3x.png │ │ └── README.md │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ └── Runner-Bridging-Header.h ├── justfile ├── lefthook.yml ├── lib ├── blocs │ ├── activity_bloc │ │ ├── activity_bloc.dart │ │ ├── activity_bloc.freezed.dart │ │ └── ticker.dart │ ├── app_settings_bloc │ │ ├── app_settings_bloc.dart │ │ └── app_settings_bloc.freezed.dart │ ├── create_form │ │ ├── create_form_bloc.dart │ │ └── create_form_bloc.freezed.dart │ ├── recent_bloc │ │ ├── recent_bloc.dart │ │ └── recent_bloc.freezed.dart │ └── vault_bloc │ │ ├── vault_bloc.dart │ │ └── vault_bloc.freezed.dart ├── bridge_generated.dart ├── components │ ├── activity_listener │ │ └── activity_listener.dart │ ├── app_wrapper │ │ ├── app_bar.dart │ │ └── app_wrapper.dart │ ├── location_dialog │ │ └── location_dialog.dart │ ├── master_password_dialog │ │ ├── master_password_dialog.dart │ │ ├── master_password_dialog_bloc.dart │ │ └── master_password_dialog_bloc.freezed.dart │ ├── merge_conflict_dialog │ │ └── merge_conflict_dialog.dart │ └── open_dialog │ │ └── open_dialog.dart ├── data │ ├── app_settings │ │ ├── app_settings.dart │ │ ├── app_settings.freezed.dart │ │ └── app_settings.g.dart │ ├── cache │ │ └── cache.dart │ ├── migration.dart │ ├── vault_file │ │ ├── vault_file.dart │ │ ├── vault_file.freezed.dart │ │ └── vault_file.g.dart │ ├── vault_providers.dart │ └── vault_repository.dart ├── ffi.dart ├── generated_plugin_registrant.dart ├── main.dart ├── pages │ ├── create │ │ └── create.dart │ ├── ftp │ │ ├── ftp.dart │ │ ├── ftp_bloc.dart │ │ └── ftp_bloc.freezed.dart │ ├── generator │ │ ├── generator.dart │ │ ├── generator_bloc.dart │ │ └── generator_bloc.freezed.dart │ ├── home │ │ └── home.dart │ ├── recent │ │ └── recent.dart │ ├── settings │ │ ├── settings.dart │ │ ├── settings_bloc.dart │ │ └── settings_bloc.freezed.dart │ └── vault │ │ ├── edit │ │ ├── edit.dart │ │ ├── edit_bloc.dart │ │ └── edit_bloc.freezed.dart │ │ ├── home │ │ ├── component_bloc │ │ │ ├── component_bloc.dart │ │ │ └── component_bloc.freezed.dart │ │ ├── folder_list.dart │ │ ├── home.dart │ │ ├── list_item_bloc │ │ │ ├── list_item_bloc.dart │ │ │ └── list_item_bloc.freezed.dart │ │ ├── tree.dart │ │ └── vault_home_bloc │ │ │ ├── vault_home_bloc.dart │ │ │ └── vault_home_bloc.freezed.dart │ │ ├── locked │ │ ├── locked.dart │ │ ├── locked_bloc.dart │ │ └── locked_bloc.freezed.dart │ │ ├── new │ │ ├── new.dart │ │ ├── new_bloc.dart │ │ └── new_bloc.freezed.dart │ │ └── settings │ │ ├── settings.dart │ │ ├── settings_bloc.dart │ │ └── settings_bloc.freezed.dart └── theme.dart ├── linux ├── .gitignore ├── CMakeLists.txt ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake ├── io.github.polypixeldev.Polypass.appdata.xml ├── main.cc ├── my_application.cc ├── my_application.h └── rust.cmake ├── polypass.iml ├── pubspec.lock ├── pubspec.yaml ├── rust ├── Cargo.lock ├── Cargo.toml └── src │ ├── api.rs │ ├── bridge_generated.io.rs │ ├── bridge_generated.rs │ └── lib.rs ├── setup-script-template.iss ├── site └── index.md ├── test └── widget_test.dart ├── web ├── favicon.png ├── icons │ ├── Icon-192.png │ ├── Icon-512.png │ ├── Icon-maskable-192.png │ └── Icon-maskable-512.png ├── index.html └── manifest.json ├── windows-install ├── msvcp140.dll ├── vcruntime140.dll └── vcruntime140_1.dll └── windows ├── .gitignore ├── CMakeLists.txt ├── flutter ├── CMakeLists.txt ├── generated_plugin_registrant.cc ├── generated_plugin_registrant.h └── generated_plugins.cmake ├── runner ├── CMakeLists.txt ├── Runner.rc ├── flutter_window.cpp ├── flutter_window.h ├── main.cpp ├── resource.h ├── resources │ └── app_icon.ico ├── runner.exe.manifest ├── utils.cpp ├── utils.h ├── win32_window.cpp └── win32_window.h └── rust.cmake /.github/ISSUE_TEMPLATE/bug.yml: -------------------------------------------------------------------------------- 1 | name: Bug Report 2 | description: File a bug report 3 | title: "[BUG] " 4 | labels: ["bug"] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: Fill out the fields below, and it will be reviewed as soon as possible. Remember to follow the Code of Conduct 9 | - type: input 10 | id: page 11 | attributes: 12 | label: Page 13 | description: What page did the bug occur on? 14 | placeholder: ex. Vault settings 15 | validations: 16 | required: true 17 | - type: textarea 18 | id: what-happened 19 | attributes: 20 | label: What happened? 21 | description: What happened? Please be as clear as possible 22 | placeholder: ex. I got an error message... 23 | validations: 24 | required: true 25 | - type: textarea 26 | id: repro 27 | attributes: 28 | label: To Reproduce 29 | description: What steps can you take to reproduce the bug? 30 | placeholder: ex. 1. Go the create new vault page... 31 | validations: 32 | required: true 33 | - type: input 34 | id: os 35 | attributes: 36 | label: Operating System 37 | description: What operating system and device did you see the bug on? 38 | placeholder: ex. Android on Google Pixel 3 39 | validations: 40 | required: true 41 | - type: textarea 42 | id: context 43 | attributes: 44 | label: Context 45 | description: Add any other context about the problem here 46 | 47 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature.yml: -------------------------------------------------------------------------------- 1 | name: Feature Request 2 | description: Suggest a feature for Polypass 3 | title: "[FEATURE] " 4 | labels: ["enhancement"] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: Fill out the fields below, and it will be reviewed as soon as possible. Remember to follow the Code of Conduct 9 | - type: textarea 10 | id: what 11 | attributes: 12 | label: What you would like 13 | description: What feature would you like to be implemented? 14 | placeholder: ex. I would like a feature that... 15 | validations: 16 | required: true 17 | - type: textarea 18 | id: why 19 | attributes: 20 | label: Why do you request this feature? 21 | description: For what reason do you request this feature? Is it related to a problem? 22 | placeholder: ex. I request this feature because... 23 | validations: 24 | required: true 25 | - type: textarea 26 | id: other 27 | attributes: 28 | label: Other 29 | description: Is there anything else you would like to say? 30 | 31 | -------------------------------------------------------------------------------- /.github/workflows/flutter.yml: -------------------------------------------------------------------------------- 1 | name: Flutter Analyze 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v3 15 | - uses: britannio/action-install-flutter@v1 16 | 17 | - name: Install dependencies 18 | run: flutter pub get 19 | 20 | - name: Verify formatting 21 | run: dart format --output=none --set-exit-if-changed . 22 | 23 | - name: Analyze project source 24 | run: flutter analyze --fatal-infos 25 | -------------------------------------------------------------------------------- /.github/workflows/jekyll-gh-pages.yml: -------------------------------------------------------------------------------- 1 | # Sample workflow for building and deploying a Jekyll site to GitHub Pages 2 | name: Deploy Jekyll with GitHub Pages 3 | 4 | on: 5 | # Allows you to run this workflow manually from the Actions tab 6 | workflow_dispatch: 7 | 8 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages 9 | permissions: 10 | contents: read 11 | pages: write 12 | id-token: write 13 | 14 | # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. 15 | # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. 16 | concurrency: 17 | group: "pages" 18 | cancel-in-progress: false 19 | 20 | jobs: 21 | # Build job 22 | build: 23 | runs-on: ubuntu-latest 24 | steps: 25 | - name: Checkout 26 | uses: actions/checkout@v3 27 | - name: Setup Pages 28 | uses: actions/configure-pages@v3 29 | - name: Build with Jekyll 30 | uses: actions/jekyll-build-pages@v1 31 | with: 32 | source: ./site 33 | destination: ./_site 34 | - name: Upload artifact 35 | uses: actions/upload-pages-artifact@v1 36 | 37 | # Deployment job 38 | deploy: 39 | environment: 40 | name: github-pages 41 | url: ${{ steps.deployment.outputs.page_url }} 42 | runs-on: ubuntu-latest 43 | needs: build 44 | steps: 45 | - name: Deploy to GitHub Pages 46 | id: deployment 47 | uses: actions/deploy-pages@v2 48 | -------------------------------------------------------------------------------- /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | name: Rust Check 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | check: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v3 17 | - uses: actions-rs/toolchain@v1 18 | with: 19 | toolchain: nightly-2023-06-15 20 | override: true 21 | 22 | - name: Build 23 | working-directory: ./rust 24 | run: cargo check --verbose 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://www.dartlang.org/guides/libraries/private-files 2 | 3 | # Files and directories created by pub 4 | .dart_tool/ 5 | .packages 6 | build/ 7 | 8 | # Directory created by dartdoc 9 | # If you don't generate documentation locally you can remove this line. 10 | doc/api/ 11 | 12 | # Avoid committing generated Javascript files: 13 | *.dart.js 14 | *.info.json # Produced by the --dump-info flag. 15 | *.js # When generated by dart2js. Don't specify *.js if your 16 | # project includes source files written in JavaScript. 17 | *.js_ 18 | *.js.deps 19 | *.js.map 20 | 21 | # Generated flutter files 22 | .flutter-plugins 23 | .flutter-plugins-dependencies 24 | 25 | # Testing files 26 | *.ppv.json 27 | 28 | # Packaged deb files 29 | debian/packages/* 30 | 31 | # Generated installer files 32 | setup-script.iss 33 | Output 34 | 35 | # Built files 36 | windows-install/data 37 | windows-install/polypass.exe 38 | windows-install/libpolypass.dll 39 | windows-install/flutter_windows.dll 40 | windows-install/polypass.exe 41 | 42 | # Rust 43 | rust/target 44 | 45 | # Android libs 46 | jniLibs 47 | 48 | .flatpak-builder 49 | build-dir -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 5464c5bac742001448fe4fc0597be939379f88ea 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /.tool-versions: -------------------------------------------------------------------------------- 1 | java adoptopenjdk-8.0.362+9 2 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Current Device", 9 | "request": "launch", 10 | "type": "dart" 11 | }, 12 | { 13 | "name": "Linux", 14 | "request": "launch", 15 | "type": "dart", 16 | "deviceId": "linux" 17 | }, 18 | { 19 | "name": "Android", 20 | "request": "launch", 21 | "type": "dart", 22 | "deviceId": "emulator-5554" 23 | }, 24 | { 25 | "name": "polypass (profile mode)", 26 | "request": "launch", 27 | "type": "dart", 28 | "flutterMode": "profile" 29 | }, 30 | { 31 | "name": "polypass (release mode)", 32 | "request": "launch", 33 | "type": "dart", 34 | "flutterMode": "release" 35 | } 36 | ], 37 | "compounds": [ 38 | { 39 | "name": "All Devices", 40 | "configurations": ["Android", "Linux"], 41 | } 42 | ] 43 | } -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Polypass 2 | Below are some helpful guidelines and tips for contributing to Polypass. 3 | 4 | ## Issues 5 | Please be as descriptive as possible when creating an issue. I will try to respond ASAP. 6 | 7 | ## Code 8 | If you have any questions, feel free to start a discussion in the Q&A category in GitHub Discussions. 9 | 10 | ### Terminology 11 | **Master Password**: The plaintext version of the user's password used to unlock a vault 12 | 13 | **Derived Key**: The result of performing Polypass's KDF function on the Master Password 14 | 15 | **Master Key**: The secure randomly generated key for a vault, stored in the vault file and encrypted by the Derived Key -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Polypass 2 | A simple, secure, and easy to use password manager written with Dart, Flutter, and Rust 3 | 4 | ## Windows installer 5 | To compile the Windows installer, build the app for Windows in release mode and copy the contents of build/windows/runner/Release to windows-install. Copy setup-script-template.iss to setup-script.iss and change the RepoPath variable to the absolute path of this cloned repository. Compile the installer with Inno Setup, when it is finished the installer executable will be in the Output directory. 6 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | 2 | include: package:flutter_lints/flutter.yaml 3 | 4 | linter: 5 | rules: 6 | prefer_single_quotes: true 7 | always_use_package_imports: true 8 | 9 | analyzer: 10 | errors: 11 | invalid_annotation_target: false 12 | exclude: 13 | - "**/*.g.dart" 14 | - "**/*.freezed.dart" 15 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion flutter.compileSdkVersion 30 | 31 | compileOptions { 32 | sourceCompatibility JavaVersion.VERSION_1_8 33 | targetCompatibility JavaVersion.VERSION_1_8 34 | } 35 | 36 | kotlinOptions { 37 | jvmTarget = '1.8' 38 | } 39 | 40 | sourceSets { 41 | main.java.srcDirs += 'src/main/kotlin' 42 | } 43 | 44 | defaultConfig { 45 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 46 | applicationId "com.polypixeldev.polypass" 47 | minSdkVersion flutter.minSdkVersion 48 | targetSdkVersion flutter.targetSdkVersion 49 | versionCode flutterVersionCode.toInteger() 50 | versionName flutterVersionName 51 | } 52 | 53 | buildTypes { 54 | release { 55 | // TODO: Add your own signing config for the release build. 56 | // Signing with the debug keys for now, so `flutter run --release` works. 57 | signingConfig signingConfigs.debug 58 | } 59 | } 60 | } 61 | 62 | flutter { 63 | source '../..' 64 | } 65 | 66 | dependencies { 67 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 68 | } 69 | 70 | [ 71 | Debug: null, 72 | Profile: '--release', 73 | Release: '--release' 74 | ].each { 75 | def taskPostfix = it.key 76 | def profileMode = it.value 77 | tasks.whenTaskAdded { task -> 78 | if (task.name == "javaPreCompile$taskPostfix") { 79 | task.dependsOn "cargoBuild$taskPostfix" 80 | } 81 | } 82 | tasks.register("cargoBuild$taskPostfix", Exec) { 83 | workingDir "../../rust" 84 | environment ANDROID_NDK_HOME: "$ANDROID_NDK" 85 | commandLine 'cargo', 'ndk', 86 | // the 2 ABIs below are used by real Android devices 87 | '-t', 'armeabi-v7a', 88 | '-t', 'arm64-v8a', 89 | // the below 2 ABIs are usually used for Android simulators, 90 | // add or remove these ABIs as needed. 91 | '-t', 'x86', 92 | '-t', 'x86_64', 93 | '-o', '../android/app/src/main/jniLibs', 'build' 94 | if (profileMode != null) { 95 | args profileMode 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/polypass/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.polypixeldev.polypass 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.7.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.2.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | tasks.register("clean", Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip 7 | -------------------------------------------------------------------------------- /android/polypass_android.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /android/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | -keep class androidx.lifecycle.DefaultLifecycleObserver -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /assets/polypass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/assets/polypass.png -------------------------------------------------------------------------------- /build.yaml: -------------------------------------------------------------------------------- 1 | targets: 2 | $default: 3 | builders: 4 | json_serializable: 5 | options: 6 | explicit_to_json: true 7 | generic_argument_factories: true 8 | any_map: true -------------------------------------------------------------------------------- /debian/debian.yaml: -------------------------------------------------------------------------------- 1 | flutter_app: 2 | command: polypass 3 | arch: x64 4 | 5 | control: 6 | Package: Polypass 7 | Version: 2.1.0 8 | Architecture: amd64 9 | Essential: no 10 | Priority: optional 11 | Maintainer: polypixeldev 12 | Description: A simple, secure, and easy to use password manager -------------------------------------------------------------------------------- /debian/gui/Polypass-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/debian/gui/Polypass-128.png -------------------------------------------------------------------------------- /debian/gui/Polypass-64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/debian/gui/Polypass-64.png -------------------------------------------------------------------------------- /debian/gui/Polypass.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Name=Polypass 4 | GenericName=Polypass 5 | Comment=A simple, secure, and easy to use password manager 6 | Terminal=false 7 | Type=Application 8 | Categories=Utility 9 | Keywords=passwords;security; 10 | Icon=Polypass 11 | StartupWMClass=polypass -------------------------------------------------------------------------------- /debian/gui/Polypass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/debian/gui/Polypass.png -------------------------------------------------------------------------------- /images/generator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/images/generator.png -------------------------------------------------------------------------------- /images/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/images/home.png -------------------------------------------------------------------------------- /images/vault.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/images/vault.png -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 9.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | target 'Runner' do 2 | use_frameworks! -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Polypass 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | polypass 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | UIBackgroundModes 47 | 48 | fetch 49 | remote-notification 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /justfile: -------------------------------------------------------------------------------- 1 | default: gen lint 2 | 3 | gen: 4 | flutter pub get 5 | flutter_rust_bridge_codegen \ 6 | --rust-input rust/src/api.rs \ 7 | --dart-output lib/bridge_generated.dart \ 8 | 9 | lint: 10 | cd rust && cargo fmt 11 | dart format . 12 | 13 | clean: 14 | flutter clean 15 | cd rust && cargo clean 16 | 17 | serve *args='': 18 | flutter pub run flutter_rust_bridge:serve {{args}} -------------------------------------------------------------------------------- /lefthook.yml: -------------------------------------------------------------------------------- 1 | pre-commit: 2 | commands: 3 | lint: 4 | exclude: ".*.g.dart|.*.freezed.dart" 5 | run: dart analyze --fatal-infos {all_files} 6 | format: 7 | glob: "*.dart" 8 | run: dart format {staged_files}; git add {staged_files} 9 | -------------------------------------------------------------------------------- /lib/blocs/activity_bloc/activity_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:bloc/bloc.dart'; 4 | import 'package:provider/provider.dart'; 5 | 6 | import 'package:polypass/blocs/vault_bloc/vault_bloc.dart'; 7 | import 'package:polypass/blocs/activity_bloc/ticker.dart'; 8 | 9 | import 'package:freezed_annotation/freezed_annotation.dart'; 10 | part 'activity_bloc.freezed.dart'; 11 | 12 | @freezed 13 | class ActivityState with _$ActivityState { 14 | const factory ActivityState( 15 | {required int duration, required bool passwordCopied}) = _ActivityState; 16 | } 17 | 18 | @freezed 19 | class ActivityEvent with _$ActivityEvent { 20 | const factory ActivityEvent.action() = ActionEvent; 21 | const factory ActivityEvent.started() = StartedEvent; 22 | const factory ActivityEvent.ticked(int duration) = TickedEvent; 23 | const factory ActivityEvent.copied(bool copied) = CopiedEvent; 24 | } 25 | 26 | class ActivityBloc extends Bloc { 27 | ActivityBloc({required this.read}) 28 | : super(ActivityState( 29 | duration: read().state.maybeMap( 30 | unlocked: (state) => 31 | state.vault.header.settings.vaultAutoLockSeconds, 32 | orElse: () => -1), 33 | passwordCopied: false)) { 34 | on((event, emit) { 35 | event.map( 36 | action: (event) => _onAction(event, emit), 37 | started: (event) => _onStarted(event, emit), 38 | ticked: (event) => _onTicked(event, emit), 39 | copied: (event) => _onCopied(event, emit)); 40 | }); 41 | } 42 | 43 | final Ticker _ticker = const Ticker(); 44 | final Locator read; 45 | StreamSubscription? _tickerSubscription; 46 | 47 | void _onAction(ActionEvent event, Emitter emit) { 48 | emit(state.copyWith( 49 | duration: read().state.maybeMap( 50 | unlocked: (state) => 51 | state.vault.header.settings.vaultAutoLockSeconds, 52 | orElse: () => -1))); 53 | 54 | add(const ActivityEvent.started()); 55 | } 56 | 57 | void _onStarted(StartedEvent event, Emitter emit) { 58 | _tickerSubscription?.cancel(); 59 | _tickerSubscription = _ticker.tick(ticks: state.duration).listen((timer) { 60 | add(ActivityEvent.ticked(timer)); 61 | }); 62 | } 63 | 64 | void _onTicked(TickedEvent event, Emitter emit) { 65 | if (event.duration <= 0) { 66 | _tickerSubscription?.cancel(); 67 | emit(state.copyWith(duration: 0)); 68 | 69 | final vaultBloc = read(); 70 | vaultBloc.state.mapOrNull( 71 | unlocked: (state) => vaultBloc.add(const VaultEvent.locked())); 72 | } else { 73 | emit(state.copyWith(duration: event.duration)); 74 | } 75 | } 76 | 77 | void _onCopied(CopiedEvent event, Emitter emit) { 78 | emit(state.copyWith(passwordCopied: event.copied)); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /lib/blocs/activity_bloc/ticker.dart: -------------------------------------------------------------------------------- 1 | class Ticker { 2 | const Ticker(); 3 | Stream tick({required int ticks}) { 4 | return Stream.periodic(const Duration(seconds: 1), (x) => ticks - x - 1) 5 | .take(ticks); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /lib/blocs/app_settings_bloc/app_settings_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | 3 | import 'package:polypass/data/app_settings/app_settings.dart'; 4 | 5 | import 'package:freezed_annotation/freezed_annotation.dart'; 6 | part 'app_settings_bloc.freezed.dart'; 7 | 8 | @freezed 9 | class AppSettingsState with _$AppSettingsState { 10 | const factory AppSettingsState({required AppSettings settings}) = 11 | _AppSettingsState; 12 | 13 | factory AppSettingsState.empty() => 14 | AppSettingsState(settings: AppSettings.empty()); 15 | } 16 | 17 | @freezed 18 | class AppSettingsEvent with _$AppSettingsEvent { 19 | const factory AppSettingsEvent.settingsUpdated(AppSettings newSettings) = 20 | SettingsUpdatedEvent; 21 | } 22 | 23 | class AppSettingsBloc extends Bloc { 24 | AppSettingsBloc(AppSettings initialSettings) 25 | : super(AppSettingsState(settings: initialSettings)) { 26 | on((event, emit) { 27 | event.map(settingsUpdated: (event) => _onSettingsUpdated(event, emit)); 28 | }); 29 | } 30 | 31 | void _onSettingsUpdated( 32 | SettingsUpdatedEvent event, Emitter emit) { 33 | emit(AppSettingsState(settings: event.newSettings)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/blocs/create_form/create_form_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | import 'package:encrypt/encrypt.dart'; 3 | import 'package:provider/provider.dart'; 4 | import 'package:uuid/uuid.dart'; 5 | 6 | import 'package:polypass/data/vault_repository.dart'; 7 | import 'package:polypass/data/vault_file/vault_file.dart'; 8 | import 'package:polypass/data/app_settings/app_settings.dart'; 9 | import 'package:polypass/data/cache/cache.dart'; 10 | import 'package:polypass/blocs/app_settings_bloc/app_settings_bloc.dart'; 11 | import 'package:polypass/main.dart' show polypassMajorVersion; 12 | 13 | import 'package:freezed_annotation/freezed_annotation.dart'; 14 | part 'create_form_bloc.freezed.dart'; 15 | 16 | @freezed 17 | class CreateFormState with _$CreateFormState { 18 | const CreateFormState._(); 19 | const factory CreateFormState( 20 | {required String name, 21 | required String masterPassword, 22 | required VaultUrl? url, 23 | required bool submitted, 24 | required bool created, 25 | required int errorCount}) = _CreateFormState; 26 | 27 | factory CreateFormState.empty() => const CreateFormState( 28 | name: '', 29 | masterPassword: '', 30 | url: null, 31 | submitted: false, 32 | created: false, 33 | errorCount: 0); 34 | 35 | bool get isFormValid => 36 | (name != '') && (masterPassword != '') && (url != null); 37 | } 38 | 39 | @freezed 40 | class CreateFormEvent with _$CreateFormEvent { 41 | const factory CreateFormEvent.nameChanged(String name) = NameChangedEvent; 42 | const factory CreateFormEvent.masterPasswordChanged(String masterPassword) = 43 | MasterPasswordChangedEvent; 44 | const factory CreateFormEvent.urlChanged(VaultUrl url) = UrlChangedEvent; 45 | const factory CreateFormEvent.formSubmitted() = FormSubmittedEvent; 46 | const factory CreateFormEvent.dataCleared() = DataClearedEvent; 47 | } 48 | 49 | class CreateFormBloc extends Bloc { 50 | CreateFormBloc( 51 | {required this.vaultRepository, 52 | required this.appSettings, 53 | required this.read}) 54 | : super(CreateFormState.empty()) { 55 | on((event, emit) async { 56 | await event.map( 57 | nameChanged: (event) => _onNameChanged(event, emit), 58 | masterPasswordChanged: (event) => 59 | _onMasterPasswordChanged(event, emit), 60 | urlChanged: (event) => _onPathChanged(event, emit), 61 | formSubmitted: (event) => _onFormSubmitted(event, emit), 62 | dataCleared: (event) => _onDataCleared(event, emit)); 63 | }); 64 | } 65 | 66 | final VaultRepository vaultRepository; 67 | final AppSettings appSettings; 68 | final Locator read; 69 | 70 | Future _onNameChanged( 71 | NameChangedEvent event, Emitter emit) async { 72 | emit(state.copyWith(name: event.name)); 73 | } 74 | 75 | Future _onMasterPasswordChanged( 76 | MasterPasswordChangedEvent event, Emitter emit) async { 77 | emit(state.copyWith(masterPassword: event.masterPassword)); 78 | } 79 | 80 | Future _onPathChanged( 81 | UrlChangedEvent event, Emitter emit) async { 82 | emit(state.copyWith(url: event.url)); 83 | } 84 | 85 | Future _onFormSubmitted( 86 | FormSubmittedEvent event, Emitter emit) async { 87 | emit(state.copyWith(submitted: true)); 88 | 89 | final salt = EncryptedData.generateSalt(); 90 | final derivedKey = EncryptedData.deriveDerivedKey( 91 | state.masterPassword, salt, appSettings.defaultVaultSettings); 92 | final masterKey = EncryptedData.deriveMasterKey( 93 | Key.fromSecureRandom(256).base64, 94 | salt, 95 | appSettings.defaultVaultSettings); 96 | final iv = IV.fromSecureRandom(16); 97 | 98 | final uuid = const Uuid().v4(); 99 | 100 | EncryptedData? remoteUrl; 101 | VaultUrl? url; 102 | 103 | state.url!.maybeMap(file: (value) { 104 | remoteUrl = null; 105 | url = value; 106 | }, cached: (value) { 107 | remoteUrl = null; 108 | url = value; 109 | }, orElse: () { 110 | remoteUrl = EncryptedData.decrypted( 111 | state.url!, IV.fromSecureRandom(16), polypassMajorVersion) 112 | .encrypt(masterKey); 113 | url = VaultUrl.cached(uuid: uuid); 114 | }); 115 | 116 | var newVaultFile = VaultFile( 117 | header: VaultHeader( 118 | majorVersion: polypassMajorVersion, 119 | name: state.name, 120 | uuid: uuid, 121 | remoteUrl: remoteUrl, 122 | lastUpdate: DateTime.now(), 123 | settings: appSettings.defaultVaultSettings, 124 | magic: MagicValue(Encrypter(AES(derivedKey)) 125 | .encrypt(MagicValue.decryptedValue.value, iv: iv) 126 | .base64), 127 | key: Encrypter(AES(derivedKey)) 128 | .encrypt(masterKey.base64, iv: iv) 129 | .base64, 130 | salt: salt), 131 | url: url, 132 | contents: EncryptedData.decrypted( 133 | VaultContents(components: []), iv, polypassMajorVersion)); 134 | 135 | if (remoteUrl != null) { 136 | addToCache(newVaultFile); 137 | } 138 | 139 | try { 140 | final success = await vaultRepository.updateFile( 141 | newVaultFile, masterKey, read()); 142 | 143 | if (!success) { 144 | emit( 145 | state.copyWith(errorCount: state.errorCount + 1, submitted: false)); 146 | return; 147 | } 148 | } catch (e) { 149 | emit(state.copyWith(errorCount: state.errorCount + 1, submitted: false)); 150 | await vaultRepository.clearPoison(url!); 151 | return; 152 | } 153 | 154 | emit(state.copyWith(created: true, url: newVaultFile.url)); 155 | } 156 | 157 | Future _onDataCleared( 158 | DataClearedEvent event, Emitter emit) async { 159 | emit(CreateFormState.empty()); 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /lib/blocs/recent_bloc/recent_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | 3 | import 'package:polypass/data/vault_file/vault_file.dart'; 4 | 5 | import 'package:freezed_annotation/freezed_annotation.dart'; 6 | part 'recent_bloc.freezed.dart'; 7 | 8 | @freezed 9 | class RecentState with _$RecentState { 10 | const factory RecentState({ 11 | VaultUrl? recentUrl, 12 | }) = _RecentState; 13 | } 14 | 15 | @freezed 16 | class RecentEvent with _$RecentEvent { 17 | const factory RecentEvent.recentUrlChanged(VaultUrl? recentUrl) = 18 | RecentUrlChangedEvent; 19 | } 20 | 21 | class RecentBloc extends Bloc { 22 | RecentBloc() : super(const RecentState()) { 23 | on((event, emit) { 24 | event.map(recentUrlChanged: (event) => _onRecentUrlChanged(event, emit)); 25 | }); 26 | } 27 | 28 | void _onRecentUrlChanged( 29 | RecentUrlChangedEvent event, Emitter emit) { 30 | emit(state.copyWith(recentUrl: event.recentUrl)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/components/activity_listener/activity_listener.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/services.dart'; 3 | import 'package:flutter_bloc/flutter_bloc.dart'; 4 | import 'package:flutter_window_close/flutter_window_close.dart'; 5 | 6 | import 'package:polypass/blocs/activity_bloc/activity_bloc.dart'; 7 | 8 | class ActivityListener extends StatelessWidget { 9 | const ActivityListener({super.key, required this.child}); 10 | 11 | final Widget child; 12 | 13 | @override 14 | Widget build(BuildContext context) { 15 | FlutterWindowClose.setWindowShouldCloseHandler(() async { 16 | final copied = context.read().state.passwordCopied; 17 | if (copied) { 18 | await Clipboard.setData(const ClipboardData(text: '')); 19 | } 20 | 21 | return true; 22 | }); 23 | 24 | HardwareKeyboard.instance.addHandler((event) { 25 | if (event is KeyDownEvent && !event.synthesized) { 26 | context.read().add(const ActivityEvent.action()); 27 | } 28 | 29 | return false; 30 | }); 31 | 32 | return Listener( 33 | onPointerDown: (event) { 34 | context.read().add(const ActivityEvent.action()); 35 | }, 36 | child: child, 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/components/app_wrapper/app_wrapper.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:go_router/go_router.dart'; 4 | 5 | import 'package:polypass/blocs/vault_bloc/vault_bloc.dart'; 6 | 7 | import 'package:polypass/components/app_wrapper/app_bar.dart'; 8 | 9 | class AppWrapper extends StatelessWidget { 10 | const AppWrapper( 11 | {Key? key, 12 | required this.child, 13 | this.actions = true, 14 | this.icon = true, 15 | this.appBar = true, 16 | this.backButton = false, 17 | this.backDest = '/'}) 18 | : super(key: key); 19 | 20 | final Widget child; 21 | final bool actions; 22 | final bool icon; 23 | final bool appBar; 24 | final bool backButton; 25 | final String backDest; 26 | 27 | @override 28 | Widget build(BuildContext context) { 29 | return MultiBlocListener( 30 | listeners: [ 31 | BlocListener( 32 | listener: (context, state) { 33 | final router = GoRouter.of(context); 34 | ScaffoldMessenger.of(context).clearSnackBars(); 35 | 36 | state.mapOrNull( 37 | locked: (state) => router.go('/vault/locked'), 38 | unlocked: (state) => router.go('/vault/home'), 39 | none: (state) => router.go('/')); 40 | }, 41 | ), 42 | BlocListener( 43 | listener: (context, state) { 44 | ScaffoldMessenger.of(context).hideCurrentSnackBar(); 45 | 46 | ScaffoldMessenger.of(context).showSnackBar(const SnackBar( 47 | content: Text( 48 | 'Failed to save changes to vault - please try again'))); 49 | }, 50 | listenWhen: (previous, current) => 51 | previous.maybeMap( 52 | unlocked: (state) => state.errorCounts, orElse: () => 0) < 53 | current.maybeMap( 54 | unlocked: (state) => state.errorCounts, orElse: () => 0)) 55 | ], 56 | child: Scaffold( 57 | appBar: appBar 58 | ? createAppBar(context, context.watch().state, actions, 59 | icon, backButton, backDest) 60 | : null, 61 | body: SizedBox.expand( 62 | child: Container( 63 | color: Theme.of(context).colorScheme.background, child: child), 64 | )), 65 | ); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /lib/components/location_dialog/location_dialog.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:go_router/go_router.dart'; 3 | import 'package:file_picker/file_picker.dart'; 4 | import 'dart:io'; 5 | 6 | import 'package:polypass/data/vault_file/vault_file.dart'; 7 | import 'package:polypass/data/app_settings/app_settings.dart'; 8 | 9 | class LocationDialog extends StatelessWidget { 10 | const LocationDialog( 11 | {Key? key, 12 | required this.onSuccess, 13 | required this.onCancel, 14 | required this.redirect, 15 | required this.vaultName}) 16 | : super(key: key); 17 | 18 | final void Function(VaultUrl path) onSuccess; 19 | final void Function() onCancel; 20 | final String redirect; 21 | final String vaultName; 22 | 23 | @override 24 | Widget build(BuildContext context) { 25 | final theme = Theme.of(context); 26 | 27 | return Dialog( 28 | shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), 29 | child: Container( 30 | decoration: BoxDecoration( 31 | color: theme.colorScheme.background, 32 | border: Border.all( 33 | color: theme.appBarTheme.backgroundColor!, width: 5), 34 | borderRadius: BorderRadius.circular(10)), 35 | constraints: const BoxConstraints(maxHeight: 400, maxWidth: 800), 36 | padding: const EdgeInsets.all(10), 37 | child: Column( 38 | mainAxisAlignment: MainAxisAlignment.center, 39 | mainAxisSize: MainAxisSize.min, 40 | children: [ 41 | FtpButton( 42 | redirect: redirect, 43 | ), 44 | LocalButton( 45 | onSuccess: onSuccess, 46 | vaultName: vaultName, 47 | ), 48 | CancelButton(onCancel: onCancel) 49 | ], 50 | ))); 51 | } 52 | } 53 | 54 | class FtpButton extends StatelessWidget { 55 | const FtpButton({Key? key, required this.redirect}) : super(key: key); 56 | 57 | final String redirect; 58 | 59 | @override 60 | Widget build(BuildContext context) { 61 | final router = GoRouter.of(context); 62 | 63 | return Container( 64 | margin: const EdgeInsets.only(bottom: 10), 65 | child: ElevatedButton( 66 | style: ButtonStyle( 67 | padding: MaterialStateProperty.all(const EdgeInsets.all(15))), 68 | child: 69 | Text('Save via FTP', style: Theme.of(context).textTheme.bodyMedium), 70 | onPressed: () => router.go('/ftp?redirect=$redirect'), 71 | ), 72 | ); 73 | } 74 | } 75 | 76 | class LocalButton extends StatelessWidget { 77 | const LocalButton( 78 | {Key? key, required this.onSuccess, required this.vaultName}) 79 | : super(key: key); 80 | 81 | final void Function(VaultUrl path) onSuccess; 82 | final String vaultName; 83 | 84 | @override 85 | Widget build(BuildContext context) { 86 | return Container( 87 | margin: const EdgeInsets.only(bottom: 10), 88 | child: ElevatedButton( 89 | style: ButtonStyle( 90 | padding: MaterialStateProperty.all(const EdgeInsets.all(15))), 91 | child: 92 | Text('Save locally', style: Theme.of(context).textTheme.bodyMedium), 93 | onPressed: () async { 94 | final vaultDir = AppSettings.polypassDir; 95 | final VaultUrl path; 96 | 97 | if (Platform.isAndroid) { 98 | path = VaultUrl.file( 99 | '$vaultDir/${vaultName == '' ? 'Passwords' : vaultName}.ppv.json'); 100 | } else { 101 | final result = await FilePicker.platform.saveFile( 102 | initialDirectory: vaultDir, 103 | dialogTitle: 'Set vault file location', 104 | fileName: vaultName == '' 105 | ? 'Passwords.ppv.json' 106 | : '$vaultName.ppv.json', 107 | type: FileType.custom, 108 | allowedExtensions: ['ppv.json']); 109 | 110 | if (result == null) { 111 | return; 112 | } 113 | 114 | path = VaultUrl.file(result); 115 | } 116 | 117 | onSuccess(path); 118 | }, 119 | ), 120 | ); 121 | } 122 | } 123 | 124 | class CancelButton extends StatelessWidget { 125 | const CancelButton({Key? key, required this.onCancel}) : super(key: key); 126 | 127 | final void Function() onCancel; 128 | 129 | @override 130 | Widget build(BuildContext context) { 131 | return ElevatedButton( 132 | style: ButtonStyle( 133 | padding: MaterialStateProperty.all(const EdgeInsets.all(15))), 134 | onPressed: onCancel, 135 | child: Text('Cancel', style: Theme.of(context).textTheme.bodyMedium), 136 | ); 137 | } 138 | } 139 | 140 | Future saveFileLocation( 141 | BuildContext context, String redirect, String vaultName) async { 142 | VaultUrl? path; 143 | 144 | await showDialog( 145 | context: context, 146 | builder: (context) => LocationDialog( 147 | onSuccess: (dialogPath) { 148 | path = dialogPath; 149 | Navigator.of(context, rootNavigator: true).pop(); 150 | }, 151 | onCancel: () { 152 | Navigator.of(context, rootNavigator: true).pop(); 153 | }, 154 | redirect: redirect, 155 | vaultName: vaultName)); 156 | 157 | return path; 158 | } 159 | -------------------------------------------------------------------------------- /lib/components/master_password_dialog/master_password_dialog_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | import 'package:bloc/bloc.dart'; 3 | import 'package:encrypt/encrypt.dart'; 4 | 5 | import 'package:polypass/data/vault_file/vault_file.dart'; 6 | 7 | import 'package:freezed_annotation/freezed_annotation.dart'; 8 | part 'master_password_dialog_bloc.freezed.dart'; 9 | 10 | enum MasterPasswordDialogStatus { wait, validating, failed, canceled, success } 11 | 12 | @freezed 13 | class MasterPasswordDialogState with _$MasterPasswordDialogState { 14 | const MasterPasswordDialogState._(); 15 | const factory MasterPasswordDialogState( 16 | {required String masterPassword, 17 | required Key? masterKey, 18 | required Key? derivedKey, 19 | required MasterPasswordDialogStatus status}) = _MasterPasswordDialogState; 20 | 21 | factory MasterPasswordDialogState.empty() => const MasterPasswordDialogState( 22 | masterPassword: 'masterPassword', 23 | masterKey: null, 24 | derivedKey: null, 25 | status: MasterPasswordDialogStatus.wait); 26 | 27 | bool get isFormValid => masterPassword != ''; 28 | } 29 | 30 | @freezed 31 | class MasterPasswordDialogEvent with _$MasterPasswordDialogEvent { 32 | const factory MasterPasswordDialogEvent.masterPasswordChanged( 33 | String masterPassword) = MasterPasswordChangedEvent; 34 | const factory MasterPasswordDialogEvent.masterPasswordSubmitted() = 35 | MasterPasswordSubmittedEvent; 36 | const factory MasterPasswordDialogEvent.canceled() = CanceledEvent; 37 | } 38 | 39 | class MasterPasswordDialogBloc 40 | extends Bloc { 41 | MasterPasswordDialogBloc({required this.vaultFile}) 42 | : super(MasterPasswordDialogState.empty()) { 43 | on((event, emit) { 44 | event.map( 45 | masterPasswordChanged: (event) => 46 | _onMasterPasswordChanged(event, emit), 47 | masterPasswordSubmitted: (event) => 48 | _onMasterPasswordSubmitted(event, emit), 49 | canceled: (event) => _onCanceled(event, emit)); 50 | }); 51 | } 52 | 53 | final VaultFile vaultFile; 54 | 55 | void _onMasterPasswordChanged(MasterPasswordChangedEvent event, 56 | Emitter emit) { 57 | emit(state.copyWith(masterPassword: event.masterPassword)); 58 | } 59 | 60 | void _onMasterPasswordSubmitted(MasterPasswordSubmittedEvent event, 61 | Emitter emit) { 62 | emit(state.copyWith(status: MasterPasswordDialogStatus.validating)); 63 | 64 | final derivedKey = EncryptedData.deriveDerivedKey(state.masterPassword, 65 | Uint8List.fromList(vaultFile.header.salt), vaultFile.header.settings); 66 | 67 | if (vaultFile.header.testMagic(derivedKey, vaultFile.contents.iv)) { 68 | emit(state.copyWith( 69 | status: MasterPasswordDialogStatus.success, 70 | masterKey: vaultFile.header 71 | .decryptMasterKey(derivedKey, vaultFile.contents.iv), 72 | derivedKey: derivedKey)); 73 | } else { 74 | emit(state.copyWith(status: MasterPasswordDialogStatus.failed)); 75 | } 76 | } 77 | 78 | void _onCanceled( 79 | CanceledEvent event, Emitter emit) { 80 | emit(state.copyWith(status: MasterPasswordDialogStatus.canceled)); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /lib/components/merge_conflict_dialog/merge_conflict_dialog.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'package:polypass/data/vault_file/vault_file.dart'; 4 | 5 | class MergeConflictDialog extends StatelessWidget { 6 | const MergeConflictDialog( 7 | {Key? key, 8 | required this.onResolve, 9 | required this.localFile, 10 | required this.remoteFile}) 11 | : super(key: key); 12 | 13 | final void Function(VaultFile resolvedFile) onResolve; 14 | final VaultFile localFile; 15 | final VaultFile remoteFile; 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | final theme = Theme.of(context); 20 | 21 | return Dialog( 22 | shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), 23 | child: Container( 24 | decoration: BoxDecoration( 25 | color: theme.colorScheme.background, 26 | border: Border.all( 27 | color: theme.appBarTheme.backgroundColor!, width: 5), 28 | borderRadius: BorderRadius.circular(10)), 29 | constraints: const BoxConstraints(maxHeight: 250, maxWidth: 700), 30 | padding: const EdgeInsets.all(10), 31 | child: Column( 32 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 33 | children: [ 34 | Text('Merge Conflict', style: theme.textTheme.titleMedium), 35 | Text( 36 | 'There have been changes to this file on multiple devices since the last sync. Please select a version to keep.', 37 | style: TextStyle( 38 | fontSize: theme.textTheme.bodySmall!.fontSize, 39 | color: Colors.white), 40 | textAlign: TextAlign.center, 41 | ), 42 | Row( 43 | mainAxisSize: MainAxisSize.max, 44 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 45 | children: [ 46 | LocalButton(onResolve: onResolve, localFile: localFile), 47 | RemoteButton(onResolve: onResolve, remoteFile: remoteFile) 48 | ]) 49 | ], 50 | ))); 51 | } 52 | } 53 | 54 | class LocalButton extends StatelessWidget { 55 | const LocalButton( 56 | {Key? key, required this.onResolve, required this.localFile}) 57 | : super(key: key); 58 | 59 | final Function(VaultFile resolvedFile) onResolve; 60 | final VaultFile localFile; 61 | 62 | @override 63 | Widget build(BuildContext context) { 64 | return ElevatedButton( 65 | child: const Text('Local', 66 | style: TextStyle(color: Colors.white, fontSize: 25)), 67 | onPressed: () { 68 | onResolve(localFile); 69 | }, 70 | ); 71 | } 72 | } 73 | 74 | class RemoteButton extends StatelessWidget { 75 | const RemoteButton( 76 | {Key? key, required this.onResolve, required this.remoteFile}) 77 | : super(key: key); 78 | 79 | final Function(VaultFile resolvedFile) onResolve; 80 | final VaultFile remoteFile; 81 | 82 | @override 83 | Widget build(BuildContext context) { 84 | return ElevatedButton( 85 | child: const Text('Remote', 86 | style: TextStyle(color: Colors.white, fontSize: 25)), 87 | onPressed: () { 88 | onResolve(remoteFile); 89 | }, 90 | ); 91 | } 92 | } 93 | 94 | Future resolveConflict(BuildContext context, 95 | {required VaultFile local, required VaultFile remote}) async { 96 | VaultFile? resolvedFile; 97 | 98 | await showDialog( 99 | context: context, 100 | builder: (context) => MergeConflictDialog( 101 | onResolve: (dialogResolvedFile) { 102 | resolvedFile = dialogResolvedFile; 103 | Navigator.of(context, rootNavigator: true).pop(); 104 | }, 105 | localFile: local, 106 | remoteFile: remote)); 107 | 108 | return resolvedFile!; 109 | } 110 | -------------------------------------------------------------------------------- /lib/data/app_settings/app_settings.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:io'; 3 | import 'package:path_provider/path_provider.dart'; 4 | import 'package:flutter/foundation.dart'; 5 | 6 | import 'package:polypass/data/vault_file/vault_file.dart'; 7 | 8 | import 'package:freezed_annotation/freezed_annotation.dart'; 9 | part 'app_settings.freezed.dart'; 10 | part 'app_settings.g.dart'; 11 | 12 | @Freezed(makeCollectionsUnmodifiable: false) 13 | class AppSettings with _$AppSettings { 14 | AppSettings._(); 15 | factory AppSettings( 16 | {required VaultSettings defaultVaultSettings, 17 | required VaultUrl? recentUrl, 18 | required Map lastSyncMap}) = _AppSettings; 19 | 20 | static final documentsDir = Platform.isAndroid 21 | ? getExternalStorageDirectory() 22 | : getApplicationDocumentsDirectory(); 23 | 24 | static late final String polypassDir; 25 | 26 | static Future loadPolypassDir() async { 27 | final polyPassDir = Directory( 28 | '${(await documentsDir)?.absolute.path}${Platform.pathSeparator}${kDebugMode ? 'polypass_debug' : 'polypass'}'); 29 | if (!await polyPassDir.exists()) { 30 | await polyPassDir.create(); 31 | } 32 | polypassDir = polyPassDir.absolute.path; 33 | } 34 | 35 | static Future load() async { 36 | await loadPolypassDir(); 37 | final file = File('$polypassDir/.settings.json'); 38 | 39 | if (!(await file.exists())) { 40 | await file.writeAsString(jsonEncode(AppSettings.empty().toJson())); 41 | return AppSettings.empty(); 42 | } 43 | 44 | final rawContents = await file.readAsString(); 45 | return AppSettings.fromJson(jsonDecode(rawContents)); 46 | } 47 | 48 | Future save() async { 49 | await File('$polypassDir/.settings.json') 50 | .writeAsString(jsonEncode(toJson())); 51 | } 52 | 53 | factory AppSettings.empty() => AppSettings( 54 | defaultVaultSettings: VaultSettings.empty(), 55 | recentUrl: null, 56 | lastSyncMap: {}); 57 | factory AppSettings.fromJson(Map json) => 58 | _$AppSettingsFromJson(json); 59 | } 60 | -------------------------------------------------------------------------------- /lib/data/app_settings/app_settings.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'app_settings.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | _$_AppSettings _$$_AppSettingsFromJson(Map json) => _$_AppSettings( 10 | defaultVaultSettings: VaultSettings.fromJson( 11 | Map.from(json['defaultVaultSettings'] as Map)), 12 | recentUrl: json['recentUrl'] == null 13 | ? null 14 | : VaultUrl.fromJson( 15 | Map.from(json['recentUrl'] as Map)), 16 | lastSyncMap: (json['lastSyncMap'] as Map).map( 17 | (k, e) => MapEntry(k as String, DateTime.parse(e as String)), 18 | ), 19 | ); 20 | 21 | Map _$$_AppSettingsToJson(_$_AppSettings instance) => 22 | { 23 | 'defaultVaultSettings': instance.defaultVaultSettings.toJson(), 24 | 'recentUrl': instance.recentUrl?.toJson(), 25 | 'lastSyncMap': 26 | instance.lastSyncMap.map((k, e) => MapEntry(k, e.toIso8601String())), 27 | }; 28 | -------------------------------------------------------------------------------- /lib/data/cache/cache.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | import 'dart:convert'; 3 | 4 | import 'package:polypass/data/app_settings/app_settings.dart'; 5 | import 'package:polypass/data/vault_file/vault_file.dart'; 6 | 7 | void addToCache(VaultFile vaultFile) { 8 | final cacheDir = Directory('${AppSettings.polypassDir}/.cache'); 9 | 10 | if (!cacheDir.existsSync()) { 11 | cacheDir.createSync(); 12 | } 13 | 14 | final file = 15 | File('${cacheDir.absolute.path}/${vaultFile.header.uuid}.ppv.json'); 16 | 17 | file.writeAsStringSync(jsonEncode(vaultFile.toJson())); 18 | } 19 | 20 | Future getFromCache(String uuid) async { 21 | final cacheDir = Directory('${AppSettings.polypassDir}/.cache'); 22 | 23 | if (!(await cacheDir.exists())) { 24 | await cacheDir.create(); 25 | return null; 26 | } 27 | 28 | final cachedFiles = await cacheDir.list().toList(); 29 | 30 | final File cachedFile; 31 | try { 32 | cachedFile = cachedFiles.firstWhere( 33 | (file) => file.path.endsWith('$uuid.ppv.json') && file is File) as File; 34 | } catch (e) { 35 | return null; 36 | } 37 | 38 | final contents = await cachedFile.readAsString(); 39 | 40 | final result = initVaultFile(jsonDecode(contents)); 41 | 42 | if (result.migrated) { 43 | await cachedFile.writeAsString(jsonEncode(result.vaultFile.toJson())); 44 | } 45 | 46 | return result.vaultFile; 47 | } 48 | 49 | FileVaultUrl cachedUrltoFileUrl(CachedVaultUrl cachedUrl) { 50 | final cachedFile = 51 | File('${AppSettings.polypassDir}/.cache/${cachedUrl.uuid}.ppv.json'); 52 | 53 | if (!(cachedFile.existsSync())) { 54 | throw Exception('FILE_NOT_IN_CACHE'); 55 | } 56 | 57 | return VaultUrl.file(cachedFile.absolute.path).mapOrNull(file: (url) => url)!; 58 | } 59 | 60 | VaultFile syncCachedAndRemote( 61 | {required VaultFile localFile, 62 | required VaultFile remoteFile, 63 | required Map lastSyncMap, 64 | required String uuid}) { 65 | var lastSync = lastSyncMap[uuid]; 66 | 67 | if (lastSync == null) { 68 | return remoteFile; 69 | } 70 | 71 | final localUpdated = localFile.header.lastUpdate.isAfter(lastSync); 72 | final remoteUpdated = remoteFile.header.lastUpdate.isAfter(lastSync); 73 | 74 | if (localUpdated) { 75 | if (remoteUpdated) { 76 | throw MergeException(local: localFile, remote: remoteFile); 77 | } else { 78 | return localFile; 79 | } 80 | } else { 81 | return remoteFile; 82 | } 83 | } 84 | 85 | class MergeException implements Exception { 86 | const MergeException({required this.local, required this.remote}); 87 | 88 | final VaultFile local; 89 | final VaultFile remote; 90 | } 91 | -------------------------------------------------------------------------------- /lib/data/migration.dart: -------------------------------------------------------------------------------- 1 | import 'package:uuid/uuid.dart'; 2 | import 'dart:io'; 3 | import 'dart:convert'; 4 | 5 | import 'package:polypass/data/vault_file/vault_file.dart'; 6 | import 'package:polypass/data/app_settings/app_settings.dart'; 7 | 8 | const fileMigrationMap = {2: migrateFileV1ToV2}; 9 | const contentsMigrationMap = {2: migrateContentsV1ToV2}; 10 | const passwordMigrationMap = {2: migratePasswordV1ToV2}; 11 | const magicValueMigrationMap = {2: migrateMagicValueV1ToV2}; 12 | const urlMigrationMap = {2: migrateUrlV1ToV2}; 13 | 14 | VaultFile migrateFile( 15 | Map originalJson, int fromVersion, int toVersion) { 16 | if (fromVersion > toVersion) { 17 | throw Exception('Cannot migrate from $fromVersion to $toVersion'); 18 | } 19 | 20 | final backupFile = File('${AppSettings.polypassDir}/.backup.ppv.json'); 21 | backupFile.writeAsString(jsonEncode(originalJson)); 22 | 23 | Map json = originalJson; 24 | 25 | for (int i = fromVersion; i < toVersion; i++) { 26 | json = fileMigrationMap[i + 1]!(json); 27 | } 28 | 29 | return VaultFile.fromJson(json); 30 | } 31 | 32 | VaultContents migrateContents( 33 | Map originalJson, int fromVersion, int toVersion) { 34 | if (fromVersion > toVersion) { 35 | throw Exception('Cannot migrate from $fromVersion to $toVersion'); 36 | } 37 | 38 | Map json = originalJson; 39 | 40 | for (int i = fromVersion; i < toVersion; i++) { 41 | json = contentsMigrationMap[i + 1]!(json); 42 | } 43 | 44 | return VaultContents.fromJson(json); 45 | } 46 | 47 | VaultPassword migratePassword( 48 | Map originalJson, int fromVersion, int toVersion) { 49 | if (fromVersion > toVersion) { 50 | throw Exception('Cannot migrate from $fromVersion to $toVersion'); 51 | } 52 | 53 | Map json = originalJson; 54 | 55 | for (int i = fromVersion; i < toVersion; i++) { 56 | json = passwordMigrationMap[i + 1]!(json); 57 | } 58 | 59 | return VaultPassword.fromJson(json); 60 | } 61 | 62 | MagicValue migrateMagicValue( 63 | Map originalJson, int fromVersion, int toVersion) { 64 | if (fromVersion > toVersion) { 65 | throw Exception('Cannot migrate from $fromVersion to $toVersion'); 66 | } 67 | 68 | Map json = originalJson; 69 | 70 | for (int i = fromVersion; i < toVersion; i++) { 71 | json = magicValueMigrationMap[i + 1]!(json); 72 | } 73 | 74 | return MagicValue.fromJson(json); 75 | } 76 | 77 | VaultUrl migrateUrl( 78 | Map originalJson, int fromVersion, int toVersion) { 79 | if (fromVersion > toVersion) { 80 | throw Exception('Cannot migrate from $fromVersion to $toVersion'); 81 | } 82 | 83 | Map json = originalJson; 84 | 85 | for (int i = fromVersion; i < toVersion; i++) { 86 | json = urlMigrationMap[i + 1]!(json); 87 | } 88 | 89 | return VaultUrl.fromJson(json); 90 | } 91 | 92 | Map migrateFileV1ToV2(Map json) { 93 | final migratedJson = json; 94 | 95 | migratedJson['header']['majorVersion'] = 2; 96 | migratedJson['header']['uuid'] = const Uuid().v4(); 97 | migratedJson['header']['remoteUrl'] = null; 98 | migratedJson['header']['lastUpdate'] = DateTime.now().toIso8601String(); 99 | migratedJson['header']['settings']['vaultAutoLockSeconds'] = 120; 100 | migratedJson['header']['settings']['clipboardClearSeconds'] = 10; 101 | 102 | return migratedJson; 103 | } 104 | 105 | Map migrateContentsV1ToV2(Map json) { 106 | final migratedJson = json; 107 | 108 | final mapList = (migratedJson['components'] as List) 109 | .map((e) => e as Map) 110 | .toList(); 111 | 112 | migratedJson['components'] = addOpenToGroup(mapList); 113 | 114 | return migratedJson; 115 | } 116 | 117 | List> addOpenToGroup( 118 | List> groupContents) { 119 | final migratedContents = groupContents; 120 | 121 | for (int i = 0; i < migratedContents.length; i++) { 122 | if (migratedContents[i].containsKey('components')) { 123 | migratedContents[i]['expanded'] = false; 124 | migratedContents[i]['components'] = 125 | addOpenToGroup(migratedContents[i]['components']); 126 | } 127 | } 128 | 129 | return migratedContents; 130 | } 131 | 132 | Map migratePasswordV1ToV2(Map json) { 133 | return json; 134 | } 135 | 136 | Map migrateMagicValueV1ToV2(Map json) { 137 | return json; 138 | } 139 | 140 | Map migrateUrlV1ToV2(Map json) { 141 | return json; 142 | } 143 | -------------------------------------------------------------------------------- /lib/data/vault_providers.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:polypass/data/vault_file/vault_file.dart'; 4 | import 'package:polypass/ffi.dart'; 5 | 6 | class FileProvider { 7 | const FileProvider(); 8 | 9 | Future readFile(FileVaultUrl url) async { 10 | final file = File(url.path); 11 | final exists = await file.exists(); 12 | 13 | if (!exists) { 14 | throw Exception('NONEXISTENT_FILE: ${url.path}'); 15 | } 16 | 17 | final contents = await file.readAsString(); 18 | 19 | return contents; 20 | } 21 | 22 | Future updateFile(FileVaultUrl url, String contents) async { 23 | final file = File(url.path); 24 | await file.writeAsString(contents); 25 | } 26 | 27 | Future deleteFile(FileVaultUrl url) async { 28 | final file = File(url.path); 29 | final exists = await file.exists(); 30 | 31 | if (!exists) { 32 | throw Exception('NONEXISTENT_FILE: ${url.path}'); 33 | } 34 | 35 | await file.delete(); 36 | } 37 | 38 | Future fileExists(FileVaultUrl url) async { 39 | final file = File(url.path); 40 | return await file.exists(); 41 | } 42 | } 43 | 44 | class FtpProvider { 45 | FtpProvider(); 46 | 47 | RwLockFtpProvider providerLock = api.initializeLockedProvider(); 48 | 49 | Future checkConnection(FtpVaultUrl url) async { 50 | final ftpUrl = api.initializeFtpUrl( 51 | path: url.path, host: url.host, user: url.user, pass: url.password); 52 | await api.checkConnection(providerLock: providerLock, url: ftpUrl); 53 | ftpUrl.dispose(); 54 | } 55 | 56 | Future connect(FtpVaultUrl url) async { 57 | final ftpUrl = api.initializeFtpUrl( 58 | path: url.path, host: url.host, user: url.user, pass: url.password); 59 | await api.connect(providerLock: providerLock, url: ftpUrl); 60 | ftpUrl.dispose(); 61 | } 62 | 63 | Future disconnect() async { 64 | await api.disconnect(providerLock: providerLock); 65 | } 66 | 67 | Future readFile(FtpVaultUrl url) async { 68 | final ftpUrl = api.initializeFtpUrl( 69 | path: url.path, host: url.host, user: url.user, pass: url.password); 70 | final contents = 71 | await api.readFile(providerLock: providerLock, url: ftpUrl); 72 | ftpUrl.dispose(); 73 | return contents; 74 | } 75 | 76 | Future updateFile(FtpVaultUrl url, String contents) async { 77 | final ftpUrl = api.initializeFtpUrl( 78 | path: url.path, host: url.host, user: url.user, pass: url.password); 79 | await api.updateFile( 80 | providerLock: providerLock, url: ftpUrl, contents: contents); 81 | ftpUrl.dispose(); 82 | } 83 | 84 | Future deleteFile(FtpVaultUrl url) async { 85 | final ftpUrl = api.initializeFtpUrl( 86 | path: url.path, host: url.host, user: url.user, pass: url.password); 87 | await api.deleteFile(providerLock: providerLock, url: ftpUrl); 88 | ftpUrl.dispose(); 89 | } 90 | 91 | Future fileExists(FtpVaultUrl url) async { 92 | final ftpUrl = api.initializeFtpUrl( 93 | path: url.path, host: url.host, user: url.user, pass: url.password); 94 | final exists = 95 | await api.fileExists(providerLock: providerLock, url: ftpUrl); 96 | ftpUrl.dispose(); 97 | return exists; 98 | } 99 | 100 | Future clearPoison() async { 101 | await api.clearPoison(providerLock: providerLock); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /lib/ffi.dart: -------------------------------------------------------------------------------- 1 | // This file initializes the dynamic library and connects it with the stub 2 | // generated by flutter_rust_bridge_codegen. 3 | 4 | import 'dart:ffi'; 5 | 6 | import 'package:polypass/bridge_generated.dart'; 7 | 8 | // Re-export the bridge so it is only necessary to import this file. 9 | export 'bridge_generated.dart'; 10 | import 'dart:io' as io; 11 | 12 | const _base = 'libpolypass'; 13 | 14 | // On MacOS, the dynamic library is not bundled with the binary, 15 | // but rather directly **linked** against the binary. 16 | final _dylib = io.Platform.isWindows ? '$_base.dll' : 'lib$_base.so'; 17 | 18 | final Libpolypass api = LibpolypassImpl(io.Platform.isIOS || io.Platform.isMacOS 19 | ? DynamicLibrary.executable() 20 | : DynamicLibrary.open(_dylib)); 21 | -------------------------------------------------------------------------------- /lib/generated_plugin_registrant.dart: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // ignore_for_file: directives_ordering 6 | // ignore_for_file: lines_longer_than_80_chars 7 | // ignore_for_file: depend_on_referenced_packages 8 | 9 | import 'package:file_picker/_internal/file_picker_web.dart'; 10 | 11 | import 'package:flutter_web_plugins/flutter_web_plugins.dart'; 12 | 13 | // ignore: public_member_api_docs 14 | void registerPlugins(Registrar registrar) { 15 | FilePickerWeb.registerWith(registrar); 16 | registrar.registerMessageHandler(); 17 | } 18 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:go_router/go_router.dart'; 3 | import 'package:flutter_bloc/flutter_bloc.dart'; 4 | import 'package:sizer/sizer.dart'; 5 | 6 | import 'package:polypass/data/vault_repository.dart'; 7 | import 'package:polypass/data/app_settings/app_settings.dart'; 8 | import 'package:polypass/blocs/create_form/create_form_bloc.dart'; 9 | import 'package:polypass/blocs/activity_bloc/activity_bloc.dart'; 10 | import 'package:polypass/blocs/recent_bloc/recent_bloc.dart'; 11 | import 'package:polypass/blocs/vault_bloc/vault_bloc.dart'; 12 | import 'package:polypass/blocs/app_settings_bloc/app_settings_bloc.dart'; 13 | 14 | import 'package:polypass/pages/home/home.dart'; 15 | import 'package:polypass/pages/ftp/ftp.dart'; 16 | import 'package:polypass/pages/recent/recent.dart'; 17 | import 'package:polypass/pages/create/create.dart'; 18 | import 'package:polypass/pages/settings/settings.dart'; 19 | import 'package:polypass/pages/vault/home/home.dart'; 20 | import 'package:polypass/pages/vault/locked/locked.dart'; 21 | import 'package:polypass/pages/vault/new/new.dart'; 22 | import 'package:polypass/pages/vault/edit/edit.dart'; 23 | import 'package:polypass/pages/vault/settings/settings.dart'; 24 | import 'package:polypass/pages/generator/generator.dart'; 25 | import 'package:polypass/components/activity_listener/activity_listener.dart'; 26 | 27 | import 'package:polypass/theme.dart'; 28 | 29 | const polypassMajorVersion = 2; 30 | 31 | void main() async { 32 | WidgetsFlutterBinding.ensureInitialized(); 33 | final settings = await AppSettings.load(); 34 | runApp(App(initialSettings: settings)); 35 | } 36 | 37 | class App extends StatefulWidget { 38 | const App({super.key, required this.initialSettings}); 39 | 40 | final AppSettings initialSettings; 41 | 42 | @override 43 | // ignore: no_logic_in_create_state 44 | State createState() => _AppState(initialSettings: initialSettings); 45 | } 46 | 47 | class _AppState extends State with TickerProviderStateMixin { 48 | _AppState({required this.initialSettings}); 49 | 50 | final AppSettings initialSettings; 51 | 52 | late final fadeController = 53 | AnimationController(vsync: this, duration: const Duration(seconds: 1)) 54 | ..forward(); 55 | 56 | late final Animation fadeAnimation = CurvedAnimation( 57 | parent: fadeController, 58 | curve: Curves.ease, 59 | ); 60 | 61 | @override 62 | void dispose() { 63 | fadeController.dispose(); 64 | super.dispose(); 65 | } 66 | 67 | @override 68 | Widget build(BuildContext context) { 69 | final router = GoRouter(routes: [ 70 | GoRoute( 71 | path: '/', 72 | pageBuilder: (context, state) => CustomTransitionPage( 73 | key: state.pageKey, 74 | child: const Home(), 75 | transitionsBuilder: 76 | (context, animation, secondaryAnimation, child) => 77 | FadeTransition(opacity: fadeAnimation, child: child), 78 | )), 79 | GoRoute( 80 | path: '/ftp', 81 | builder: (context, state) => FtpInput(routerState: state)), 82 | GoRoute(path: '/recent', builder: (context, state) => const Recent()), 83 | GoRoute(path: '/create', builder: (context, state) => const Create()), 84 | GoRoute(path: '/settings', builder: (context, state) => const Settings()), 85 | GoRoute( 86 | path: '/generator', 87 | builder: (context, state) => Generator( 88 | routerState: state, 89 | )), 90 | GoRoute( 91 | path: '/vault/home', builder: (context, state) => const VaultHome()), 92 | GoRoute( 93 | path: '/vault/locked', 94 | builder: (context, state) => const VaultLocked()), 95 | GoRoute(path: '/vault/new', builder: (context, state) => const NewItem()), 96 | GoRoute( 97 | path: '/vault/edit/:path', 98 | builder: (context, state) => EditItem(routerState: state)), 99 | GoRoute( 100 | path: '/vault/settings', 101 | builder: (context, state) => const VaultSettingsPage()) 102 | ], initialLocation: '/recent'); 103 | 104 | return Sizer(builder: (context, orientation, deviceType) { 105 | return RepositoryProvider( 106 | create: (context) => VaultRepository(), 107 | child: MultiBlocProvider( 108 | providers: [ 109 | BlocProvider( 110 | create: (context) => AppSettingsBloc(initialSettings), 111 | ), 112 | BlocProvider( 113 | create: (context) => CreateFormBloc( 114 | vaultRepository: context.read(), 115 | appSettings: context.read().state.settings, 116 | read: context.read)), 117 | BlocProvider(create: (context) => VaultBloc(read: context.read)), 118 | BlocProvider( 119 | create: (context) => ActivityBloc(read: context.read) 120 | ..add(const ActivityEvent.started())), 121 | BlocProvider( 122 | create: (context) => RecentBloc(), 123 | ) 124 | ], 125 | child: ActivityListener( 126 | child: MaterialApp.router( 127 | routeInformationProvider: router.routeInformationProvider, 128 | routeInformationParser: router.routeInformationParser, 129 | routerDelegate: router.routerDelegate, 130 | title: 'Polypass', 131 | debugShowCheckedModeBanner: false, 132 | theme: appTheme), 133 | ), 134 | ), 135 | ); 136 | }); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /lib/pages/ftp/ftp_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | 3 | import 'package:freezed_annotation/freezed_annotation.dart'; 4 | part 'ftp_bloc.freezed.dart'; 5 | 6 | @freezed 7 | class FtpState with _$FtpState { 8 | const FtpState._(); 9 | const factory FtpState( 10 | {required String host, 11 | required String user, 12 | required String password, 13 | required String path, 14 | required bool submitted}) = _FtpState; 15 | 16 | factory FtpState.empty() => const FtpState( 17 | host: '', user: '', password: '', path: '', submitted: false); 18 | 19 | bool get isFormValid => 20 | host.isNotEmpty && 21 | user.isNotEmpty && 22 | password.isNotEmpty && 23 | path.isNotEmpty; 24 | } 25 | 26 | @freezed 27 | class FtpEvent with _$FtpEvent { 28 | const factory FtpEvent.hostChanged(String host) = HostChangedEvent; 29 | const factory FtpEvent.userChanged(String user) = UserChangedEvent; 30 | const factory FtpEvent.passwordChanged(String password) = 31 | PasswordChangedEvent; 32 | const factory FtpEvent.pathChanged(String path) = PathChangedEvent; 33 | const factory FtpEvent.submitted() = SubmittedEvent; 34 | const factory FtpEvent.errored() = ErroredEvent; 35 | } 36 | 37 | class FtpBloc extends Bloc { 38 | FtpBloc({String? host, String? user, String? password, String? path}) 39 | : super(FtpState( 40 | host: host ?? '', 41 | user: user ?? '', 42 | password: password ?? '', 43 | path: path ?? '', 44 | submitted: false)) { 45 | on((event, emit) { 46 | event.map( 47 | hostChanged: (event) => _onHostChanged(event, emit), 48 | userChanged: (event) => _onUserChanged(event, emit), 49 | passwordChanged: (event) => _onPasswordChanged(event, emit), 50 | pathChanged: (event) => _onPathChanged(event, emit), 51 | submitted: (event) => _onSubmitted(event, emit), 52 | errored: (event) => _onErrored(event, emit)); 53 | }); 54 | } 55 | 56 | void _onHostChanged(HostChangedEvent event, Emitter emit) { 57 | emit(state.copyWith(host: event.host)); 58 | } 59 | 60 | void _onUserChanged(UserChangedEvent event, Emitter emit) { 61 | emit(state.copyWith(user: event.user)); 62 | } 63 | 64 | void _onPasswordChanged(PasswordChangedEvent event, Emitter emit) { 65 | emit(state.copyWith(password: event.password)); 66 | } 67 | 68 | void _onPathChanged(PathChangedEvent event, Emitter emit) { 69 | emit(state.copyWith(path: event.path)); 70 | } 71 | 72 | void _onSubmitted(SubmittedEvent event, Emitter emit) { 73 | emit(state.copyWith(submitted: true)); 74 | } 75 | 76 | void _onErrored(ErroredEvent event, Emitter emit) { 77 | emit(state.copyWith(submitted: false)); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /lib/pages/generator/generator_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:bloc/bloc.dart'; 4 | 5 | import 'package:freezed_annotation/freezed_annotation.dart'; 6 | part 'generator_bloc.freezed.dart'; 7 | 8 | @freezed 9 | class GeneratorState with _$GeneratorState { 10 | const GeneratorState._(); 11 | const factory GeneratorState({ 12 | required String generatedPassword, 13 | required int length, 14 | required bool lowercase, 15 | required bool uppercase, 16 | required bool numbers, 17 | required bool symbols, 18 | }) = _GeneratorState; 19 | 20 | factory GeneratorState.empty() => GeneratorState( 21 | generatedPassword: generatePassword(10, true, true, true, true), 22 | length: 10, 23 | lowercase: true, 24 | uppercase: true, 25 | numbers: true, 26 | symbols: true, 27 | ); 28 | } 29 | 30 | @freezed 31 | class GeneratorEvent with _$GeneratorEvent { 32 | const factory GeneratorEvent.lengthChanged(int length) = LengthChangedEvent; 33 | const factory GeneratorEvent.lowercaseChanged(bool lowercase) = 34 | LowercaseChangedEvent; 35 | const factory GeneratorEvent.uppercaseChanged(bool uppercase) = 36 | UppercaseChangedEvent; 37 | const factory GeneratorEvent.numbersChanged(bool numbers) = 38 | NumbersChangedEvent; 39 | const factory GeneratorEvent.symbolsChanged(bool symbols) = 40 | SymbolsChangedEvent; 41 | const factory GeneratorEvent.regeneratePassword() = RegeneratePasswordEvent; 42 | } 43 | 44 | class GeneratorBloc extends Bloc { 45 | GeneratorBloc() : super(GeneratorState.empty()) { 46 | on((event, emit) { 47 | event.map( 48 | lengthChanged: (event) => _onLengthChanged(event, emit), 49 | lowercaseChanged: (event) => _onLowercaseChanged(event, emit), 50 | uppercaseChanged: (event) => _onUppercaseChanged(event, emit), 51 | numbersChanged: (event) => _onNumbersChanged(event, emit), 52 | symbolsChanged: (event) => _onSymbolsChanged(event, emit), 53 | regeneratePassword: (event) => _onRegeneratePassword(event, emit), 54 | ); 55 | }); 56 | } 57 | 58 | void _onLengthChanged( 59 | LengthChangedEvent event, Emitter emit) { 60 | emit(state.copyWith( 61 | length: event.length, 62 | generatedPassword: generatePassword( 63 | event.length, 64 | state.lowercase, 65 | state.uppercase, 66 | state.numbers, 67 | state.symbols, 68 | ))); 69 | } 70 | 71 | void _onLowercaseChanged( 72 | LowercaseChangedEvent event, Emitter emit) { 73 | emit(state.copyWith( 74 | lowercase: event.lowercase, 75 | generatedPassword: generatePassword( 76 | state.length, 77 | event.lowercase, 78 | state.uppercase, 79 | state.numbers, 80 | state.symbols, 81 | ))); 82 | } 83 | 84 | void _onUppercaseChanged( 85 | UppercaseChangedEvent event, Emitter emit) { 86 | emit(state.copyWith( 87 | uppercase: event.uppercase, 88 | generatedPassword: generatePassword( 89 | state.length, 90 | state.lowercase, 91 | event.uppercase, 92 | state.numbers, 93 | state.symbols, 94 | ))); 95 | } 96 | 97 | void _onNumbersChanged( 98 | NumbersChangedEvent event, Emitter emit) { 99 | emit(state.copyWith( 100 | numbers: event.numbers, 101 | generatedPassword: generatePassword( 102 | state.length, 103 | state.lowercase, 104 | state.uppercase, 105 | event.numbers, 106 | state.symbols, 107 | ))); 108 | } 109 | 110 | void _onSymbolsChanged( 111 | SymbolsChangedEvent event, Emitter emit) { 112 | emit(state.copyWith( 113 | symbols: event.symbols, 114 | generatedPassword: generatePassword( 115 | state.length, 116 | state.lowercase, 117 | state.uppercase, 118 | state.numbers, 119 | event.symbols, 120 | ))); 121 | } 122 | 123 | void _onRegeneratePassword( 124 | RegeneratePasswordEvent event, Emitter emit) { 125 | emit(state.copyWith( 126 | generatedPassword: generatePassword( 127 | state.length, 128 | state.lowercase, 129 | state.uppercase, 130 | state.numbers, 131 | state.symbols, 132 | ))); 133 | } 134 | } 135 | 136 | String generatePassword( 137 | int length, bool lowercase, bool uppercase, bool numbers, bool symbols) { 138 | var alphabetBuffer = StringBuffer(); 139 | if (lowercase) alphabetBuffer.write('abcdefghijklmnopqrstuvwxyz'); 140 | if (uppercase) alphabetBuffer.write('ABCDEFGHIJKLMNOPQRSTUVWXYZ'); 141 | if (numbers) alphabetBuffer.write('0123456789'); 142 | if (symbols) alphabetBuffer.write('!@#\$%^&*()_+-=[]{}\\|;\':",./<>?'); 143 | 144 | final alphabet = alphabetBuffer.toString(); 145 | 146 | if (alphabet.isEmpty) return ''; 147 | 148 | final password = StringBuffer(); 149 | for (var i = 0; i < length; i++) { 150 | password.write(alphabet[Random.secure().nextInt(alphabet.length - 1)]); 151 | } 152 | 153 | return password.toString(); 154 | } 155 | -------------------------------------------------------------------------------- /lib/pages/recent/recent.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:go_router/go_router.dart'; 4 | import 'package:polypass/components/app_wrapper/app_wrapper.dart'; 5 | 6 | import 'package:polypass/blocs/app_settings_bloc/app_settings_bloc.dart'; 7 | import 'package:polypass/blocs/recent_bloc/recent_bloc.dart'; 8 | import 'package:polypass/data/vault_repository.dart'; 9 | 10 | class Recent extends StatelessWidget { 11 | const Recent({Key? key}) : super(key: key); 12 | 13 | @override 14 | Widget build(BuildContext context) { 15 | final router = GoRouter.of(context); 16 | final appSettingsBloc = context.read(); 17 | var recentUrl = appSettingsBloc.state.settings.recentUrl; 18 | 19 | if (recentUrl != null) { 20 | context.read().fileExists(recentUrl).then((exists) { 21 | if (!exists) { 22 | appSettingsBloc.add(AppSettingsEvent.settingsUpdated( 23 | appSettingsBloc.state.settings.copyWith(recentUrl: null))); 24 | } else { 25 | context 26 | .read() 27 | .add(RecentEvent.recentUrlChanged(recentUrl)); 28 | } 29 | 30 | router.go('/'); 31 | }); 32 | } else { 33 | Future.delayed(Duration.zero, () { 34 | router.go('/'); 35 | }); 36 | } 37 | 38 | return AppWrapper( 39 | appBar: false, 40 | child: Container( 41 | color: Colors.black, 42 | child: const Image(image: AssetImage('assets/polypass.png')))); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lib/pages/settings/settings_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | 3 | import 'package:polypass/blocs/app_settings_bloc/app_settings_bloc.dart'; 4 | import 'package:polypass/data/app_settings/app_settings.dart'; 5 | 6 | import 'package:freezed_annotation/freezed_annotation.dart'; 7 | part 'settings_bloc.freezed.dart'; 8 | 9 | @freezed 10 | class SettingsState with _$SettingsState { 11 | const factory SettingsState({required AppSettings settings}) = _SettingsState; 12 | } 13 | 14 | @freezed 15 | class SettingsEvent with _$SettingsEvent { 16 | const factory SettingsEvent.setSaveKeyInMemory(bool setting) = 17 | SetSaveKeyInMemoryEvent; 18 | const factory SettingsEvent.setKDFIterations(int setting) = 19 | SetKDFIterationsEvent; 20 | const factory SettingsEvent.setKDFThreads(int setting) = SetKDFThreadsEvent; 21 | const factory SettingsEvent.setKDFMemory(int setting) = SetKDFMemoryEvent; 22 | const factory SettingsEvent.setClipboardClearSeconds(int setting) = 23 | SetClipboardClearSecondsEvent; 24 | const factory SettingsEvent.setVaultAutoLockSeconds(int setting) = 25 | SetVaultAutoLockSecondsEvent; 26 | const factory SettingsEvent.settingsSaved() = SettingsSavedEvent; 27 | } 28 | 29 | class SettingsBloc extends Bloc { 30 | SettingsBloc({required this.settingsBloc}) 31 | : super(SettingsState(settings: settingsBloc.state.settings)) { 32 | on((event, emit) { 33 | event.map( 34 | setSaveKeyInMemory: (event) => _onSetSaveKeyInMemory(event, emit), 35 | setKDFIterations: (event) => _onSetKDFIterations(event, emit), 36 | setKDFThreads: (event) => _onSetKDFThreads(event, emit), 37 | setKDFMemory: (event) => _onSetKDFMemory(event, emit), 38 | setClipboardClearSeconds: (event) => 39 | _onSetClipboardClearSeconds(event, emit), 40 | setVaultAutoLockSeconds: (event) => 41 | _onSetVaultAutoLockSeconds(event, emit), 42 | settingsSaved: (event) => _onSettingsSaved(event, emit)); 43 | }); 44 | } 45 | 46 | final AppSettingsBloc settingsBloc; 47 | 48 | void _onSetSaveKeyInMemory( 49 | SetSaveKeyInMemoryEvent event, Emitter emit) { 50 | emit(state.copyWith( 51 | settings: state.settings.copyWith( 52 | defaultVaultSettings: state.settings.defaultVaultSettings 53 | .copyWith(saveKeyInMemory: event.setting)))); 54 | } 55 | 56 | void _onSetKDFIterations( 57 | SetKDFIterationsEvent event, Emitter emit) { 58 | emit(state.copyWith( 59 | settings: state.settings.copyWith( 60 | defaultVaultSettings: state.settings.defaultVaultSettings 61 | .copyWith(iterations: event.setting)))); 62 | } 63 | 64 | void _onSetKDFThreads(SetKDFThreadsEvent event, Emitter emit) { 65 | emit(state.copyWith( 66 | settings: state.settings.copyWith( 67 | defaultVaultSettings: state.settings.defaultVaultSettings 68 | .copyWith(threads: event.setting)))); 69 | } 70 | 71 | void _onSetKDFMemory(SetKDFMemoryEvent event, Emitter emit) { 72 | emit(state.copyWith( 73 | settings: state.settings.copyWith( 74 | defaultVaultSettings: state.settings.defaultVaultSettings 75 | .copyWith(memory: event.setting)))); 76 | } 77 | 78 | void _onSetClipboardClearSeconds( 79 | SetClipboardClearSecondsEvent event, Emitter emit) { 80 | emit(state.copyWith( 81 | settings: state.settings.copyWith( 82 | defaultVaultSettings: state.settings.defaultVaultSettings 83 | .copyWith(clipboardClearSeconds: event.setting)))); 84 | } 85 | 86 | void _onSetVaultAutoLockSeconds( 87 | SetVaultAutoLockSecondsEvent event, Emitter emit) { 88 | emit(state.copyWith( 89 | settings: state.settings.copyWith( 90 | defaultVaultSettings: state.settings.defaultVaultSettings 91 | .copyWith(vaultAutoLockSeconds: event.setting)))); 92 | } 93 | 94 | void _onSettingsSaved(SettingsSavedEvent event, Emitter emit) { 95 | settingsBloc.add(AppSettingsEvent.settingsUpdated(state.settings)); 96 | state.settings.save(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /lib/pages/vault/edit/edit_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | import 'package:encrypt/encrypt.dart'; 3 | 4 | import 'package:polypass/data/vault_file/vault_file.dart'; 5 | import 'package:polypass/main.dart' show polypassMajorVersion; 6 | 7 | import 'package:freezed_annotation/freezed_annotation.dart'; 8 | part 'edit_bloc.freezed.dart'; 9 | 10 | @freezed 11 | class EditFormState with _$EditFormState { 12 | const EditFormState._(); 13 | const factory EditFormState( 14 | {required String name, 15 | required String username, 16 | required String password, 17 | required String notes, 18 | required bool submitted, 19 | required VaultItem? editedItem, 20 | required Key? masterKey}) = _EditFormState; 21 | 22 | bool get isFormValid => (name != '') && (username != '') && (password != ''); 23 | } 24 | 25 | @freezed 26 | class EditFormEvent with _$EditFormEvent { 27 | const factory EditFormEvent.nameChanged(String name) = NameChangedEvent; 28 | const factory EditFormEvent.usernameChanged(String username) = 29 | UsernameChangedEvent; 30 | const factory EditFormEvent.passwordChanged(String password) = 31 | PasswordChangedEvent; 32 | const factory EditFormEvent.notesChanged(String notes) = NotesChangedEvent; 33 | const factory EditFormEvent.formSubmitted(Key masterKey) = FormSubmittedEvent; 34 | const factory EditFormEvent.failed() = FailedEvent; 35 | } 36 | 37 | class EditFormBloc extends Bloc { 38 | EditFormBloc( 39 | {required String name, 40 | required String username, 41 | required String password, 42 | required String notes}) 43 | : super(EditFormState( 44 | name: name, 45 | username: username, 46 | password: password, 47 | notes: notes, 48 | submitted: false, 49 | editedItem: null, 50 | masterKey: null)) { 51 | on((event, emit) { 52 | event.map( 53 | nameChanged: (event) => _onNameChanged(event, emit), 54 | usernameChanged: (event) => _onUsernameChanged(event, emit), 55 | passwordChanged: (event) => _onPasswordChanged(event, emit), 56 | notesChanged: (event) => _onNotesChanged(event, emit), 57 | formSubmitted: (event) => _onFormSubmitted(event, emit), 58 | failed: (event) => _onFailedEvent(event, emit)); 59 | }); 60 | } 61 | 62 | void _onNameChanged(NameChangedEvent event, Emitter emit) { 63 | emit(state.copyWith(name: event.name)); 64 | } 65 | 66 | void _onUsernameChanged( 67 | UsernameChangedEvent event, Emitter emit) { 68 | emit(state.copyWith(username: event.username)); 69 | } 70 | 71 | void _onPasswordChanged( 72 | PasswordChangedEvent event, Emitter emit) { 73 | emit(state.copyWith(password: event.password)); 74 | } 75 | 76 | void _onNotesChanged(NotesChangedEvent event, Emitter emit) { 77 | emit(state.copyWith(notes: event.notes)); 78 | } 79 | 80 | void _onFormSubmitted(FormSubmittedEvent event, Emitter emit) { 81 | emit(state.copyWith(submitted: true, masterKey: event.masterKey)); 82 | 83 | emit(state.copyWith( 84 | editedItem: VaultItem( 85 | name: state.name, 86 | username: state.username, 87 | password: EncryptedData.decrypted( 88 | VaultPassword(state.password), 89 | IV.fromSecureRandom(16), 90 | polypassMajorVersion) 91 | .encrypt(event.masterKey), 92 | notes: state.notes))); 93 | } 94 | 95 | void _onFailedEvent(FailedEvent event, Emitter emit) { 96 | emit(state.copyWith(submitted: false, editedItem: null)); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /lib/pages/vault/home/component_bloc/component_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | 3 | import 'package:freezed_annotation/freezed_annotation.dart'; 4 | part 'component_bloc.freezed.dart'; 5 | 6 | enum ComponentMode { normal, rename } 7 | 8 | enum ExpandMode { expanded, collapsed } 9 | 10 | @freezed 11 | class ComponentState with _$ComponentState { 12 | const factory ComponentState( 13 | {required bool inArea, 14 | required ComponentMode mode, 15 | required ExpandMode expand}) = _ComponentState; 16 | 17 | factory ComponentState.empty(bool expanded) => ComponentState( 18 | inArea: false, 19 | mode: ComponentMode.normal, 20 | expand: expanded ? ExpandMode.expanded : ExpandMode.collapsed); 21 | } 22 | 23 | @freezed 24 | class ComponentEvent with _$ComponentEvent { 25 | const factory ComponentEvent.entered() = EnteredEvent; 26 | const factory ComponentEvent.exited() = ExitedEvent; 27 | const factory ComponentEvent.modeToggled() = ModeToggledEvent; 28 | const factory ComponentEvent.expandToggled() = ExpandToggledEvent; 29 | } 30 | 31 | class ComponentBloc extends Bloc { 32 | ComponentBloc(bool expanded) : super(ComponentState.empty(expanded)) { 33 | on((event, emit) { 34 | event.map( 35 | entered: (event) => _onEntered(event, emit), 36 | exited: (event) => _onExited(event, emit), 37 | modeToggled: (event) => _onModeToggled(event, emit), 38 | expandToggled: (event) => _onExpandToggled(event, emit)); 39 | }); 40 | } 41 | 42 | void _onEntered(EnteredEvent event, Emitter emit) { 43 | emit(state.copyWith(inArea: true)); 44 | } 45 | 46 | void _onExited(ExitedEvent event, Emitter emit) { 47 | emit(state.copyWith(inArea: false)); 48 | } 49 | 50 | void _onModeToggled(ModeToggledEvent event, Emitter emit) { 51 | emit(state.copyWith( 52 | mode: state.mode == ComponentMode.normal 53 | ? ComponentMode.rename 54 | : ComponentMode.normal)); 55 | } 56 | 57 | void _onExpandToggled( 58 | ExpandToggledEvent event, Emitter emit) { 59 | emit(state.copyWith( 60 | expand: state.expand == ExpandMode.collapsed 61 | ? ExpandMode.expanded 62 | : ExpandMode.collapsed)); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /lib/pages/vault/home/home.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | 4 | import 'package:polypass/pages/vault/home/vault_home_bloc/vault_home_bloc.dart'; 5 | import 'package:polypass/blocs/vault_bloc/vault_bloc.dart'; 6 | 7 | import 'package:polypass/components/app_wrapper/app_wrapper.dart'; 8 | import 'package:polypass/pages/vault/home/tree.dart'; 9 | import 'package:polypass/pages/vault/home/folder_list.dart'; 10 | 11 | class VaultHome extends StatelessWidget { 12 | const VaultHome({Key? key}) : super(key: key); 13 | 14 | @override 15 | Widget build(BuildContext context) { 16 | return AppWrapper( 17 | child: BlocProvider( 18 | create: (context) => VaultHomeBloc(vaultBloc: context.read()), 19 | child: const Column(children: [SearchBar(), PasswordsView()]), 20 | )); 21 | } 22 | } 23 | 24 | class PasswordsView extends StatelessWidget { 25 | const PasswordsView({Key? key}) : super(key: key); 26 | 27 | @override 28 | Widget build(BuildContext context) { 29 | return Expanded( 30 | child: Container( 31 | decoration: BoxDecoration( 32 | borderRadius: BorderRadius.circular(5), 33 | color: Theme.of(context).cardColor), 34 | margin: const EdgeInsets.all(10), 35 | padding: const EdgeInsets.all(10), 36 | child: LayoutBuilder(builder: (context, constraints) { 37 | final size = MediaQuery.of(context).size; 38 | final noDividerWidth = constraints.maxWidth - 20; 39 | 40 | return Row(children: [ 41 | BlocBuilder( 42 | builder: (context, state) { 43 | return SizedBox( 44 | width: size.width < 600 && state.treeVisible 45 | ? noDividerWidth 46 | : size.width >= 600 && state.treeVisible 47 | ? noDividerWidth * 0.25 48 | : 0, 49 | child: BlocBuilder( 50 | builder: (context, state) { 51 | return state.treeVisible ? const Tree() : Container(); 52 | }), 53 | ); 54 | }), 55 | const SizedBox(width: 20, child: TreeDivider()), 56 | BlocBuilder( 57 | builder: (context, state) { 58 | return SizedBox( 59 | width: size.width < 600 && !state.treeVisible 60 | ? noDividerWidth 61 | : size.width >= 600 && state.treeVisible 62 | ? noDividerWidth * 0.75 63 | : size.width >= 600 && !state.treeVisible 64 | ? noDividerWidth 65 | : 0, 66 | child: BlocBuilder( 67 | builder: (context, state) { 68 | if (MediaQuery.of(context).size.width < 600) { 69 | return !state.treeVisible 70 | ? const FolderList() 71 | : Container(); 72 | } else { 73 | return const FolderList(); 74 | } 75 | }), 76 | ); 77 | }) 78 | ]); 79 | })), 80 | ); 81 | } 82 | } 83 | 84 | class TreeDivider extends StatelessWidget { 85 | const TreeDivider({Key? key}) : super(key: key); 86 | 87 | @override 88 | Widget build(BuildContext context) { 89 | return LayoutBuilder(builder: (context, constraints) { 90 | return SizedBox( 91 | height: constraints.maxHeight, 92 | child: Column( 93 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 94 | crossAxisAlignment: CrossAxisAlignment.center, 95 | children: [ 96 | SizedBox( 97 | height: 35, 98 | width: 20, 99 | child: MouseRegion( 100 | cursor: SystemMouseCursors.click, 101 | child: GestureDetector( 102 | child: BlocBuilder( 103 | builder: (context, state) { 104 | return Text( 105 | state.treeVisible ? '<' : '>', 106 | style: const TextStyle(fontSize: 35), 107 | textAlign: TextAlign.center, 108 | ); 109 | }), 110 | onTap: () => context 111 | .read() 112 | .add(const VaultHomeEvent.treeToggled()), 113 | ), 114 | ), 115 | ), 116 | SizedBox( 117 | width: 20, 118 | height: constraints.maxHeight - 35, 119 | child: const VerticalDivider()), 120 | ], 121 | ), 122 | ); 123 | }); 124 | } 125 | } 126 | 127 | class SearchBar extends StatelessWidget { 128 | const SearchBar({Key? key}) : super(key: key); 129 | 130 | @override 131 | Widget build(BuildContext context) { 132 | final theme = Theme.of(context); 133 | final vaultHomeBloc = context.read(); 134 | 135 | return Container( 136 | decoration: BoxDecoration( 137 | borderRadius: BorderRadius.circular(5), color: theme.cardColor), 138 | margin: const EdgeInsets.all(10), 139 | padding: const EdgeInsets.all(10), 140 | child: Container( 141 | decoration: BoxDecoration( 142 | borderRadius: BorderRadius.circular(5), 143 | color: theme.colorScheme.secondary), 144 | padding: const EdgeInsets.only(left: 10), 145 | child: TextField( 146 | decoration: InputDecoration( 147 | icon: IconButton( 148 | icon: const Icon(Icons.search), 149 | onPressed: () { 150 | vaultHomeBloc.add(const VaultHomeEvent.searchSubmitted()); 151 | }, 152 | ), 153 | label: Text( 154 | 'Search ${context.read().state.mapOrNull(unlocked: (state) => state.vault.header.name)!}'), 155 | floatingLabelStyle: theme.textTheme.bodySmall, 156 | labelStyle: theme.textTheme.bodySmall, 157 | border: InputBorder.none, 158 | contentPadding: const EdgeInsets.all(10), 159 | ), 160 | style: theme.textTheme.bodySmall, 161 | onChanged: (query) { 162 | vaultHomeBloc.add(VaultHomeEvent.queryChanged(query)); 163 | }, 164 | onSubmitted: (query) { 165 | vaultHomeBloc.add(const VaultHomeEvent.searchSubmitted()); 166 | }, 167 | ), 168 | ), 169 | ); 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /lib/pages/vault/home/list_item_bloc/list_item_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | import 'package:encrypt/encrypt.dart'; 3 | 4 | import 'package:freezed_annotation/freezed_annotation.dart'; 5 | part 'list_item_bloc.freezed.dart'; 6 | 7 | enum ListItemMode { normal, view } 8 | 9 | @freezed 10 | class ListItemState with _$ListItemState { 11 | const factory ListItemState( 12 | {required ListItemMode mode, required Key? masterKey}) = _ListItemState; 13 | 14 | factory ListItemState.empty() => 15 | const ListItemState(mode: ListItemMode.normal, masterKey: null); 16 | } 17 | 18 | @freezed 19 | class ListItemEvent with _$ListItemEvent { 20 | const factory ListItemEvent.modeToggled({ListItemMode? newMode}) = 21 | ModeToggledEvent; 22 | const factory ListItemEvent.masterKeyChanged(Key? masterKey) = 23 | MasterKeyAcquiredEvent; 24 | } 25 | 26 | class ListItemBloc extends Bloc { 27 | ListItemBloc() : super(ListItemState.empty()) { 28 | on((event, emit) { 29 | event.map( 30 | modeToggled: (event) => _onModeToggled(event, emit), 31 | masterKeyChanged: (event) => _onMasterKeyAcquired(event, emit)); 32 | }); 33 | } 34 | 35 | void _onModeToggled(ModeToggledEvent event, Emitter emit) { 36 | emit(state.copyWith( 37 | mode: event.newMode ?? 38 | (state.mode == ListItemMode.normal 39 | ? ListItemMode.view 40 | : ListItemMode.normal))); 41 | } 42 | 43 | void _onMasterKeyAcquired( 44 | MasterKeyAcquiredEvent event, Emitter emit) { 45 | emit(state.copyWith(masterKey: event.masterKey)); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lib/pages/vault/home/vault_home_bloc/vault_home_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | 3 | import 'package:polypass/blocs/vault_bloc/vault_bloc.dart'; 4 | import 'package:polypass/data/vault_file/vault_file.dart'; 5 | 6 | import 'package:freezed_annotation/freezed_annotation.dart'; 7 | part 'vault_home_bloc.freezed.dart'; 8 | 9 | @freezed 10 | class VaultHomeState with _$VaultHomeState { 11 | const factory VaultHomeState( 12 | {required String query, 13 | required bool submitted, 14 | required List> results, 15 | required bool treeVisible}) = _VaultHomeState; 16 | 17 | factory VaultHomeState.empty() => const VaultHomeState( 18 | query: '', submitted: false, results: [], treeVisible: true); 19 | } 20 | 21 | @freezed 22 | class VaultHomeEvent with _$VaultHomeEvent { 23 | const factory VaultHomeEvent.queryChanged(String query) = QueryChangedEvent; 24 | const factory VaultHomeEvent.searchSubmitted() = SearchSubmittedEvent; 25 | const factory VaultHomeEvent.treeToggled() = TreeToggledEvent; 26 | } 27 | 28 | class VaultHomeBloc extends Bloc { 29 | VaultHomeBloc({required this.vaultBloc}) : super(VaultHomeState.empty()) { 30 | on((event, emit) async { 31 | await event.map( 32 | queryChanged: (event) => _onQueryChanged(event, emit), 33 | searchSubmitted: (event) => _onSearchSubmitted(event, emit), 34 | treeToggled: (event) => _onTreeToggled(event, emit)); 35 | }); 36 | } 37 | 38 | final VaultBloc vaultBloc; 39 | 40 | Future _onQueryChanged( 41 | QueryChangedEvent event, Emitter emit) async { 42 | emit(state.copyWith(query: event.query)); 43 | } 44 | 45 | Future _onSearchSubmitted( 46 | SearchSubmittedEvent event, Emitter emit) async { 47 | emit(state.copyWith(submitted: true)); 48 | 49 | final unlockedState = vaultBloc.state 50 | .maybeMap(unlocked: (state) => state, orElse: () => throw Error()); 51 | 52 | final decryptedContents = unlockedState.vault.contents.maybeMap( 53 | decrypted: (contents) => contents, orElse: () => throw Error()); 54 | 55 | final results = 56 | searchGroup(decryptedContents.data.components, state.query, null); 57 | 58 | emit(state.copyWith(results: results)); 59 | 60 | vaultBloc.add(const VaultEvent.groupSelected(['Search Results'], false)); 61 | } 62 | 63 | Future _onTreeToggled( 64 | TreeToggledEvent event, Emitter emit) async { 65 | emit(state.copyWith(treeVisible: !state.treeVisible)); 66 | } 67 | } 68 | 69 | List> searchGroup( 70 | List components, String query, List? path) { 71 | final matchedItems = >[]; 72 | 73 | for (final component in components) { 74 | component.map(group: (group) { 75 | final groupMatchedItems = searchGroup(group.group.components, query, 76 | path == null ? [group.group.name] : [...path, group.group.name]); 77 | matchedItems.addAll(groupMatchedItems); 78 | }, item: (item) { 79 | final exp = RegExp(query, caseSensitive: false); 80 | if (exp.hasMatch(item.item.name)) { 81 | matchedItems 82 | .add(path == null ? [item.item.name] : [...path, item.item.name]); 83 | } 84 | }); 85 | } 86 | 87 | return matchedItems; 88 | } 89 | -------------------------------------------------------------------------------- /lib/pages/vault/locked/locked.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | 4 | import 'package:polypass/blocs/vault_bloc/vault_bloc.dart'; 5 | import 'package:polypass/pages/vault/locked/locked_bloc.dart'; 6 | 7 | import 'package:polypass/components/app_wrapper/app_wrapper.dart'; 8 | 9 | class VaultLocked extends StatelessWidget { 10 | const VaultLocked({Key? key}) : super(key: key); 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return AppWrapper( 15 | child: Center( 16 | child: Container( 17 | decoration: BoxDecoration( 18 | color: const Color(0xFF373b42), 19 | borderRadius: BorderRadius.circular(10)), 20 | padding: const EdgeInsets.all(10), 21 | margin: const EdgeInsets.symmetric(horizontal: 10), 22 | width: 600, 23 | child: BlocProvider( 24 | create: (context) => LockedFormBloc(read: context.read), 25 | child: MultiBlocListener( 26 | listeners: [ 27 | BlocListener( 28 | listener: (context, state) { 29 | ScaffoldMessenger.of(context).clearSnackBars(); 30 | ScaffoldMessenger.of(context).showSnackBar(const SnackBar( 31 | content: Text('Unlocking vault...'), 32 | duration: Duration(seconds: 3))); 33 | }, 34 | listenWhen: (previous, current) => current.success == true), 35 | BlocListener( 36 | listener: (context, state) { 37 | ScaffoldMessenger.of(context).clearSnackBars(); 38 | ScaffoldMessenger.of(context).showSnackBar(const SnackBar( 39 | content: Text( 40 | 'Decryption failed. Check your credentials and try again.'), 41 | duration: Duration(seconds: 5))); 42 | }, 43 | listenWhen: (previous, current) => 44 | previous.fails != current.fails) 45 | ], 46 | child: Column( 47 | mainAxisAlignment: MainAxisAlignment.center, 48 | crossAxisAlignment: CrossAxisAlignment.center, 49 | mainAxisSize: MainAxisSize.min, 50 | children: [ 51 | Text( 52 | 'Unlock ${context.read().state.mapOrNull(locked: (state) => state.vault.header.name)}', 53 | style: const TextStyle(color: Colors.white, fontSize: 30), 54 | textAlign: TextAlign.center), 55 | const MasterPasswordInput(), 56 | const SubmitButton() 57 | ], 58 | ), 59 | ), 60 | ), 61 | ))); 62 | } 63 | } 64 | 65 | class MasterPasswordInput extends StatelessWidget { 66 | const MasterPasswordInput({ 67 | Key? key, 68 | }) : super(key: key); 69 | 70 | @override 71 | Widget build(BuildContext context) { 72 | final theme = Theme.of(context); 73 | 74 | return BlocBuilder( 75 | builder: (context, state) { 76 | return Container( 77 | decoration: BoxDecoration( 78 | color: theme.colorScheme.secondary, 79 | borderRadius: BorderRadius.circular(5)), 80 | margin: const EdgeInsets.symmetric(vertical: 10, horizontal: 5), 81 | child: TextFormField( 82 | enabled: context 83 | .read() 84 | .state 85 | .maybeMap(unlocking: (state) => false, orElse: () => true), 86 | decoration: const InputDecoration( 87 | labelText: 'Master Password', 88 | contentPadding: EdgeInsets.all(10), 89 | floatingLabelStyle: TextStyle(color: Colors.black), 90 | labelStyle: TextStyle(color: Colors.black), 91 | border: InputBorder.none), 92 | style: theme.textTheme.bodySmall, 93 | cursorColor: Colors.black, 94 | obscureText: true, 95 | enableSuggestions: false, 96 | autocorrect: false, 97 | onChanged: (masterPassword) { 98 | context 99 | .read() 100 | .add(LockedFormEvent.masterPasswordChanged(masterPassword)); 101 | }, 102 | onFieldSubmitted: (masterPassword) { 103 | context 104 | .read() 105 | .add(LockedFormEvent.formSubmitted(context)); 106 | }, 107 | autofocus: true, 108 | )); 109 | }, 110 | ); 111 | } 112 | } 113 | 114 | class SubmitButton extends StatelessWidget { 115 | const SubmitButton({ 116 | Key? key, 117 | }) : super(key: key); 118 | 119 | @override 120 | Widget build(BuildContext context) { 121 | return BlocBuilder( 122 | builder: (context, state) { 123 | return ElevatedButton( 124 | style: ButtonStyle( 125 | padding: MaterialStateProperty.all(const EdgeInsets.all(15))), 126 | onPressed: context.read().state.maybeMap( 127 | unlocking: (state) => true, orElse: () => false) || 128 | !state.isFormValid 129 | ? null 130 | : () { 131 | context 132 | .read() 133 | .add(LockedFormEvent.formSubmitted(context)); 134 | }, 135 | child: const Text('Submit', 136 | style: TextStyle(color: Colors.white, fontSize: 20)), 137 | ); 138 | }); 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /lib/pages/vault/locked/locked_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | import 'package:bloc/bloc.dart'; 3 | import 'package:encrypt/encrypt.dart'; 4 | import 'package:provider/provider.dart'; 5 | import 'package:flutter/material.dart' show BuildContext; 6 | 7 | import 'package:polypass/blocs/vault_bloc/vault_bloc.dart'; 8 | 9 | import 'package:freezed_annotation/freezed_annotation.dart'; 10 | import 'package:polypass/data/vault_file/vault_file.dart'; 11 | part 'locked_bloc.freezed.dart'; 12 | 13 | @freezed 14 | class LockedFormState with _$LockedFormState { 15 | const LockedFormState._(); 16 | const factory LockedFormState( 17 | { 18 | // Raw master password that user enters 19 | required String masterPassword, 20 | // Derived master key from master password 21 | required Key? masterKey, 22 | required bool submitted, 23 | required bool success, 24 | required int fails}) = _UnlockFormState; 25 | 26 | factory LockedFormState.empty() => const LockedFormState( 27 | masterPassword: '', 28 | masterKey: null, 29 | submitted: false, 30 | success: false, 31 | fails: 0); 32 | 33 | bool get isFormValid => masterPassword != ''; 34 | } 35 | 36 | @freezed 37 | class LockedFormEvent with _$LockedFormEvent { 38 | const factory LockedFormEvent.masterPasswordChanged(String masterPassword) = 39 | MasterPasswordChangedEvent; 40 | const factory LockedFormEvent.formSubmitted(BuildContext context) = 41 | FormSubmittedEvent; 42 | } 43 | 44 | class LockedFormBloc extends Bloc { 45 | LockedFormBloc({required this.read}) : super(LockedFormState.empty()) { 46 | on((event, emit) { 47 | event.map( 48 | masterPasswordChanged: (event) => 49 | _onMasterPasswordChanged(event, emit), 50 | formSubmitted: (event) => _onFormSubmitted(event, emit)); 51 | }); 52 | } 53 | 54 | final Locator read; 55 | 56 | void _onMasterPasswordChanged( 57 | MasterPasswordChangedEvent event, Emitter emit) { 58 | emit(state.copyWith(masterPassword: event.masterPassword)); 59 | } 60 | 61 | void _onFormSubmitted( 62 | FormSubmittedEvent event, Emitter emit) { 63 | emit(state.copyWith(submitted: true)); 64 | 65 | final vaultBloc = read(); 66 | 67 | final lockedState = vaultBloc.state 68 | .maybeMap(locked: (state) => state, orElse: () => throw Error()); 69 | 70 | final derivedKey = EncryptedData.deriveDerivedKey( 71 | state.masterPassword, 72 | Uint8List.fromList(lockedState.vault.header.salt), 73 | lockedState.vault.header.settings); 74 | 75 | if (lockedState.vault.header 76 | .testMagic(derivedKey, lockedState.vault.contents.iv)) { 77 | emit(state.copyWith(success: true)); 78 | vaultBloc.add(VaultEvent.unlocked( 79 | lockedState.vault.header 80 | .decryptMasterKey(derivedKey, lockedState.vault.contents.iv), 81 | event.context)); 82 | } else { 83 | emit(state.copyWith( 84 | masterKey: null, submitted: false, fails: state.fails + 1)); 85 | } 86 | 87 | emit(state.copyWith(masterKey: derivedKey)); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /lib/pages/vault/new/new_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | import 'package:encrypt/encrypt.dart'; 3 | 4 | import 'package:polypass/data/vault_file/vault_file.dart'; 5 | import 'package:polypass/main.dart' show polypassMajorVersion; 6 | 7 | import 'package:freezed_annotation/freezed_annotation.dart'; 8 | part 'new_bloc.freezed.dart'; 9 | 10 | @freezed 11 | class NewFormState with _$NewFormState { 12 | const NewFormState._(); 13 | const factory NewFormState( 14 | {required String name, 15 | required String username, 16 | required String password, 17 | required String notes, 18 | required bool submitted, 19 | required VaultItem? createdItem, 20 | required Key? masterKey}) = _NewFormState; 21 | 22 | factory NewFormState.empty() => const NewFormState( 23 | name: '', 24 | username: '', 25 | password: '', 26 | notes: '', 27 | submitted: false, 28 | createdItem: null, 29 | masterKey: null); 30 | 31 | bool get isFormValid => (name != '') && (username != '') && (password != ''); 32 | } 33 | 34 | @freezed 35 | class NewFormEvent with _$NewFormEvent { 36 | const factory NewFormEvent.nameChanged(String name) = NameChangedEvent; 37 | const factory NewFormEvent.usernameChanged(String username) = 38 | UsernameChangedEvent; 39 | const factory NewFormEvent.passwordChanged(String password) = 40 | PasswordChangedEvent; 41 | const factory NewFormEvent.notesChanged(String notes) = NotesChangedEvent; 42 | const factory NewFormEvent.formSubmitted(Key masterKey) = FormSubmittedEvent; 43 | const factory NewFormEvent.failed() = FailedEvent; 44 | } 45 | 46 | class NewFormBloc extends Bloc { 47 | NewFormBloc() : super(NewFormState.empty()) { 48 | on((event, emit) { 49 | event.map( 50 | nameChanged: (event) => _onNameChanged(event, emit), 51 | usernameChanged: (event) => _onUsernameChanged(event, emit), 52 | passwordChanged: (event) => _onPasswordChanged(event, emit), 53 | notesChanged: (event) => _onNotesChanged(event, emit), 54 | formSubmitted: (event) => _onFormSubmitted(event, emit), 55 | failed: (event) => _onFailedEvent(event, emit)); 56 | }); 57 | } 58 | 59 | void _onNameChanged(NameChangedEvent event, Emitter emit) { 60 | emit(state.copyWith(name: event.name)); 61 | } 62 | 63 | void _onUsernameChanged( 64 | UsernameChangedEvent event, Emitter emit) { 65 | emit(state.copyWith(username: event.username)); 66 | } 67 | 68 | void _onPasswordChanged( 69 | PasswordChangedEvent event, Emitter emit) { 70 | emit(state.copyWith(password: event.password)); 71 | } 72 | 73 | void _onNotesChanged(NotesChangedEvent event, Emitter emit) { 74 | emit(state.copyWith(notes: event.notes)); 75 | } 76 | 77 | void _onFormSubmitted(FormSubmittedEvent event, Emitter emit) { 78 | emit(state.copyWith(submitted: true, masterKey: event.masterKey)); 79 | 80 | emit(state.copyWith( 81 | createdItem: VaultItem( 82 | name: state.name, 83 | username: state.username, 84 | password: EncryptedData.decrypted( 85 | VaultPassword(state.password), 86 | IV.fromSecureRandom(16), 87 | polypassMajorVersion) 88 | .encrypt(event.masterKey), 89 | notes: state.notes))); 90 | } 91 | 92 | void _onFailedEvent(FailedEvent event, Emitter emit) { 93 | emit(state.copyWith(submitted: false, createdItem: null)); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /lib/theme.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | final appTheme = ThemeData( 4 | colorScheme: const ColorScheme( 5 | brightness: Brightness.dark, 6 | primary: Color(0xFF4b4e53), 7 | onPrimary: Colors.white, 8 | secondary: Colors.green, 9 | tertiary: Colors.lightBlue, 10 | onSecondary: Colors.black, 11 | error: Colors.red, 12 | onError: Colors.black, 13 | background: Color(0xFF4b4e53), 14 | onBackground: Colors.white, 15 | surface: Color(0xFF282c34), 16 | onSurface: Colors.white, 17 | primaryContainer: Color.fromARGB(255, 62, 64, 68)), 18 | appBarTheme: const AppBarTheme( 19 | backgroundColor: Color(0xFF282c34), 20 | titleTextStyle: TextStyle(color: Colors.white, fontSize: 22)), 21 | cardColor: const Color(0xFF282c34), 22 | textTheme: const TextTheme( 23 | titleMedium: TextStyle(fontSize: 30, color: Colors.white), 24 | bodyMedium: TextStyle(fontSize: 20, color: Colors.white), 25 | bodySmall: TextStyle(fontSize: 20, color: Colors.black)), 26 | elevatedButtonTheme: ElevatedButtonThemeData(style: ButtonStyle( 27 | backgroundColor: MaterialStateProperty.resolveWith((states) { 28 | if (states.contains(MaterialState.disabled)) { 29 | return const Color(0xFF3f4145); 30 | } 31 | 32 | return Colors.blue; 33 | }))), 34 | snackBarTheme: const SnackBarThemeData( 35 | backgroundColor: Color(0xFF282c34), 36 | contentTextStyle: TextStyle(fontSize: 15, color: Colors.white)), 37 | dividerTheme: const DividerThemeData( 38 | thickness: 3, space: 10, indent: 5, endIndent: 5, color: Colors.grey)); 39 | -------------------------------------------------------------------------------- /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | project(runner LANGUAGES CXX) 3 | 4 | set(BINARY_NAME "polypass") 5 | set(APPLICATION_ID "com.polypixeldev.polypass") 6 | 7 | cmake_policy(SET CMP0063 NEW) 8 | 9 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 10 | 11 | # Root filesystem for cross-building. 12 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 13 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 14 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 15 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 16 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 17 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 18 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 19 | endif() 20 | 21 | # Configure build options. 22 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 23 | set(CMAKE_BUILD_TYPE "Debug" CACHE 24 | STRING "Flutter build mode" FORCE) 25 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 26 | "Debug" "Profile" "Release") 27 | endif() 28 | 29 | # Compilation settings that should be applied to most targets. 30 | function(APPLY_STANDARD_SETTINGS TARGET) 31 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 32 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 33 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 34 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 35 | endfunction() 36 | 37 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 38 | 39 | # Flutter library and tool build rules. 40 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 41 | 42 | # System-level dependencies. 43 | find_package(PkgConfig REQUIRED) 44 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 45 | 46 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 47 | 48 | # Application build 49 | add_executable(${BINARY_NAME} 50 | "main.cc" 51 | "my_application.cc" 52 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 53 | ) 54 | apply_standard_settings(${BINARY_NAME}) 55 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 56 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 57 | add_dependencies(${BINARY_NAME} flutter_assemble) 58 | # Only the install-generated bundle's copy of the executable will launch 59 | # correctly, since the resources must in the right relative locations. To avoid 60 | # people trying to run the unbundled copy, put it in a subdirectory instead of 61 | # the default top-level location. 62 | set_target_properties(${BINARY_NAME} 63 | PROPERTIES 64 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 65 | ) 66 | 67 | # Generated plugin build rules, which manage building the plugins and adding 68 | # them to the application. 69 | include(flutter/generated_plugins.cmake) 70 | 71 | include(./rust.cmake) 72 | 73 | # === Installation === 74 | # By default, "installing" just makes a relocatable bundle in the build 75 | # directory. 76 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 77 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 78 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 79 | endif() 80 | 81 | # Start with a clean build bundle directory every time. 82 | install(CODE " 83 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 84 | " COMPONENT Runtime) 85 | 86 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 87 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 88 | 89 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 90 | COMPONENT Runtime) 91 | 92 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 93 | COMPONENT Runtime) 94 | 95 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 96 | COMPONENT Runtime) 97 | 98 | if(PLUGIN_BUNDLED_LIBRARIES) 99 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 100 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 101 | COMPONENT Runtime) 102 | endif() 103 | 104 | # Fully re-copy the assets directory on each build to avoid having stale files 105 | # from a previous install. 106 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 107 | install(CODE " 108 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 109 | " COMPONENT Runtime) 110 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 111 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 112 | 113 | # Install the AOT library on non-Debug builds only. 114 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 115 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 116 | COMPONENT Runtime) 117 | endif() 118 | -------------------------------------------------------------------------------- /linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 4 | 5 | # Configuration provided via flutter tool. 6 | include(${EPHEMERAL_DIR}/generated_config.cmake) 7 | 8 | # TODO: Move the rest of this into files in ephemeral. See 9 | # https://github.com/flutter/flutter/issues/57146. 10 | 11 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 12 | # which isn't available in 3.10. 13 | function(list_prepend LIST_NAME PREFIX) 14 | set(NEW_LIST "") 15 | foreach(element ${${LIST_NAME}}) 16 | list(APPEND NEW_LIST "${PREFIX}${element}") 17 | endforeach(element) 18 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 19 | endfunction() 20 | 21 | # === Flutter Library === 22 | # System-level dependencies. 23 | find_package(PkgConfig REQUIRED) 24 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 25 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 26 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 27 | 28 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 29 | 30 | # Published to parent scope for install step. 31 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 32 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 33 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 34 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 35 | 36 | list(APPEND FLUTTER_LIBRARY_HEADERS 37 | "fl_basic_message_channel.h" 38 | "fl_binary_codec.h" 39 | "fl_binary_messenger.h" 40 | "fl_dart_project.h" 41 | "fl_engine.h" 42 | "fl_json_message_codec.h" 43 | "fl_json_method_codec.h" 44 | "fl_message_codec.h" 45 | "fl_method_call.h" 46 | "fl_method_channel.h" 47 | "fl_method_codec.h" 48 | "fl_method_response.h" 49 | "fl_plugin_registrar.h" 50 | "fl_plugin_registry.h" 51 | "fl_standard_message_codec.h" 52 | "fl_standard_method_codec.h" 53 | "fl_string_codec.h" 54 | "fl_value.h" 55 | "fl_view.h" 56 | "flutter_linux.h" 57 | ) 58 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 59 | add_library(flutter INTERFACE) 60 | target_include_directories(flutter INTERFACE 61 | "${EPHEMERAL_DIR}" 62 | ) 63 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 64 | target_link_libraries(flutter INTERFACE 65 | PkgConfig::GTK 66 | PkgConfig::GLIB 67 | PkgConfig::GIO 68 | ) 69 | add_dependencies(flutter flutter_assemble) 70 | 71 | # === Flutter tool backend === 72 | # _phony_ is a non-existent file to force this command to run every time, 73 | # since currently there's no way to get a full input/output list from the 74 | # flutter tool. 75 | add_custom_command( 76 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 77 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 78 | COMMAND ${CMAKE_COMMAND} -E env 79 | ${FLUTTER_TOOL_ENVIRONMENT} 80 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 81 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 82 | VERBATIM 83 | ) 84 | add_custom_target(flutter_assemble DEPENDS 85 | "${FLUTTER_LIBRARY}" 86 | ${FLUTTER_LIBRARY_HEADERS} 87 | ) 88 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void fl_register_plugins(FlPluginRegistry* registry) { 12 | g_autoptr(FlPluginRegistrar) flutter_window_close_registrar = 13 | fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterWindowClosePlugin"); 14 | flutter_window_close_plugin_register_with_registrar(flutter_window_close_registrar); 15 | } 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | flutter_window_close 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /linux/io.github.polypixeldev.Polypass.appdata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | io.github.polypixeldev.Polypass 4 | 5 | Polypass 6 | A simple, secure, and easy to use password manager 7 | https://github.com/polypixeldev/polypass 8 | https://github.com/polypixeldev/polypass/issues 9 | https://github.com/polypixeldev/polypass 10 | 11 | Utility 12 | 13 | 14 | 15 | MIT 16 | GPL-3.0 17 | polypixeldev 18 | 19 | 20 | pointing 21 | keyboard 22 | touch 23 | 24 | 25 | 26 |

27 | Polypass is a simple, secure, and easy to use password manager 28 |

29 |
30 | 31 | io.github.polypixeldev.Polypass.desktop 32 | 33 | 34 | 35 | 36 | The home page 37 | https://raw.githubusercontent.com/polypixeldev/polypass/main/images/home.png 38 | 39 | 40 | The vault page 41 | https://raw.githubusercontent.com/polypixeldev/polypass/main/images/vault.png 42 | 43 | 44 | The generator page 45 | https://raw.githubusercontent.com/polypixeldev/polypass/main/images/generator.png 46 | 47 | 48 | 49 | 50 | 51 | Version 2.1.0 of Polypass brings a lot of improvements and bug fixes to 52 | Polypass, including:
    53 |
  • Synchronization bugs fixed
  • 54 |
  • Random password generator
  • 55 |
56 |
57 |
58 | 59 | Version 2.0.0 of Polypass brings many big improvements to PolyPass, including:
    60 |
  • Android builds
  • 61 |
  • Remote files via FTP
  • 62 |
  • Offline access
  • 63 |
  • Auto locking
  • 64 |
  • Auto clipboard clearing
  • 65 |
  • and more!
  • 66 |
67 |
68 |
69 | 70 | 71 |

72 | Initial release 73 |

74 |
75 |
76 |
77 |
78 | -------------------------------------------------------------------------------- /linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "Polypass"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "Polypass"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /linux/rust.cmake: -------------------------------------------------------------------------------- 1 | # We include Corrosion inline here, but ideally in a project with 2 | # many dependencies we would need to install Corrosion on the system. 3 | # See instructions on https://github.com/AndrewGaspar/corrosion#cmake-install 4 | # Once done, uncomment this line: 5 | # find_package(Corrosion REQUIRED) 6 | 7 | include(FetchContent) 8 | 9 | set(Rust_TOOLCHAIN "nightly-2023-06-15") 10 | 11 | FetchContent_Declare( 12 | Corrosion 13 | GIT_REPOSITORY https://github.com/AndrewGaspar/corrosion.git 14 | GIT_TAG origin/master # Optionally specify a version tag or branch here 15 | ) 16 | 17 | FetchContent_MakeAvailable(Corrosion) 18 | 19 | corrosion_import_crate(MANIFEST_PATH ../rust/Cargo.toml) 20 | 21 | # Flutter-specific 22 | 23 | set(CRATE_NAME "libpolypass") 24 | 25 | target_link_libraries(${BINARY_NAME} PRIVATE ${CRATE_NAME}) 26 | 27 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 28 | -------------------------------------------------------------------------------- /polypass.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: polypass 2 | description: A password manager written in Dart/Flutter 3 | 4 | publish_to: 'none' 5 | 6 | version: 2.1.0 7 | 8 | environment: 9 | sdk: ">=2.17.0" 10 | 11 | dependencies: 12 | bloc: ^8.0.3 13 | encrypt: ^5.0.1 14 | equatable: ^2.0.3 15 | ffi: ^2.0.1 16 | file_picker: ^5.3.0 17 | flutter: 18 | sdk: flutter 19 | flutter_bloc: ^8.0.1 20 | flutter_rust_bridge: ^1.61.1 21 | flutter_spinbox: ^0.13.1 22 | flutter_window_close: ^0.2.2 23 | freezed_annotation: ^2.0.3 24 | go_router: ^9.0.2 25 | hash: ^1.0.4 26 | json_annotation: ^4.5.0 27 | meta: ^1.8.0 28 | path_provider: ^2.0.11 29 | pointycastle: ^3.6.1 30 | provider: ^6.0.3 31 | sizer: ^2.0.15 32 | uuid: ^3.0.6 33 | 34 | dev_dependencies: 35 | flutter_test: 36 | sdk: flutter 37 | flutter_lints: ^2.0.1 38 | build_runner: ^2.1.11 39 | freezed: ^2.0.3+1 40 | json_serializable: ^6.2.0 41 | # locked by flutter rust bridge 42 | ffigen: 7.2.11 43 | flutter_launcher_icons: ^0.13.1 44 | 45 | flutter_icons: 46 | android: true 47 | ios: false 48 | image_path: "assets/polypass.png" 49 | min_sdk_android: 21 # android min sdk min:16, default 21 50 | windows: 51 | generate: true 52 | image_path: "assets/polypass.png" 53 | icon_size: 48 # min:48, max:256, default: 48 54 | 55 | 56 | flutter: 57 | uses-material-design: true 58 | assets: 59 | - assets/polypass.png 60 | -------------------------------------------------------------------------------- /rust/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "libpolypass" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [lib] 7 | crate-type = ["staticlib", "cdylib"] 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [dependencies] 12 | flutter_rust_bridge = "1" 13 | suppaftp = "5.1.0" 14 | -------------------------------------------------------------------------------- /rust/src/bridge_generated.io.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | // Section: wire functions 3 | 4 | #[no_mangle] 5 | pub extern "C" fn wire_initialize_provider() -> support::WireSyncReturn { 6 | wire_initialize_provider_impl() 7 | } 8 | 9 | #[no_mangle] 10 | pub extern "C" fn wire_initialize_locked_provider() -> support::WireSyncReturn { 11 | wire_initialize_locked_provider_impl() 12 | } 13 | 14 | #[no_mangle] 15 | pub extern "C" fn wire_initialize_ftp_url( 16 | path: *mut wire_uint_8_list, 17 | host: *mut wire_uint_8_list, 18 | user: *mut wire_uint_8_list, 19 | pass: *mut wire_uint_8_list, 20 | ) -> support::WireSyncReturn { 21 | wire_initialize_ftp_url_impl(path, host, user, pass) 22 | } 23 | 24 | #[no_mangle] 25 | pub extern "C" fn wire_connect( 26 | port_: i64, 27 | provider_lock: wire_RwLockFtpProvider, 28 | url: wire_FtpUrl, 29 | ) { 30 | wire_connect_impl(port_, provider_lock, url) 31 | } 32 | 33 | #[no_mangle] 34 | pub extern "C" fn wire_disconnect(port_: i64, provider_lock: wire_RwLockFtpProvider) { 35 | wire_disconnect_impl(port_, provider_lock) 36 | } 37 | 38 | #[no_mangle] 39 | pub extern "C" fn wire_check_connection( 40 | port_: i64, 41 | provider_lock: wire_RwLockFtpProvider, 42 | url: wire_FtpUrl, 43 | ) { 44 | wire_check_connection_impl(port_, provider_lock, url) 45 | } 46 | 47 | #[no_mangle] 48 | pub extern "C" fn wire_read_file( 49 | port_: i64, 50 | provider_lock: wire_RwLockFtpProvider, 51 | url: wire_FtpUrl, 52 | ) { 53 | wire_read_file_impl(port_, provider_lock, url) 54 | } 55 | 56 | #[no_mangle] 57 | pub extern "C" fn wire_update_file( 58 | port_: i64, 59 | provider_lock: wire_RwLockFtpProvider, 60 | url: wire_FtpUrl, 61 | contents: *mut wire_uint_8_list, 62 | ) { 63 | wire_update_file_impl(port_, provider_lock, url, contents) 64 | } 65 | 66 | #[no_mangle] 67 | pub extern "C" fn wire_delete_file( 68 | port_: i64, 69 | provider_lock: wire_RwLockFtpProvider, 70 | url: wire_FtpUrl, 71 | ) { 72 | wire_delete_file_impl(port_, provider_lock, url) 73 | } 74 | 75 | #[no_mangle] 76 | pub extern "C" fn wire_file_exists( 77 | port_: i64, 78 | provider_lock: wire_RwLockFtpProvider, 79 | url: wire_FtpUrl, 80 | ) { 81 | wire_file_exists_impl(port_, provider_lock, url) 82 | } 83 | 84 | #[no_mangle] 85 | pub extern "C" fn wire_clear_poison(port_: i64, provider_lock: wire_RwLockFtpProvider) { 86 | wire_clear_poison_impl(port_, provider_lock) 87 | } 88 | 89 | // Section: allocate functions 90 | 91 | #[no_mangle] 92 | pub extern "C" fn new_FtpUrl() -> wire_FtpUrl { 93 | wire_FtpUrl::new_with_null_ptr() 94 | } 95 | 96 | #[no_mangle] 97 | pub extern "C" fn new_RwLockFtpProvider() -> wire_RwLockFtpProvider { 98 | wire_RwLockFtpProvider::new_with_null_ptr() 99 | } 100 | 101 | #[no_mangle] 102 | pub extern "C" fn new_uint_8_list_0(len: i32) -> *mut wire_uint_8_list { 103 | let ans = wire_uint_8_list { 104 | ptr: support::new_leak_vec_ptr(Default::default(), len), 105 | len, 106 | }; 107 | support::new_leak_box_ptr(ans) 108 | } 109 | 110 | // Section: related functions 111 | 112 | #[no_mangle] 113 | pub extern "C" fn drop_opaque_FtpProvider(ptr: *const c_void) { 114 | unsafe { 115 | Arc::::decrement_strong_count(ptr as _); 116 | } 117 | } 118 | 119 | #[no_mangle] 120 | pub extern "C" fn share_opaque_FtpProvider(ptr: *const c_void) -> *const c_void { 121 | unsafe { 122 | Arc::::increment_strong_count(ptr as _); 123 | ptr 124 | } 125 | } 126 | 127 | #[no_mangle] 128 | pub extern "C" fn drop_opaque_FtpUrl(ptr: *const c_void) { 129 | unsafe { 130 | Arc::::decrement_strong_count(ptr as _); 131 | } 132 | } 133 | 134 | #[no_mangle] 135 | pub extern "C" fn share_opaque_FtpUrl(ptr: *const c_void) -> *const c_void { 136 | unsafe { 137 | Arc::::increment_strong_count(ptr as _); 138 | ptr 139 | } 140 | } 141 | 142 | #[no_mangle] 143 | pub extern "C" fn drop_opaque_RwLockFtpProvider(ptr: *const c_void) { 144 | unsafe { 145 | Arc::>::decrement_strong_count(ptr as _); 146 | } 147 | } 148 | 149 | #[no_mangle] 150 | pub extern "C" fn share_opaque_RwLockFtpProvider(ptr: *const c_void) -> *const c_void { 151 | unsafe { 152 | Arc::>::increment_strong_count(ptr as _); 153 | ptr 154 | } 155 | } 156 | 157 | // Section: impl Wire2Api 158 | 159 | impl Wire2Api> for wire_FtpUrl { 160 | fn wire2api(self) -> RustOpaque { 161 | unsafe { support::opaque_from_dart(self.ptr as _) } 162 | } 163 | } 164 | impl Wire2Api>> for wire_RwLockFtpProvider { 165 | fn wire2api(self) -> RustOpaque> { 166 | unsafe { support::opaque_from_dart(self.ptr as _) } 167 | } 168 | } 169 | impl Wire2Api for *mut wire_uint_8_list { 170 | fn wire2api(self) -> String { 171 | let vec: Vec = self.wire2api(); 172 | String::from_utf8_lossy(&vec).into_owned() 173 | } 174 | } 175 | 176 | impl Wire2Api> for *mut wire_uint_8_list { 177 | fn wire2api(self) -> Vec { 178 | unsafe { 179 | let wrap = support::box_from_leak_ptr(self); 180 | support::vec_from_leak_ptr(wrap.ptr, wrap.len) 181 | } 182 | } 183 | } 184 | // Section: wire structs 185 | 186 | #[repr(C)] 187 | #[derive(Clone)] 188 | pub struct wire_FtpUrl { 189 | ptr: *const core::ffi::c_void, 190 | } 191 | 192 | #[repr(C)] 193 | #[derive(Clone)] 194 | pub struct wire_RwLockFtpProvider { 195 | ptr: *const core::ffi::c_void, 196 | } 197 | 198 | #[repr(C)] 199 | #[derive(Clone)] 200 | pub struct wire_uint_8_list { 201 | ptr: *mut u8, 202 | len: i32, 203 | } 204 | 205 | // Section: impl NewWithNullPtr 206 | 207 | pub trait NewWithNullPtr { 208 | fn new_with_null_ptr() -> Self; 209 | } 210 | 211 | impl NewWithNullPtr for *mut T { 212 | fn new_with_null_ptr() -> Self { 213 | std::ptr::null_mut() 214 | } 215 | } 216 | 217 | impl NewWithNullPtr for wire_FtpUrl { 218 | fn new_with_null_ptr() -> Self { 219 | Self { 220 | ptr: core::ptr::null(), 221 | } 222 | } 223 | } 224 | impl NewWithNullPtr for wire_RwLockFtpProvider { 225 | fn new_with_null_ptr() -> Self { 226 | Self { 227 | ptr: core::ptr::null(), 228 | } 229 | } 230 | } 231 | 232 | // Section: sync execution mode utility 233 | 234 | #[no_mangle] 235 | pub extern "C" fn free_WireSyncReturn(ptr: support::WireSyncReturn) { 236 | unsafe { 237 | let _ = support::box_from_leak_ptr(ptr); 238 | }; 239 | } 240 | -------------------------------------------------------------------------------- /rust/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![feature(mutex_unpoison)] 2 | 3 | mod api; 4 | mod bridge_generated; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */ 5 | -------------------------------------------------------------------------------- /setup-script-template.iss: -------------------------------------------------------------------------------- 1 | ; Script generated by the Inno Setup Script Wizard. 2 | ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! 3 | 4 | ;CHANGE THIS TO THE PATH OF THE REPOSITORY 5 | #define RepoPath "CHANGE_THIS" 6 | 7 | #define MyAppName "Polypass" 8 | #define MyAppVersion "2.1.0" 9 | #define MyAppExeName "polypass.exe" 10 | #define MyAppAssocName MyAppName + " Vault" 11 | #define MyAppAssocExt ".ppv.json" 12 | #define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt 13 | 14 | [Setup] 15 | ; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. 16 | ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) 17 | AppId={{45D60F3D-1367-4E43-8F0A-AA1630876759} 18 | AppName={#MyAppName} 19 | AppVersion={#MyAppVersion} 20 | ;AppVerName={#MyAppName} {#MyAppVersion} 21 | DefaultDirName={autopf}\{#MyAppName} 22 | ChangesAssociations=yes 23 | DisableProgramGroupPage=yes 24 | LicenseFile={#RepoPath}\LICENSE 25 | ; Remove the following line to run in administrative install mode (install for all users.) 26 | PrivilegesRequired=lowest 27 | PrivilegesRequiredOverridesAllowed=dialog 28 | OutputBaseFilename=polypass_setup 29 | SetupIconFile={#RepoPath}\windows\runner\resources\app_icon.ico 30 | Compression=lzma 31 | SolidCompression=yes 32 | WizardStyle=modern 33 | 34 | [Languages] 35 | Name: "english"; MessagesFile: "compiler:Default.isl" 36 | 37 | [Tasks] 38 | Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked 39 | 40 | [Files] 41 | Source: "{#RepoPath}\windows-install\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion 42 | Source: "{#RepoPath}\windows-install\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs 43 | ; NOTE: Don't use "Flags: ignoreversion" on any shared system files 44 | 45 | [Registry] 46 | Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue 47 | Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey 48 | Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0" 49 | Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1""" 50 | Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: "" 51 | 52 | [Icons] 53 | Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" 54 | Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon 55 | 56 | [Run] 57 | Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent 58 | 59 | -------------------------------------------------------------------------------- /site/index.md: -------------------------------------------------------------------------------- 1 | # Polypass 2 | A simple, secure, and easy to use password manager written with Dart, Flutter, and Rust -------------------------------------------------------------------------------- /test/widget_test.dart: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | polypass 33 | 34 | 35 | 36 | 39 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "polypass", 3 | "short_name": "polypass", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /windows-install/msvcp140.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/windows-install/msvcp140.dll -------------------------------------------------------------------------------- /windows-install/vcruntime140.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/windows-install/vcruntime140.dll -------------------------------------------------------------------------------- /windows-install/vcruntime140_1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/windows-install/vcruntime140_1.dll -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(polypass LANGUAGES CXX) 3 | 4 | set(BINARY_NAME "polypass") 5 | 6 | cmake_policy(SET CMP0063 NEW) 7 | 8 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 9 | 10 | # Configure build options. 11 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 12 | if(IS_MULTICONFIG) 13 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 14 | CACHE STRING "" FORCE) 15 | else() 16 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 17 | set(CMAKE_BUILD_TYPE "Debug" CACHE 18 | STRING "Flutter build mode" FORCE) 19 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 20 | "Debug" "Profile" "Release") 21 | endif() 22 | endif() 23 | 24 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 25 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 26 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 27 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 28 | 29 | # Use Unicode for all projects. 30 | add_definitions(-DUNICODE -D_UNICODE) 31 | 32 | # Compilation settings that should be applied to most targets. 33 | function(APPLY_STANDARD_SETTINGS TARGET) 34 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 35 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 36 | target_compile_options(${TARGET} PRIVATE /EHsc) 37 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 38 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 39 | endfunction() 40 | 41 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 42 | 43 | # Flutter library and tool build rules. 44 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 45 | 46 | # Application build 47 | add_subdirectory("runner") 48 | 49 | # Generated plugin build rules, which manage building the plugins and adding 50 | # them to the application. 51 | include(flutter/generated_plugins.cmake) 52 | 53 | include(./rust.cmake) 54 | 55 | # === Installation === 56 | # Support files are copied into place next to the executable, so that it can 57 | # run in place. This is done instead of making a separate bundle (as on Linux) 58 | # so that building and running from within Visual Studio will work. 59 | set(BUILD_BUNDLE_DIR "$") 60 | # Make the "install" step default, as it's required to run. 61 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 62 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 63 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 64 | endif() 65 | 66 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 67 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 68 | 69 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 70 | COMPONENT Runtime) 71 | 72 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 73 | COMPONENT Runtime) 74 | 75 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 76 | COMPONENT Runtime) 77 | 78 | if(PLUGIN_BUNDLED_LIBRARIES) 79 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 80 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 81 | COMPONENT Runtime) 82 | endif() 83 | 84 | # Fully re-copy the assets directory on each build to avoid having stale files 85 | # from a previous install. 86 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 87 | install(CODE " 88 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 89 | " COMPONENT Runtime) 90 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 91 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 92 | 93 | # Install the AOT library on non-Debug builds only. 94 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 95 | CONFIGURATIONS Profile;Release 96 | COMPONENT Runtime) 97 | -------------------------------------------------------------------------------- /windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 4 | 5 | # Configuration provided via flutter tool. 6 | include(${EPHEMERAL_DIR}/generated_config.cmake) 7 | 8 | # TODO: Move the rest of this into files in ephemeral. See 9 | # https://github.com/flutter/flutter/issues/57146. 10 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 11 | 12 | # === Flutter Library === 13 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 14 | 15 | # Published to parent scope for install step. 16 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 17 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 18 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 19 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 20 | 21 | list(APPEND FLUTTER_LIBRARY_HEADERS 22 | "flutter_export.h" 23 | "flutter_windows.h" 24 | "flutter_messenger.h" 25 | "flutter_plugin_registrar.h" 26 | "flutter_texture_registrar.h" 27 | ) 28 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 29 | add_library(flutter INTERFACE) 30 | target_include_directories(flutter INTERFACE 31 | "${EPHEMERAL_DIR}" 32 | ) 33 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 34 | add_dependencies(flutter flutter_assemble) 35 | 36 | # === Wrapper === 37 | list(APPEND CPP_WRAPPER_SOURCES_CORE 38 | "core_implementations.cc" 39 | "standard_codec.cc" 40 | ) 41 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 42 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 43 | "plugin_registrar.cc" 44 | ) 45 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 46 | list(APPEND CPP_WRAPPER_SOURCES_APP 47 | "flutter_engine.cc" 48 | "flutter_view_controller.cc" 49 | ) 50 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 51 | 52 | # Wrapper sources needed for a plugin. 53 | add_library(flutter_wrapper_plugin STATIC 54 | ${CPP_WRAPPER_SOURCES_CORE} 55 | ${CPP_WRAPPER_SOURCES_PLUGIN} 56 | ) 57 | apply_standard_settings(flutter_wrapper_plugin) 58 | set_target_properties(flutter_wrapper_plugin PROPERTIES 59 | POSITION_INDEPENDENT_CODE ON) 60 | set_target_properties(flutter_wrapper_plugin PROPERTIES 61 | CXX_VISIBILITY_PRESET hidden) 62 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 63 | target_include_directories(flutter_wrapper_plugin PUBLIC 64 | "${WRAPPER_ROOT}/include" 65 | ) 66 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 67 | 68 | # Wrapper sources needed for the runner. 69 | add_library(flutter_wrapper_app STATIC 70 | ${CPP_WRAPPER_SOURCES_CORE} 71 | ${CPP_WRAPPER_SOURCES_APP} 72 | ) 73 | apply_standard_settings(flutter_wrapper_app) 74 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 75 | target_include_directories(flutter_wrapper_app PUBLIC 76 | "${WRAPPER_ROOT}/include" 77 | ) 78 | add_dependencies(flutter_wrapper_app flutter_assemble) 79 | 80 | # === Flutter tool backend === 81 | # _phony_ is a non-existent file to force this command to run every time, 82 | # since currently there's no way to get a full input/output list from the 83 | # flutter tool. 84 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 85 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 86 | add_custom_command( 87 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 88 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 89 | ${CPP_WRAPPER_SOURCES_APP} 90 | ${PHONY_OUTPUT} 91 | COMMAND ${CMAKE_COMMAND} -E env 92 | ${FLUTTER_TOOL_ENVIRONMENT} 93 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 94 | windows-x64 $ 95 | VERBATIM 96 | ) 97 | add_custom_target(flutter_assemble DEPENDS 98 | "${FLUTTER_LIBRARY}" 99 | ${FLUTTER_LIBRARY_HEADERS} 100 | ${CPP_WRAPPER_SOURCES_CORE} 101 | ${CPP_WRAPPER_SOURCES_PLUGIN} 102 | ${CPP_WRAPPER_SOURCES_APP} 103 | ) 104 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void RegisterPlugins(flutter::PluginRegistry* registry) { 12 | FlutterWindowClosePluginRegisterWithRegistrar( 13 | registry->GetRegistrarForPlugin("FlutterWindowClosePlugin")); 14 | } 15 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | flutter_window_close 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | add_executable(${BINARY_NAME} WIN32 5 | "flutter_window.cpp" 6 | "main.cpp" 7 | "utils.cpp" 8 | "win32_window.cpp" 9 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 10 | "Runner.rc" 11 | "runner.exe.manifest" 12 | ) 13 | apply_standard_settings(${BINARY_NAME}) 14 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 15 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 16 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 17 | add_dependencies(${BINARY_NAME} flutter_assemble) 18 | -------------------------------------------------------------------------------- /windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #ifdef FLUTTER_BUILD_NUMBER 64 | #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0 67 | #endif 68 | 69 | #ifdef FLUTTER_BUILD_NAME 70 | #define VERSION_AS_STRING #FLUTTER_BUILD_NAME 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.polypixeldev" "\0" 93 | VALUE "FileDescription", "Polypass" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "Polypass" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2022 com.polypixeldev. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "polypass.exe" "\0" 98 | VALUE "ProductName", "Polypass" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | return true; 30 | } 31 | 32 | void FlutterWindow::OnDestroy() { 33 | if (flutter_controller_) { 34 | flutter_controller_ = nullptr; 35 | } 36 | 37 | Win32Window::OnDestroy(); 38 | } 39 | 40 | LRESULT 41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 42 | WPARAM const wparam, 43 | LPARAM const lparam) noexcept { 44 | // Give Flutter, including plugins, an opportunity to handle window messages. 45 | if (flutter_controller_) { 46 | std::optional result = 47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 48 | lparam); 49 | if (result) { 50 | return *result; 51 | } 52 | } 53 | 54 | switch (message) { 55 | case WM_FONTCHANGE: 56 | flutter_controller_->engine()->ReloadSystemFonts(); 57 | break; 58 | } 59 | 60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 61 | } 62 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.CreateAndShow(L"Polypass", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/polypixeldev/polypass/965e7a08c1e2744d2cb74a95f50ac0a301b252ca/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | if (target_length == 0) { 52 | return std::string(); 53 | } 54 | std::string utf8_string; 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates and shows a win32 window with |title| and position and size using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | -------------------------------------------------------------------------------- /windows/rust.cmake: -------------------------------------------------------------------------------- 1 | # We include Corrosion inline here, but ideally in a project with 2 | # many dependencies we would need to install Corrosion on the system. 3 | # See instructions on https://github.com/AndrewGaspar/corrosion#cmake-install 4 | # Once done, uncomment this line: 5 | # find_package(Corrosion REQUIRED) 6 | 7 | include(FetchContent) 8 | 9 | set(Rust_TOOLCHAIN "nightly") 10 | 11 | FetchContent_Declare( 12 | Corrosion 13 | GIT_REPOSITORY https://github.com/AndrewGaspar/corrosion.git 14 | GIT_TAG origin/master # Optionally specify a version tag or branch here 15 | ) 16 | 17 | FetchContent_MakeAvailable(Corrosion) 18 | 19 | corrosion_import_crate(MANIFEST_PATH ../rust/Cargo.toml) 20 | 21 | # Flutter-specific 22 | 23 | set(CRATE_NAME "libpolypass") 24 | 25 | target_link_libraries(${BINARY_NAME} PRIVATE ${CRATE_NAME}) 26 | 27 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 28 | --------------------------------------------------------------------------------