├── .github
├── dependabot.yml
└── workflows
│ ├── flutter.yml
│ └── remove-old-artifacts.yml
├── .gitignore
├── .metadata
├── .vscode
└── launch.json
├── LICENSE
├── README.md
├── analysis_options.yaml
├── android
├── .gitignore
├── app
│ ├── build.gradle
│ └── src
│ │ ├── debug
│ │ └── AndroidManifest.xml
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── kotlin
│ │ │ └── com
│ │ │ │ └── hoc
│ │ │ │ └── node_auth
│ │ │ │ ├── MainActivity.kt
│ │ │ │ └── MyApp.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
└── settings.gradle
├── assets
├── bg.jpg
└── user.png
├── ios
├── .gitignore
├── Flutter
│ ├── AppFrameworkInfo.plist
│ ├── Debug.xcconfig
│ └── Release.xcconfig
├── Podfile
├── Podfile.lock
├── 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
├── lib
├── app.dart
├── data
│ ├── constants.dart
│ ├── exception
│ │ ├── local_data_source_exception.dart
│ │ └── remote_data_source_exception.dart
│ ├── local
│ │ ├── entities
│ │ │ ├── user_and_token_entity.dart
│ │ │ ├── user_and_token_entity.g.dart
│ │ │ ├── user_entity.dart
│ │ │ └── user_entity.g.dart
│ │ ├── local_data_source.dart
│ │ ├── method_channel_crypto_impl.dart
│ │ └── shared_pref_util.dart
│ ├── mappers.dart
│ ├── remote
│ │ ├── api_service.dart
│ │ ├── auth_interceptor.dart
│ │ ├── remote_data_source.dart
│ │ └── response
│ │ │ ├── token_response.dart
│ │ │ ├── token_response.g.dart
│ │ │ ├── user_response.dart
│ │ │ └── user_response.g.dart
│ ├── serializers.dart
│ ├── serializers.g.dart
│ └── user_repository_imp.dart
├── domain
│ ├── models
│ │ ├── app_error.dart
│ │ ├── auth_state.dart
│ │ ├── auth_state.g.dart
│ │ ├── user.dart
│ │ ├── user.g.dart
│ │ ├── user_and_token.dart
│ │ └── user_and_token.g.dart
│ ├── repositories
│ │ └── user_repository.dart
│ └── usecases
│ │ ├── change_password_use_case.dart
│ │ ├── get_auth_state_stream_use_case.dart
│ │ ├── get_auth_state_use_case.dart
│ │ ├── login_use_case.dart
│ │ ├── logout_use_case.dart
│ │ ├── register_use_case.dart
│ │ ├── reset_password_use_case.dart
│ │ ├── send_reset_password_email_use_case.dart
│ │ └── upload_image_use_case.dart
├── main.dart
├── pages
│ ├── home
│ │ ├── change_password
│ │ │ ├── change_password.dart
│ │ │ ├── change_password_bloc.dart
│ │ │ ├── change_password_bottomsheet.dart
│ │ │ ├── change_password_state.dart
│ │ │ └── change_password_state.g.dart
│ │ ├── home.dart
│ │ ├── home_bloc.dart
│ │ ├── home_page.dart
│ │ ├── home_profile_widget.dart
│ │ └── home_state.dart
│ ├── login
│ │ ├── login.dart
│ │ ├── login_bloc.dart
│ │ ├── login_page.dart
│ │ └── login_state.dart
│ ├── register
│ │ ├── register.dart
│ │ ├── register_bloc.dart
│ │ ├── register_page.dart
│ │ └── register_state.dart
│ └── reset_password
│ │ ├── input_token
│ │ ├── input_token_and_reset_password.dart
│ │ ├── input_token_and_reset_password_bloc.dart
│ │ └── input_token_and_reset_password_page.dart
│ │ ├── reset_password_page.dart
│ │ └── send_email
│ │ ├── send_email.dart
│ │ ├── send_email_bloc.dart
│ │ ├── send_email_page.dart
│ │ └── send_email_state.dart
├── utils
│ ├── snackbar.dart
│ ├── streams.dart
│ ├── type_defs.dart
│ ├── unit.dart
│ └── validators.dart
└── widgets
│ └── password_textfield.dart
├── pubspec.lock
├── pubspec.yaml
├── renovate.json
├── screenshots
├── Screenshot1.png
├── Screenshot2.png
├── Screenshot3.png
├── Screenshot4.png
├── Screenshot5.png
└── Screenshot6.png
├── 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
├── .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
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # To get started with Dependabot version updates, you'll need to specify which
2 | # package ecosystems to update and where the package manifests are located.
3 | # Please see the documentation for all configuration options:
4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5 |
6 | version: 2
7 | enable-beta-ecosystems: true
8 | updates:
9 | - package-ecosystem: "pub" # See documentation for possible values
10 | directory: "/" # Location of package manifests
11 | schedule:
12 | interval: "daily"
13 |
--------------------------------------------------------------------------------
/.github/workflows/flutter.yml:
--------------------------------------------------------------------------------
1 | name: Flutter
2 |
3 | on:
4 | push:
5 | branches: [ master ]
6 | pull_request:
7 | branches: [ master ]
8 |
9 | jobs:
10 | build:
11 | runs-on: ubuntu-latest
12 |
13 | strategy:
14 | matrix:
15 | flutter-channel: [ 'stable' ]
16 |
17 | steps:
18 | - uses: actions/checkout@v4
19 |
20 | - uses: actions/setup-java@v4
21 | with:
22 | distribution: 'zulu'
23 | java-version: '17'
24 |
25 | - uses: subosito/flutter-action@v2
26 | with:
27 | channel: ${{ matrix.flutter-channel }}
28 |
29 | - name: Print Dart SDK version
30 | run: dart --version
31 |
32 | - name: Print Flutter SDK version
33 | run: flutter --version
34 |
35 | - name: Install dependencies
36 | run: dart pub get
37 |
38 | - name: Format code
39 | if: ${{ matrix.flutter-channel == 'stable' }}
40 | run: dart format lib --set-exit-if-changed
41 |
42 | - name: Analyze
43 | if: ${{ matrix.flutter-channel == 'stable' }}
44 | run: dart analyze lib
45 |
46 | - name: Gen code
47 | run: dart run build_runner build --delete-conflicting-outputs
48 |
49 | - name: Build Debug APK
50 | run: flutter build apk --debug --no-shrink
51 |
52 | - name: Upload APK
53 | if: ${{ matrix.flutter-channel == 'stable' }}
54 | uses: actions/upload-artifact@v4
55 | with:
56 | name: app-${{ matrix.flutter-channel }}
57 | path: build/app/outputs/apk/debug/app-debug.apk
58 |
59 |
--------------------------------------------------------------------------------
/.github/workflows/remove-old-artifacts.yml:
--------------------------------------------------------------------------------
1 | name: Remove old artifacts
2 |
3 | on:
4 | # push:
5 | # branches: [ master ]
6 |
7 | schedule:
8 | # Runs at 01:00 UTC on the 1, 8, 15, 22 and 29th of every month.
9 | - cron: '0 1 */7 * *'
10 |
11 | workflow_dispatch:
12 |
13 | jobs:
14 | remove-old-artifacts:
15 | runs-on: ubuntu-latest
16 | timeout-minutes: 10
17 |
18 | steps:
19 | - name: Remove old artifacts
20 | uses: c-hive/gha-remove-artifacts@v1
21 | with:
22 | age: '7 days'
23 | skip-tags: true
24 | skip-recent: 5
25 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | **/ios/Flutter/.last_build_id
26 | .dart_tool/
27 | .flutter-plugins
28 | .flutter-plugins-dependencies
29 | .packages
30 | .pub-cache/
31 | .pub/
32 | /build/
33 |
34 | # Web related
35 | lib/generated_plugin_registrant.dart
36 |
37 | # Symbolication related
38 | app.*.symbols
39 |
40 | # Obfuscation related
41 | app.*.map.json
42 |
43 | # Exceptions to above rules.
44 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
45 |
--------------------------------------------------------------------------------
/.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: b176042c1a8a9fdb5c96051b613895e7f0ab167b
8 | channel: master
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/.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": "Flutter",
9 | "type": "dart",
10 | "request": "launch",
11 | "program": "lib/main.dart"
12 | },
13 | {
14 | "name": "Flutter",
15 | "request": "launch",
16 | "type": "dart"
17 | }
18 | ]
19 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Petrus Nguyễn Thái Học
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # node_auth # node-auth-flutter-BLoC-pattern-RxDart
2 |
3 | - ❄️❄️ `BLoC pattern` `rxdart` `stream` 🐋🐋 Simple auth app flutter, server node.js, BLoC pattern, RxDart
4 | - Functionalities: `LOGIN`, `LOGOUT`, `REGISTER`, `CHANGE PASSWORD`, `CHANGE AVATAR`, `FORGOT PASSWORD` 🌀🌀
5 | - **Pure rxdart BLoC pattern**. BLoC pattern without library. Flutter Functional & Reactive programming 🌱🌱
6 | - Platform-Specific Code With **Flutter Method Channel**
7 | - [Android](https://github.com/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/blob/master/android/app/src/main/kotlin/com/hoc/node_auth/MainActivity.kt#L21): using [Tink library](https://github.com/google/tink) to encrypt/decrypt access token and user info.
8 | - [iOS](https://github.com/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/blob/master/ios/Runner/AppDelegate.swift#L20): using [CryptoSwift library](https://github.com/krzyzanowskim/CryptoSwift) to encrypt/decrypt access token and user info.
9 |
10 | [](https://github.com/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/actions/workflows/flutter.yml)
11 | [](https://codemagic.io/apps/5e299cf863c55e0019edee46/5e299cf863c55e0019edee45/latest_build)
12 | 
13 | [](https://hits.seeyoufarm.com)
14 |
15 |
16 | Liked some of my work? Buy me a coffee (or more likely a beer)
17 |
18 |
19 |
20 | ## Video demo:
21 |
22 | [Youtube](https://youtu.be/OvsDKfy0aOs)
23 |
24 | ## Download apk [here](https://nightly.link/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/workflows/flutter/master/app.zip)
25 |
26 | ## Flutter version (stable channel)
27 |
28 | ```yaml
29 | environment:
30 | sdk: ^3.4.3
31 | flutter: ">=3.22.2"
32 | ```
33 |
34 | ## Screenshots
35 |
36 | | | | |
37 | | :---: | :---: | :---: |
38 | |  |  | 
39 | |  |  | 
40 |
41 | ## Find this repository useful? ❤️
42 |
43 | Star this repository and follow me for next creations! Thanks for your support 💗💗.
44 |
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | include: package:flutter_lints/flutter.yaml
2 |
3 | analyzer:
4 | language:
5 | strict-casts: true
6 | strict-raw-types: true
7 | strict-inference: true
8 |
9 | linter:
10 | rules:
11 | - prefer_final_locals
12 | # https://github.com/dart-lang/lints#migrating-from-packagepedantic
13 | - always_declare_return_types
14 | - prefer_single_quotes
15 | - unawaited_futures
16 | - unsafe_html
17 | - avoid_slow_async_io
--------------------------------------------------------------------------------
/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 | plugins {
2 | id "com.android.application"
3 | id "kotlin-android"
4 | id "dev.flutter.flutter-gradle-plugin"
5 | }
6 |
7 | kotlin {
8 | jvmToolchain {
9 | languageVersion = JavaLanguageVersion.of(17)
10 | vendor = JvmVendorSpec.AZUL
11 | }
12 | }
13 |
14 | def localProperties = new Properties()
15 | def localPropertiesFile = rootProject.file('local.properties')
16 | if (localPropertiesFile.exists()) {
17 | localPropertiesFile.withReader('UTF-8') { reader ->
18 | localProperties.load(reader)
19 | }
20 | }
21 |
22 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
23 | if (flutterVersionCode == null) {
24 | flutterVersionCode = '1'
25 | }
26 |
27 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
28 | if (flutterVersionName == null) {
29 | flutterVersionName = '1.0'
30 | }
31 |
32 | android {
33 | compileSdkVersion 34
34 | namespace "com.hoc.node_auth"
35 |
36 | compileOptions {
37 | sourceCompatibility JavaVersion.VERSION_1_8
38 | targetCompatibility JavaVersion.VERSION_1_8
39 | }
40 |
41 | kotlinOptions {
42 | jvmTarget = '1.8'
43 | }
44 |
45 | sourceSets {
46 | main.java.srcDirs += 'src/main/kotlin'
47 | }
48 |
49 | defaultConfig {
50 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
51 | applicationId "com.hoc.node_auth"
52 | minSdkVersion 21
53 | targetSdkVersion 34
54 | versionCode flutterVersionCode.toInteger()
55 | versionName flutterVersionName
56 | multiDexEnabled true
57 | }
58 |
59 | buildTypes {
60 | release {
61 | // TODO: Add your own signing config for the release build.
62 | // Signing with the debug keys for now, so `flutter run --release` works.
63 | signingConfig signingConfigs.debug
64 | }
65 | }
66 | }
67 |
68 | flutter {
69 | source '../..'
70 | }
71 |
72 | dependencies {
73 | implementation "androidx.multidex:multidex:2.0.1"
74 |
75 | implementation "com.google.crypto.tink:tink-android:1.7.0"
76 |
77 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0'
78 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0'
79 | }
80 |
--------------------------------------------------------------------------------
/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
17 |
21 |
24 |
25 |
26 |
27 |
28 |
29 |
31 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/android/app/src/main/kotlin/com/hoc/node_auth/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.hoc.node_auth
2 |
3 | import android.util.Log
4 | import com.google.crypto.tink.subtle.Base64
5 | import io.flutter.embedding.android.FlutterActivity
6 | import io.flutter.embedding.engine.FlutterEngine
7 | import io.flutter.plugin.common.MethodCall
8 | import io.flutter.plugin.common.MethodChannel
9 | import kotlinx.coroutines.*
10 |
11 | class MainActivity : FlutterActivity() {
12 | private lateinit var cryptoChannel: MethodChannel
13 | private lateinit var mainScope: CoroutineScope
14 |
15 | //region Lifecycle
16 | override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
17 | super.configureFlutterEngine(flutterEngine)
18 | Log.d("Flutter", "configureFlutterEngine flutterEngine=$flutterEngine $this")
19 |
20 | mainScope = MainScope()
21 | cryptoChannel = MethodChannel(
22 | flutterEngine.dartExecutor.binaryMessenger,
23 | CRYPTO_CHANNEL,
24 | ).apply { setMethodCallHandler(MethodCallHandlerImpl()) }
25 | }
26 |
27 | override fun cleanUpFlutterEngine(flutterEngine: FlutterEngine) {
28 | super.cleanUpFlutterEngine(flutterEngine)
29 | Log.d("Flutter", "cleanUpFlutterEngine flutterEngine=$flutterEngine $this")
30 |
31 | cryptoChannel.setMethodCallHandler(null)
32 | mainScope.cancel()
33 | }
34 | //endregion
35 |
36 | private inner class MethodCallHandlerImpl : MethodChannel.MethodCallHandler {
37 | override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
38 | when (call.method) {
39 | ENCRYPT_METHOD -> encrypt(call, result)
40 | DECRYPT_METHOD -> decrypt(call, result)
41 | else -> result.notImplemented()
42 | }
43 | }
44 | }
45 |
46 | //region Handlers
47 | private fun encrypt(
48 | call: MethodCall,
49 | result: MethodChannel.Result
50 | ) {
51 | val plaintext = checkNotNull(call.arguments()) { "plaintext must be not null" }
52 |
53 | mainScope.launch {
54 | runCatching {
55 | withContext(Dispatchers.IO) {
56 | plaintext
57 | .encodeToByteArray()
58 | .let { myApp.aead.encrypt(it, null) }
59 | .let { Base64.encode(it) }
60 | }
61 | }
62 | .onSuccess { result.success(it) }
63 | .onFailureExceptCancellationException {
64 | Log.e("Flutter", "encrypt", it)
65 | result.error(CRYPTO_ERROR_CODE, it.message, null)
66 | }
67 | }
68 | }
69 |
70 | private fun decrypt(
71 | call: MethodCall,
72 | result: MethodChannel.Result
73 | ) {
74 | val ciphertext = checkNotNull(call.arguments()) { "ciphertext must be not null" }
75 |
76 | mainScope.launch {
77 | runCatching {
78 | withContext(Dispatchers.IO) {
79 | Base64
80 | .decode(ciphertext, Base64.DEFAULT)
81 | .let { myApp.aead.decrypt(it, null) }
82 | .decodeToString()
83 | }
84 | }
85 | .onSuccess { result.success(it) }
86 | .onFailureExceptCancellationException {
87 | Log.e("Flutter", "decrypt", it)
88 | result.error(CRYPTO_ERROR_CODE, it.message, null)
89 | }
90 | }
91 | }
92 | //endregion
93 |
94 | private companion object {
95 | const val CRYPTO_CHANNEL = "com.hoc.node_auth/crypto"
96 | const val CRYPTO_ERROR_CODE = "com.hoc.node_auth/crypto_error"
97 | const val ENCRYPT_METHOD = "encrypt"
98 | const val DECRYPT_METHOD = "decrypt"
99 | }
100 | }
101 |
102 | private inline fun Result.onFailureExceptCancellationException(action: (throwable: Throwable) -> Unit): Result {
103 | return onFailure {
104 | if (it is CancellationException) throw it
105 | action(it)
106 | }
107 | }
--------------------------------------------------------------------------------
/android/app/src/main/kotlin/com/hoc/node_auth/MyApp.kt:
--------------------------------------------------------------------------------
1 | package com.hoc.node_auth
2 |
3 | import android.app.Activity
4 | import androidx.multidex.MultiDex
5 | import com.google.crypto.tink.Aead
6 | import com.google.crypto.tink.KeyTemplates
7 | import com.google.crypto.tink.aead.AeadConfig
8 | import com.google.crypto.tink.integration.android.AndroidKeysetManager
9 | import com.google.crypto.tink.integration.android.AndroidKeystoreKmsClient
10 | import io.flutter.app.FlutterApplication
11 |
12 | class MyApp : FlutterApplication() {
13 | val aead: Aead by lazy {
14 | AndroidKeysetManager
15 | .Builder()
16 | .withSharedPref(this, KEYSET_NAME, PREF_FILE_NAME)
17 | .withKeyTemplate(KeyTemplates.get("AES256_GCM"))
18 | .withMasterKeyUri(MASTER_KEY_URI)
19 | .build()
20 | .keysetHandle
21 | .getPrimitive(Aead::class.java)
22 | }
23 |
24 | override fun onCreate() {
25 | super.onCreate()
26 | MultiDex.install(this)
27 | AeadConfig.register()
28 | }
29 |
30 | private companion object {
31 | private const val KEYSET_NAME = "nodeauth_keyset"
32 | private const val PREF_FILE_NAME = "nodeauth_pref"
33 | private const val MASTER_KEY_URI = "${AndroidKeystoreKmsClient.PREFIX}nodeauth_master_key"
34 | }
35 | }
36 |
37 | val Activity.myApp: MyApp get() = application as MyApp
--------------------------------------------------------------------------------
/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/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/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 | allprojects {
2 | repositories {
3 | google()
4 | jcenter()
5 | }
6 | }
7 |
8 | rootProject.buildDir = '../build'
9 | subprojects {
10 | project.buildDir = "${rootProject.buildDir}/${project.name}"
11 | }
12 | subprojects {
13 | project.evaluationDependsOn(':app')
14 | }
15 |
16 | tasks.register("clean", Delete) {
17 | delete rootProject.buildDir
18 | }
--------------------------------------------------------------------------------
/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-8.10.2-bin.zip
7 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | def flutterSdkPath = {
3 | def properties = new Properties()
4 | file("local.properties").withInputStream { properties.load(it) }
5 | def flutterSdkPath = properties.getProperty("flutter.sdk")
6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7 | return flutterSdkPath
8 | }()
9 |
10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
11 |
12 | repositories {
13 | google()
14 | mavenCentral()
15 | gradlePluginPortal()
16 | }
17 | }
18 |
19 | plugins {
20 | id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21 | id "com.android.application" version "8.7.2" apply false
22 | id "org.jetbrains.kotlin.android" version "2.0.21" apply false
23 | id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0")
24 | }
25 |
26 | rootProject.name = "github_search"
27 | include ":app"
--------------------------------------------------------------------------------
/assets/bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/assets/bg.jpg
--------------------------------------------------------------------------------
/assets/user.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/assets/user.png
--------------------------------------------------------------------------------
/ios/.gitignore:
--------------------------------------------------------------------------------
1 | *.mode1v3
2 | *.mode2v3
3 | *.moved-aside
4 | *.pbxuser
5 | *.perspectivev3
6 | **/*sync/
7 | .sconsign.dblite
8 | .tags*
9 | **/.vagrant/
10 | **/DerivedData/
11 | Icon?
12 | **/Pods/
13 | **/.symlinks/
14 | profile
15 | xcuserdata
16 | **/.generated/
17 | Flutter/App.framework
18 | Flutter/Flutter.framework
19 | Flutter/Flutter.podspec
20 | Flutter/Generated.xcconfig
21 | Flutter/app.flx
22 | Flutter/app.zip
23 | Flutter/flutter_assets/
24 | Flutter/flutter_export_environment.sh
25 | ServiceDefinitions.json
26 | Runner/GeneratedPluginRegistrant.*
27 |
28 | # Exceptions to above rules.
29 | !default.mode1v3
30 | !default.mode2v3
31 | !default.pbxuser
32 | !default.perspectivev3
33 |
--------------------------------------------------------------------------------
/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
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 "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment this line to define a global platform for your project
2 | # platform :ios, '9.0'
3 |
4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6 |
7 | project 'Runner', {
8 | 'Debug' => :debug,
9 | 'Profile' => :release,
10 | 'Release' => :release,
11 | }
12 |
13 | def flutter_root
14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
15 | unless File.exist?(generated_xcode_build_settings_path)
16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
17 | end
18 |
19 | File.foreach(generated_xcode_build_settings_path) do |line|
20 | matches = line.match(/FLUTTER_ROOT\=(.*)/)
21 | return matches[1].strip if matches
22 | end
23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
24 | end
25 |
26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
27 |
28 | flutter_ios_podfile_setup
29 |
30 | target 'Runner' do
31 | use_frameworks!
32 | use_modular_headers!
33 |
34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
35 |
36 | pod 'CryptoSwift', '~> 1.2.0'
37 | end
38 |
39 | post_install do |installer|
40 | installer.pods_project.targets.each do |target|
41 | flutter_additional_ios_build_settings(target)
42 | end
43 | end
44 |
--------------------------------------------------------------------------------
/ios/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - CryptoSwift (1.2.0)
3 | - cupertino_http (0.0.1):
4 | - Flutter
5 | - Flutter (1.0.0)
6 | - image_picker_ios (0.0.1):
7 | - Flutter
8 | - shared_preferences_ios (0.0.1):
9 | - Flutter
10 |
11 | DEPENDENCIES:
12 | - CryptoSwift (~> 1.2.0)
13 | - cupertino_http (from `.symlinks/plugins/cupertino_http/ios`)
14 | - Flutter (from `Flutter`)
15 | - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
16 | - shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`)
17 |
18 | SPEC REPOS:
19 | trunk:
20 | - CryptoSwift
21 |
22 | EXTERNAL SOURCES:
23 | cupertino_http:
24 | :path: ".symlinks/plugins/cupertino_http/ios"
25 | Flutter:
26 | :path: Flutter
27 | image_picker_ios:
28 | :path: ".symlinks/plugins/image_picker_ios/ios"
29 | shared_preferences_ios:
30 | :path: ".symlinks/plugins/shared_preferences_ios/ios"
31 |
32 | SPEC CHECKSUMS:
33 | CryptoSwift: 40e374e45291d8dceedcb0d6184da94533eaabdf
34 | cupertino_http: 5f8b1161107fe6c8d94a0c618735a033d93fa7db
35 | Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
36 | image_picker_ios: b786a5dcf033a8336a657191401bfdf12017dabb
37 | shared_preferences_ios: 548a61f8053b9b8a49ac19c1ffbc8b92c50d68ad
38 |
39 | PODFILE CHECKSUM: 28949384d1a9817c5c0092fcf6ffc3a836337eb0
40 |
41 | COCOAPODS: 1.11.2
42 |
--------------------------------------------------------------------------------
/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 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/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 | import CryptoSwift
4 |
5 | private extension String {
6 | static let CRYPTO_CHANNEL = "com.hoc.node_auth/crypto"
7 | static let CRYPTO_ERROR_CODE = "com.hoc.node_auth/crypto_error"
8 | static let ENCRYPT_METHOD = "encrypt"
9 | static let DECRYPT_METHOD = "decrypt"
10 | }
11 |
12 | @UIApplicationMain
13 | @objc class AppDelegate: FlutterAppDelegate {
14 | override func application(
15 | _ application: UIApplication,
16 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
17 | ) -> Bool {
18 | let flutterVC = window?.rootViewController as! FlutterViewController
19 |
20 | let cryptoChannel = FlutterMethodChannel(
21 | name: .CRYPTO_CHANNEL,
22 | binaryMessenger: flutterVC.binaryMessenger
23 | )
24 | cryptoChannel.setMethodCallHandler { call, result in
25 | switch call.method {
26 | case .ENCRYPT_METHOD: encrypt(call: call, result: result)
27 | case .DECRYPT_METHOD: decrypt(call: call, result: result)
28 | default:
29 | result(FlutterMethodNotImplemented)
30 | }
31 | }
32 |
33 | GeneratedPluginRegistrant.register(with: self)
34 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
35 | }
36 | }
37 |
38 | private enum AESConfig {
39 | static let iv: [UInt8] = "_hoc081098_auth_".bytes
40 | static let key: [UInt8] = "__hoc081098_nodejs_auth_rxdart__".bytes
41 |
42 | static let backgroundQueue = DispatchQueue.global(qos: .userInitiated)
43 |
44 | static func gcm() -> GCM { GCM(iv: AESConfig.iv, mode: .combined) }
45 | }
46 |
47 | private func complete(result: @escaping FlutterResult, with error: Error) {
48 | NSLog("\n[NODE_AUTH] Error: \(error)")
49 |
50 | executeOnMain {
51 | result(
52 | FlutterError(
53 | code: .CRYPTO_ERROR_CODE,
54 | message: error.localizedDescription,
55 | details: nil
56 | )
57 | )
58 | }
59 | }
60 |
61 | private func executeOnMain(block: @escaping () -> Void) {
62 | if Thread.isMainThread {
63 | block()
64 | } else {
65 | DispatchQueue.main.async {
66 | block()
67 | }
68 | }
69 | }
70 |
71 | private func useAES(
72 | input: String,
73 | result: @escaping FlutterResult,
74 | inputToBytes: (String) -> [UInt8]?,
75 | bytesToString: @escaping ([UInt8]) -> String?,
76 | block: @escaping (AES, [UInt8]) throws -> [UInt8]
77 | ) {
78 | guard let inputBytes = inputToBytes(input) else {
79 | NSLog("\n[NODE_AUTH] Error: inputToBytes returns nil")
80 |
81 | executeOnMain {
82 | result(
83 | FlutterError(
84 | code: .CRYPTO_ERROR_CODE,
85 | message: "An unexpected error occurred!",
86 | details: nil
87 | )
88 | )
89 | }
90 | return
91 | }
92 |
93 | AESConfig.backgroundQueue.async {
94 | let start = DispatchTime.now()
95 |
96 | do {
97 | let aes = try AES(
98 | key: AESConfig.key,
99 | blockMode: AESConfig.gcm(),
100 | padding: .noPadding
101 | )
102 |
103 | let outputBytes = try block(aes, inputBytes)
104 | guard let stringResult = bytesToString(outputBytes) else {
105 | NSLog("\n[NODE_AUTH] Error: bytesToString returns nil")
106 |
107 | executeOnMain {
108 | result(
109 | FlutterError(
110 | code: .CRYPTO_ERROR_CODE,
111 | message: "An unexpected error occurred!",
112 | details: nil
113 | )
114 | )
115 | }
116 | return
117 | }
118 |
119 | let end = DispatchTime.now()
120 | let nanoTime = end.uptimeNanoseconds - start.uptimeNanoseconds
121 | let millisTime = Double(nanoTime) / 1_000_000
122 | NSLog("\n[NODE_AUTH] Time: \(millisTime) ms")
123 |
124 | executeOnMain { result(stringResult) }
125 | } catch {
126 | complete(result: result, with: error)
127 | }
128 | }
129 | }
130 |
131 | private func encrypt(call: FlutterMethodCall, result: @escaping FlutterResult) {
132 | useAES(
133 | input: call.arguments as! String,
134 | result: result,
135 | inputToBytes: { $0.bytes },
136 | bytesToString: base64Encode(bytes:)
137 | ) { aes, bytes in try aes.encrypt(bytes) }
138 | }
139 |
140 |
141 | private func decrypt(call: FlutterMethodCall, result: @escaping FlutterResult) {
142 | useAES(
143 | input: call.arguments as! String,
144 | result: result,
145 | inputToBytes: base64Decode(s:),
146 | bytesToString: { .init(bytes: $0, encoding: .utf8) }
147 | ) { aes, bytes in try aes.decrypt(bytes) }
148 | }
149 |
150 | func base64Decode(s: String) -> [UInt8]? {
151 | Data(base64Encoded: s)?.bytes
152 | }
153 |
154 | func base64Encode(bytes: [UInt8]) -> String {
155 | Data(bytes).base64EncodedString()
156 | }
157 |
--------------------------------------------------------------------------------
/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/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/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/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/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/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/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/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/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/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/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/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/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/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/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/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/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/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/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/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/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/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/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/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/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/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/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/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/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/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/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/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoc081098/node-auth-flutter-BLoC-pattern-RxDart/68edfb61af7d048063c0bf9d7e4780f15e8e9a68/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 | NSPhotoLibraryUsageDescription
6 | This app needs access to your photos
7 | CFBundleDevelopmentRegion
8 | $(DEVELOPMENT_LANGUAGE)
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | node_auth
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 | CADisableMinimumFrameDurationOnPhone
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
2 |
--------------------------------------------------------------------------------
/lib/app.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_bloc_pattern/flutter_bloc_pattern.dart';
3 | import 'package:flutter_disposebag/flutter_disposebag.dart';
4 | import 'package:flutter_provider/flutter_provider.dart';
5 | import 'package:node_auth/domain/models/app_error.dart';
6 | import 'package:node_auth/domain/models/auth_state.dart';
7 | import 'package:node_auth/domain/repositories/user_repository.dart';
8 | import 'package:node_auth/domain/usecases/get_auth_state_stream_use_case.dart';
9 | import 'package:node_auth/domain/usecases/get_auth_state_use_case.dart';
10 | import 'package:node_auth/domain/usecases/login_use_case.dart';
11 | import 'package:node_auth/domain/usecases/logout_use_case.dart';
12 | import 'package:node_auth/domain/usecases/register_use_case.dart';
13 | import 'package:node_auth/domain/usecases/upload_image_use_case.dart';
14 | import 'package:node_auth/pages/home/home.dart';
15 | import 'package:node_auth/pages/login/login.dart';
16 | import 'package:node_auth/pages/register/register.dart';
17 | import 'package:node_auth/pages/reset_password/reset_password_page.dart';
18 | import 'package:node_auth/utils/streams.dart';
19 |
20 | class MyApp extends StatelessWidget {
21 | const MyApp({super.key});
22 |
23 | @override
24 | Widget build(BuildContext context) {
25 | final routes = {
26 | Navigator.defaultRouteName: (context) {
27 | return Provider.factory(
28 | (context) => GetAuthStateUseCase(context.get()),
29 | child: const Home(),
30 | );
31 | },
32 | RegisterPage.routeName: (context) {
33 | return BlocProvider(
34 | initBloc: (context) => RegisterBloc(
35 | RegisterUseCase(context.get()),
36 | ),
37 | child: const RegisterPage(),
38 | );
39 | },
40 | HomePage.routeName: (context) {
41 | return BlocProvider(
42 | initBloc: (context) {
43 | final userRepository = context.get();
44 | return HomeBloc(
45 | LogoutUseCase(userRepository),
46 | GetAuthStateStreamUseCase(userRepository),
47 | UploadImageUseCase(userRepository),
48 | );
49 | },
50 | child: const HomePage(),
51 | );
52 | },
53 | LoginPage.routeName: (context) {
54 | return BlocProvider(
55 | initBloc: (context) => LoginBloc(
56 | LoginUseCase(context.get()),
57 | ),
58 | child: const LoginPage(),
59 | );
60 | },
61 | ResetPasswordPage.routeName: (context) {
62 | return const ResetPasswordPage();
63 | },
64 | };
65 |
66 | final themeData = ThemeData(brightness: Brightness.dark);
67 | return Provider