diff --git a/flutter-ory-network/.gitignore b/flutter-ory-network/.gitignore new file mode 100644 index 00000000..583a2212 --- /dev/null +++ b/flutter-ory-network/.gitignore @@ -0,0 +1,94 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.build/ +.buildlog/ +.history +.svn/ +.swiftpm/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Android related +**/android/build/ +**/android/**/gradle-wrapper.jar +**/android/.gradle +**/android/captures/ +**/android/gradlew +**/android/gradlew.bat +**/android/local.properties +**/android/**/GeneratedPluginRegistrant.java + +# iOS/XCode related +**/ios/**/*.mode1v3 +**/ios/**/*.mode2v3 +**/ios/**/*.moved-aside +**/ios/**/*.pbxuser +**/ios/**/*.perspectivev3 +**/ios/**/*sync/ +**/ios/**/.sconsign.dblite +**/ios/**/.tags* +**/ios/**/.vagrant/ +**/ios/**/DerivedData/ +**/ios/**/Icon? +**/ios/**/Pods/ +**/ios/**/.symlinks/ +**/ios/**/profile +**/ios/**/xcuserdata +**/ios/.generated/ +**/ios/Flutter/App.framework +**/ios/Flutter/Flutter.framework +**/ios/Flutter/Flutter.podspec +**/ios/Flutter/Generated.xcconfig +**/ios/Flutter/app.flx +**/ios/Flutter/app.zip +**/ios/Flutter/flutter_assets/ +**/ios/Flutter/flutter_export_environment.sh +**/ios/ServiceDefinitions.json +**/ios/Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!**/ios/**/default.mode1v3 +!**/ios/**/default.mode2v3 +!**/ios/**/default.pbxuser +!**/ios/**/default.perspectivev3 +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release + +# Environmental variables +.env diff --git a/flutter-ory-network/.metadata b/flutter-ory-network/.metadata new file mode 100644 index 00000000..de745e4a --- /dev/null +++ b/flutter-ory-network/.metadata @@ -0,0 +1,45 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled. + +version: + revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + channel: stable + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + - platform: android + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + - platform: ios + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + - platform: linux + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + - platform: macos + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + - platform: web + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + - platform: windows + create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/flutter-ory-network/README.md b/flutter-ory-network/README.md new file mode 100644 index 00000000..d3acb7d6 --- /dev/null +++ b/flutter-ory-network/README.md @@ -0,0 +1,78 @@ +# Integrate Ory Network with Flutter + +This example demonstrates how to use Ory Network with a Flutter app. It includes +login and registration with email and password. + +## Develop + +### Prerequisites + +1. [Flutter](https://docs.flutter.dev/get-started/install) version 3.13.1 +2. Xcode and Android Studio +3. iOS Simulator or Android Emulator +4. [Ory Network](https://console.ory.sh/) project + +### Environmental variables + +Create .env file with your project url in the root folder of the Flutter app + +```env +ORY_BASE_URL=https://{your-project-slug}.projects.oryapis.com +``` + +### Google Sign In + +If you use Google Sign In on Android, add following variable to .env file + +```env +WEB_CLIENT_ID={web-client-id}.apps.googleusercontent.com +``` + +If you use Google Sign In on iOS, add following variable to .env file + +```env + +IOS_CLIENT_ID={ios-client-id}.apps.googleusercontent.com +``` + +Additionally, add iOS URL scheme to Info.plist. It can be found in additional +information of your iOS Client ID. + +```xml +CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLSchemes + + + IOS_URL_SCHEME + + + +``` + +For more information, see +[Google Integration Docs](https://www.ory.sh/docs/kratos/social-signin/google). + +### Apple Sign In + +To configure Apple Sign In on IOS, see +[Apple Integration Docs](https://www.ory.sh/docs/kratos/social-signin/apple).\ +To configure Apple Sign In on Android, see [Social sign-in for native and mobile apps ](https://www.ory.sh/docs/kratos/social-signin/native-apps). + +### Run locally + +1. Install dependencies from `pubspec.yaml` + +```console +flutter pub get +``` + +2. open iOS Simulator or Android Emulator +3. Start the app + +```console +flutter run +``` diff --git a/flutter-ory-network/analysis_options.yaml b/flutter-ory-network/analysis_options.yaml new file mode 100644 index 00000000..fd16f921 --- /dev/null +++ b/flutter-ory-network/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/flutter-ory-network/android/.gitignore b/flutter-ory-network/android/.gitignore new file mode 100644 index 00000000..6f568019 --- /dev/null +++ b/flutter-ory-network/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/flutter-ory-network/android/app/build.gradle b/flutter-ory-network/android/app/build.gradle new file mode 100644 index 00000000..cee1d87b --- /dev/null +++ b/flutter-ory-network/android/app/build.gradle @@ -0,0 +1,72 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + namespace "sh.ory.flutter_ory_network" + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "sh.ory.flutter_ory_network" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + minSdkVersion 19 + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/flutter-ory-network/android/app/src/debug/AndroidManifest.xml b/flutter-ory-network/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 00000000..399f6981 --- /dev/null +++ b/flutter-ory-network/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/flutter-ory-network/android/app/src/main/AndroidManifest.xml b/flutter-ory-network/android/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..aff483cc --- /dev/null +++ b/flutter-ory-network/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/flutter-ory-network/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java b/flutter-ory-network/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java new file mode 100644 index 00000000..b17ab81c --- /dev/null +++ b/flutter-ory-network/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java @@ -0,0 +1,28 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +// Generated file. +// +// If you wish to remove Flutter's multidex support, delete this entire file. +// +// Modifications to this file should be done in a copy under a different name +// as this file may be regenerated. + +package io.flutter.app; + +import android.app.Application; +import android.content.Context; +import androidx.annotation.CallSuper; +import androidx.multidex.MultiDex; + +/** + * Extension of {@link android.app.Application}, adding multidex support. + */ +public class FlutterMultiDexApplication extends Application { + @Override + @CallSuper + protected void attachBaseContext(Context base) { + super.attachBaseContext(base); + MultiDex.install(this); + } +} diff --git a/flutter-ory-network/android/app/src/main/kotlin/com/ory/flutter_ory_network/MainActivity.kt b/flutter-ory-network/android/app/src/main/kotlin/com/ory/flutter_ory_network/MainActivity.kt new file mode 100644 index 00000000..bd14b254 --- /dev/null +++ b/flutter-ory-network/android/app/src/main/kotlin/com/ory/flutter_ory_network/MainActivity.kt @@ -0,0 +1,6 @@ +package com.ory.flutter_ory_network + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/flutter-ory-network/android/app/src/main/kotlin/sh/ory/flutter_ory_network/MainActivity.kt b/flutter-ory-network/android/app/src/main/kotlin/sh/ory/flutter_ory_network/MainActivity.kt new file mode 100644 index 00000000..a8a95596 --- /dev/null +++ b/flutter-ory-network/android/app/src/main/kotlin/sh/ory/flutter_ory_network/MainActivity.kt @@ -0,0 +1,6 @@ +package sh.ory.flutter_ory_network + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/flutter-ory-network/android/app/src/main/res/drawable-v21/launch_background.xml b/flutter-ory-network/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 00000000..f74085f3 --- /dev/null +++ b/flutter-ory-network/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/flutter-ory-network/android/app/src/main/res/drawable/launch_background.xml b/flutter-ory-network/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 00000000..304732f8 --- /dev/null +++ b/flutter-ory-network/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/flutter-ory-network/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/flutter-ory-network/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 00000000..db77bb4b Binary files /dev/null and b/flutter-ory-network/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/flutter-ory-network/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/flutter-ory-network/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 00000000..17987b79 Binary files /dev/null and b/flutter-ory-network/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/flutter-ory-network/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/flutter-ory-network/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 00000000..09d43914 Binary files /dev/null and b/flutter-ory-network/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/flutter-ory-network/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/flutter-ory-network/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..d5f1c8d3 Binary files /dev/null and b/flutter-ory-network/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/flutter-ory-network/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/flutter-ory-network/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 00000000..4d6372ee Binary files /dev/null and b/flutter-ory-network/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/flutter-ory-network/android/app/src/main/res/values-night/styles.xml b/flutter-ory-network/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 00000000..06952be7 --- /dev/null +++ b/flutter-ory-network/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/flutter-ory-network/android/app/src/main/res/values/styles.xml b/flutter-ory-network/android/app/src/main/res/values/styles.xml new file mode 100644 index 00000000..cb1ef880 --- /dev/null +++ b/flutter-ory-network/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/flutter-ory-network/android/app/src/profile/AndroidManifest.xml b/flutter-ory-network/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 00000000..399f6981 --- /dev/null +++ b/flutter-ory-network/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/flutter-ory-network/android/build.gradle b/flutter-ory-network/android/build.gradle new file mode 100644 index 00000000..f7eb7f63 --- /dev/null +++ b/flutter-ory-network/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + ext.kotlin_version = '1.7.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.3.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +tasks.register("clean", Delete) { + delete rootProject.buildDir +} diff --git a/flutter-ory-network/android/gradle.properties b/flutter-ory-network/android/gradle.properties new file mode 100644 index 00000000..94adc3a3 --- /dev/null +++ b/flutter-ory-network/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/flutter-ory-network/android/gradle/wrapper/gradle-wrapper.properties b/flutter-ory-network/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..5670ff9c --- /dev/null +++ b/flutter-ory-network/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sat Nov 22 20:54:41 EST 2025 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/flutter-ory-network/android/settings.gradle b/flutter-ory-network/android/settings.gradle new file mode 100644 index 00000000..44e62bcf --- /dev/null +++ b/flutter-ory-network/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/flutter-ory-network/assets/icons/1.5x/eye-off.png b/flutter-ory-network/assets/icons/1.5x/eye-off.png new file mode 100644 index 00000000..f8b03985 Binary files /dev/null and b/flutter-ory-network/assets/icons/1.5x/eye-off.png differ diff --git a/flutter-ory-network/assets/icons/1.5x/eye.png b/flutter-ory-network/assets/icons/1.5x/eye.png new file mode 100644 index 00000000..0afa80dc Binary files /dev/null and b/flutter-ory-network/assets/icons/1.5x/eye.png differ diff --git a/flutter-ory-network/assets/icons/1.5x/logout.png b/flutter-ory-network/assets/icons/1.5x/logout.png new file mode 100644 index 00000000..4bf0ffb4 Binary files /dev/null and b/flutter-ory-network/assets/icons/1.5x/logout.png differ diff --git a/flutter-ory-network/assets/icons/1.5x/settings.png b/flutter-ory-network/assets/icons/1.5x/settings.png new file mode 100644 index 00000000..e1e39a2f Binary files /dev/null and b/flutter-ory-network/assets/icons/1.5x/settings.png differ diff --git a/flutter-ory-network/assets/icons/2.0x/eye-off.png b/flutter-ory-network/assets/icons/2.0x/eye-off.png new file mode 100644 index 00000000..8f96a2b3 Binary files /dev/null and b/flutter-ory-network/assets/icons/2.0x/eye-off.png differ diff --git a/flutter-ory-network/assets/icons/2.0x/eye.png b/flutter-ory-network/assets/icons/2.0x/eye.png new file mode 100644 index 00000000..12c2c83c Binary files /dev/null and b/flutter-ory-network/assets/icons/2.0x/eye.png differ diff --git a/flutter-ory-network/assets/icons/2.0x/settings.png b/flutter-ory-network/assets/icons/2.0x/settings.png new file mode 100644 index 00000000..74d2fd85 Binary files /dev/null and b/flutter-ory-network/assets/icons/2.0x/settings.png differ diff --git a/flutter-ory-network/assets/icons/3.0x/eye-off.png b/flutter-ory-network/assets/icons/3.0x/eye-off.png new file mode 100644 index 00000000..9ef9e008 Binary files /dev/null and b/flutter-ory-network/assets/icons/3.0x/eye-off.png differ diff --git a/flutter-ory-network/assets/icons/3.0x/eye.png b/flutter-ory-network/assets/icons/3.0x/eye.png new file mode 100644 index 00000000..12f9b039 Binary files /dev/null and b/flutter-ory-network/assets/icons/3.0x/eye.png differ diff --git a/flutter-ory-network/assets/icons/3.0x/logout.png b/flutter-ory-network/assets/icons/3.0x/logout.png new file mode 100644 index 00000000..b0513c11 Binary files /dev/null and b/flutter-ory-network/assets/icons/3.0x/logout.png differ diff --git a/flutter-ory-network/assets/icons/3.0x/settings.png b/flutter-ory-network/assets/icons/3.0x/settings.png new file mode 100644 index 00000000..c2e1df39 Binary files /dev/null and b/flutter-ory-network/assets/icons/3.0x/settings.png differ diff --git a/flutter-ory-network/assets/icons/4.0x/eye-off.png b/flutter-ory-network/assets/icons/4.0x/eye-off.png new file mode 100644 index 00000000..8bee73bd Binary files /dev/null and b/flutter-ory-network/assets/icons/4.0x/eye-off.png differ diff --git a/flutter-ory-network/assets/icons/4.0x/eye.png b/flutter-ory-network/assets/icons/4.0x/eye.png new file mode 100644 index 00000000..c5173de0 Binary files /dev/null and b/flutter-ory-network/assets/icons/4.0x/eye.png differ diff --git a/flutter-ory-network/assets/icons/4.0x/logout.png b/flutter-ory-network/assets/icons/4.0x/logout.png new file mode 100644 index 00000000..e4a8bd35 Binary files /dev/null and b/flutter-ory-network/assets/icons/4.0x/logout.png differ diff --git a/flutter-ory-network/assets/icons/4.0x/settings.png b/flutter-ory-network/assets/icons/4.0x/settings.png new file mode 100644 index 00000000..609dbd86 Binary files /dev/null and b/flutter-ory-network/assets/icons/4.0x/settings.png differ diff --git a/flutter-ory-network/assets/icons/eye-off.png b/flutter-ory-network/assets/icons/eye-off.png new file mode 100644 index 00000000..65924f7d Binary files /dev/null and b/flutter-ory-network/assets/icons/eye-off.png differ diff --git a/flutter-ory-network/assets/icons/eye.png b/flutter-ory-network/assets/icons/eye.png new file mode 100644 index 00000000..e8d3e119 Binary files /dev/null and b/flutter-ory-network/assets/icons/eye.png differ diff --git a/flutter-ory-network/assets/icons/logout.png b/flutter-ory-network/assets/icons/logout.png new file mode 100644 index 00000000..e858106a Binary files /dev/null and b/flutter-ory-network/assets/icons/logout.png differ diff --git a/flutter-ory-network/assets/icons/settings.png b/flutter-ory-network/assets/icons/settings.png new file mode 100644 index 00000000..129b40c9 Binary files /dev/null and b/flutter-ory-network/assets/icons/settings.png differ diff --git a/flutter-ory-network/assets/images/1.5x/apple.png b/flutter-ory-network/assets/images/1.5x/apple.png new file mode 100644 index 00000000..665598ff Binary files /dev/null and b/flutter-ory-network/assets/images/1.5x/apple.png differ diff --git a/flutter-ory-network/assets/images/1.5x/google.png b/flutter-ory-network/assets/images/1.5x/google.png new file mode 100644 index 00000000..b159dc85 Binary files /dev/null and b/flutter-ory-network/assets/images/1.5x/google.png differ diff --git a/flutter-ory-network/assets/images/2.0x/apple.png b/flutter-ory-network/assets/images/2.0x/apple.png new file mode 100644 index 00000000..fb4601c6 Binary files /dev/null and b/flutter-ory-network/assets/images/2.0x/apple.png differ diff --git a/flutter-ory-network/assets/images/2.0x/google.png b/flutter-ory-network/assets/images/2.0x/google.png new file mode 100644 index 00000000..837a1948 Binary files /dev/null and b/flutter-ory-network/assets/images/2.0x/google.png differ diff --git a/flutter-ory-network/assets/images/3.0x/apple.png b/flutter-ory-network/assets/images/3.0x/apple.png new file mode 100644 index 00000000..2bdc9172 Binary files /dev/null and b/flutter-ory-network/assets/images/3.0x/apple.png differ diff --git a/flutter-ory-network/assets/images/3.0x/google.png b/flutter-ory-network/assets/images/3.0x/google.png new file mode 100644 index 00000000..71d2c039 Binary files /dev/null and b/flutter-ory-network/assets/images/3.0x/google.png differ diff --git a/flutter-ory-network/assets/images/4.0x/apple.png b/flutter-ory-network/assets/images/4.0x/apple.png new file mode 100644 index 00000000..7fe2a63d Binary files /dev/null and b/flutter-ory-network/assets/images/4.0x/apple.png differ diff --git a/flutter-ory-network/assets/images/4.0x/google.png b/flutter-ory-network/assets/images/4.0x/google.png new file mode 100644 index 00000000..60321327 Binary files /dev/null and b/flutter-ory-network/assets/images/4.0x/google.png differ diff --git a/flutter-ory-network/assets/images/apple.png b/flutter-ory-network/assets/images/apple.png new file mode 100644 index 00000000..2a259447 Binary files /dev/null and b/flutter-ory-network/assets/images/apple.png differ diff --git a/flutter-ory-network/assets/images/flows-auth-buttons-social-apple.png b/flutter-ory-network/assets/images/flows-auth-buttons-social-apple.png new file mode 100644 index 00000000..2a259447 Binary files /dev/null and b/flutter-ory-network/assets/images/flows-auth-buttons-social-apple.png differ diff --git a/flutter-ory-network/assets/images/flows-auth-buttons-social-google.png b/flutter-ory-network/assets/images/flows-auth-buttons-social-google.png new file mode 100644 index 00000000..9a9c46c2 Binary files /dev/null and b/flutter-ory-network/assets/images/flows-auth-buttons-social-google.png differ diff --git a/flutter-ory-network/assets/images/google.png b/flutter-ory-network/assets/images/google.png new file mode 100644 index 00000000..9a9c46c2 Binary files /dev/null and b/flutter-ory-network/assets/images/google.png differ diff --git a/flutter-ory-network/assets/images/ory_logo.png b/flutter-ory-network/assets/images/ory_logo.png new file mode 100644 index 00000000..41915eb9 Binary files /dev/null and b/flutter-ory-network/assets/images/ory_logo.png differ diff --git a/flutter-ory-network/devtools_options.yaml b/flutter-ory-network/devtools_options.yaml new file mode 100644 index 00000000..fa0b357c --- /dev/null +++ b/flutter-ory-network/devtools_options.yaml @@ -0,0 +1,3 @@ +description: This file stores settings for Dart & Flutter DevTools. +documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states +extensions: diff --git a/flutter-ory-network/ios/.gitignore b/flutter-ory-network/ios/.gitignore new file mode 100644 index 00000000..7a7f9873 --- /dev/null +++ b/flutter-ory-network/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/flutter-ory-network/ios/Flutter/AppFrameworkInfo.plist b/flutter-ory-network/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 00000000..1dc6cf76 --- /dev/null +++ b/flutter-ory-network/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 13.0 + + diff --git a/flutter-ory-network/ios/Flutter/Debug.xcconfig b/flutter-ory-network/ios/Flutter/Debug.xcconfig new file mode 100644 index 00000000..ec97fc6f --- /dev/null +++ b/flutter-ory-network/ios/Flutter/Debug.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "Generated.xcconfig" diff --git a/flutter-ory-network/ios/Flutter/Release.xcconfig b/flutter-ory-network/ios/Flutter/Release.xcconfig new file mode 100644 index 00000000..c4855bfe --- /dev/null +++ b/flutter-ory-network/ios/Flutter/Release.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "Generated.xcconfig" diff --git a/flutter-ory-network/ios/Podfile b/flutter-ory-network/ios/Podfile new file mode 100644 index 00000000..e51a31d9 --- /dev/null +++ b/flutter-ory-network/ios/Podfile @@ -0,0 +1,44 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '13.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/flutter-ory-network/ios/Podfile.lock b/flutter-ory-network/ios/Podfile.lock new file mode 100644 index 00000000..2efd3855 --- /dev/null +++ b/flutter-ory-network/ios/Podfile.lock @@ -0,0 +1,99 @@ +PODS: + - AppAuth (2.0.0): + - AppAuth/Core (= 2.0.0) + - AppAuth/ExternalUserAgent (= 2.0.0) + - AppAuth/Core (2.0.0) + - AppAuth/ExternalUserAgent (2.0.0): + - AppAuth/Core + - AppCheckCore (11.2.0): + - GoogleUtilities/Environment (~> 8.0) + - GoogleUtilities/UserDefaults (~> 8.0) + - PromisesObjC (~> 2.4) + - Flutter (1.0.0) + - flutter_secure_storage (6.0.0): + - Flutter + - flutter_web_auth (0.6.0): + - Flutter + - google_sign_in_ios (0.0.1): + - Flutter + - FlutterMacOS + - GoogleSignIn (~> 9.0) + - GTMSessionFetcher (>= 3.4.0) + - GoogleSignIn (9.0.0): + - AppAuth (~> 2.0) + - AppCheckCore (~> 11.0) + - GTMAppAuth (~> 5.0) + - GTMSessionFetcher/Core (~> 3.3) + - GoogleUtilities/Environment (8.1.0): + - GoogleUtilities/Privacy + - GoogleUtilities/Logger (8.1.0): + - GoogleUtilities/Environment + - GoogleUtilities/Privacy + - GoogleUtilities/Privacy (8.1.0) + - GoogleUtilities/UserDefaults (8.1.0): + - GoogleUtilities/Logger + - GoogleUtilities/Privacy + - GTMAppAuth (5.0.0): + - AppAuth/Core (~> 2.0) + - GTMSessionFetcher/Core (< 4.0, >= 3.3) + - GTMSessionFetcher (3.5.0): + - GTMSessionFetcher/Full (= 3.5.0) + - GTMSessionFetcher/Core (3.5.0) + - GTMSessionFetcher/Full (3.5.0): + - GTMSessionFetcher/Core + - objective_c (0.0.1): + - Flutter + - PromisesObjC (2.4.0) + - sign_in_with_apple (0.0.1): + - Flutter + +DEPENDENCIES: + - Flutter (from `Flutter`) + - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) + - flutter_web_auth (from `.symlinks/plugins/flutter_web_auth/ios`) + - google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/darwin`) + - objective_c (from `.symlinks/plugins/objective_c/ios`) + - sign_in_with_apple (from `.symlinks/plugins/sign_in_with_apple/ios`) + +SPEC REPOS: + trunk: + - AppAuth + - AppCheckCore + - GoogleSignIn + - GoogleUtilities + - GTMAppAuth + - GTMSessionFetcher + - PromisesObjC + +EXTERNAL SOURCES: + Flutter: + :path: Flutter + flutter_secure_storage: + :path: ".symlinks/plugins/flutter_secure_storage/ios" + flutter_web_auth: + :path: ".symlinks/plugins/flutter_web_auth/ios" + google_sign_in_ios: + :path: ".symlinks/plugins/google_sign_in_ios/darwin" + objective_c: + :path: ".symlinks/plugins/objective_c/ios" + sign_in_with_apple: + :path: ".symlinks/plugins/sign_in_with_apple/ios" + +SPEC CHECKSUMS: + AppAuth: 1c1a8afa7e12f2ec3a294d9882dfa5ab7d3cb063 + AppCheckCore: cc8fd0a3a230ddd401f326489c99990b013f0c4f + Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 + flutter_secure_storage: 1ed9476fba7e7a782b22888f956cce43e2c62f13 + flutter_web_auth: e5618c2e8a6822d86a0dc49f08d00a7ba25cfafd + google_sign_in_ios: 00dfa94252eb10278b64828c81bcb7158a81a53a + GoogleSignIn: c7f09cfbc85a1abf69187be091997c317cc33b77 + GoogleUtilities: 00c88b9a86066ef77f0da2fab05f65d7768ed8e1 + GTMAppAuth: 217a876b249c3c585a54fd6f73e6b58c4f5c4238 + GTMSessionFetcher: 5aea5ba6bd522a239e236100971f10cb71b96ab6 + objective_c: 89e720c30d716b036faf9c9684022048eee1eee2 + PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 + sign_in_with_apple: c5dcc141574c8c54d5ac99dd2163c0c72ad22418 + +PODFILE CHECKSUM: 4f1c12611da7338d21589c0b2ecd6bd20b109694 + +COCOAPODS: 1.16.2 diff --git a/flutter-ory-network/ios/Runner.xcodeproj/project.pbxproj b/flutter-ory-network/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 00000000..9a29fbd0 --- /dev/null +++ b/flutter-ory-network/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,746 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 806A4268FA350FE41F8569DA /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B1C3FAC3908A19FDC95DF8C /* Pods_RunnerTests.framework */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + 99C4A8A0D8F4812473034146 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2FC830B17BFE3D0034060C69 /* Pods_Runner.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 0CB57777B6627A48BB9FA8C8 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 2FC830B17BFE3D0034060C69 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 311C9A0E2AD94FCA0082AC0F /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; + 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 5049002C15409643EB52610C /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; + 572786F99F7DFEE344A536D0 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 7B1C3FAC3908A19FDC95DF8C /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A7A031BF64D7C0BBC9510C27 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + B9F2C68CEBAD8576F94DBFA2 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + BFB18E6C40720455AECECC2B /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 99C4A8A0D8F4812473034146 /* Pods_Runner.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A11DA63E44DE6327E50E646B /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 806A4268FA350FE41F8569DA /* Pods_RunnerTests.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C8082294A63A400263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C807B294A618700263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + 331C8082294A63A400263BE5 /* RunnerTests */, + A665270B796B85815C608C0F /* Pods */, + F2402B6CEE3498843683A976 /* Frameworks */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + 331C8081294A63A400263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 311C9A0E2AD94FCA0082AC0F /* Runner.entitlements */, + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; + A665270B796B85815C608C0F /* Pods */ = { + isa = PBXGroup; + children = ( + A7A031BF64D7C0BBC9510C27 /* Pods-Runner.debug.xcconfig */, + B9F2C68CEBAD8576F94DBFA2 /* Pods-Runner.release.xcconfig */, + BFB18E6C40720455AECECC2B /* Pods-Runner.profile.xcconfig */, + 0CB57777B6627A48BB9FA8C8 /* Pods-RunnerTests.debug.xcconfig */, + 5049002C15409643EB52610C /* Pods-RunnerTests.release.xcconfig */, + 572786F99F7DFEE344A536D0 /* Pods-RunnerTests.profile.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; + F2402B6CEE3498843683A976 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 2FC830B17BFE3D0034060C69 /* Pods_Runner.framework */, + 7B1C3FAC3908A19FDC95DF8C /* Pods_RunnerTests.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C8080294A63A400263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 3834015CF9820D05956C35E2 /* [CP] Check Pods Manifest.lock */, + 331C807D294A63A400263BE5 /* Sources */, + 331C807F294A63A400263BE5 /* Resources */, + A11DA63E44DE6327E50E646B /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 331C8086294A63A400263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 41429A30DBA960B328EE0121 /* [CP] Check Pods Manifest.lock */, + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + 15FE7AA82ACE92C893182D64 /* [CP] Embed Pods Frameworks */, + 219D11493666AB3DD993FA33 /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C8080294A63A400263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 97C146ED1CF9000F007C117D; + }; + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + 331C8080294A63A400263BE5 /* RunnerTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C807F294A63A400263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 15FE7AA82ACE92C893182D64 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 219D11493666AB3DD993FA33 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 3834015CF9820D05956C35E2 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 41429A30DBA960B328EE0121 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C807D294A63A400263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C8086294A63A400263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 44TJKWD29H; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "sh.ory.flutter-ory-network"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 331C8088294A63A400263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 0CB57777B6627A48BB9FA8C8 /* Pods-RunnerTests.debug.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.ory_network_flutter.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Debug; + }; + 331C8089294A63A400263BE5 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 5049002C15409643EB52610C /* Pods-RunnerTests.release.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.ory_network_flutter.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Release; + }; + 331C808A294A63A400263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 572786F99F7DFEE344A536D0 /* Pods-RunnerTests.profile.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.ory_network_flutter.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 44TJKWD29H; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "sh.ory.flutter-ory-network"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 44TJKWD29H; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "sh.ory.flutter-ory-network"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C8088294A63A400263BE5 /* Debug */, + 331C8089294A63A400263BE5 /* Release */, + 331C808A294A63A400263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/flutter-ory-network/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/flutter-ory-network/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/flutter-ory-network/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/flutter-ory-network/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/flutter-ory-network/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/flutter-ory-network/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/flutter-ory-network/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/flutter-ory-network/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..f9b0d7c5 --- /dev/null +++ b/flutter-ory-network/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/flutter-ory-network/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/flutter-ory-network/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 00000000..e3773d42 --- /dev/null +++ b/flutter-ory-network/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/flutter-ory-network/ios/Runner.xcworkspace/contents.xcworkspacedata b/flutter-ory-network/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..21a3cc14 --- /dev/null +++ b/flutter-ory-network/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/flutter-ory-network/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/flutter-ory-network/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/flutter-ory-network/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/flutter-ory-network/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/flutter-ory-network/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..f9b0d7c5 --- /dev/null +++ b/flutter-ory-network/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/flutter-ory-network/ios/Runner/AppDelegate.swift b/flutter-ory-network/ios/Runner/AppDelegate.swift new file mode 100644 index 00000000..b6363034 --- /dev/null +++ b/flutter-ory-network/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@main +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..e882ab98 --- /dev/null +++ b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images": [ + { + "size": "20x20", + "idiom": "iphone", + "filename": "Icon-App-20x20@2x.png", + "scale": "2x" + }, + { + "size": "20x20", + "idiom": "iphone", + "filename": "Icon-App-20x20@3x.png", + "scale": "3x" + }, + { + "size": "29x29", + "idiom": "iphone", + "filename": "Icon-App-29x29@1x.png", + "scale": "1x" + }, + { + "size": "29x29", + "idiom": "iphone", + "filename": "Icon-App-29x29@2x.png", + "scale": "2x" + }, + { + "size": "29x29", + "idiom": "iphone", + "filename": "Icon-App-29x29@3x.png", + "scale": "3x" + }, + { + "size": "40x40", + "idiom": "iphone", + "filename": "Icon-App-40x40@2x.png", + "scale": "2x" + }, + { + "size": "40x40", + "idiom": "iphone", + "filename": "Icon-App-40x40@3x.png", + "scale": "3x" + }, + { + "size": "60x60", + "idiom": "iphone", + "filename": "Icon-App-60x60@2x.png", + "scale": "2x" + }, + { + "size": "60x60", + "idiom": "iphone", + "filename": "Icon-App-60x60@3x.png", + "scale": "3x" + }, + { + "size": "20x20", + "idiom": "ipad", + "filename": "Icon-App-20x20@1x.png", + "scale": "1x" + }, + { + "size": "20x20", + "idiom": "ipad", + "filename": "Icon-App-20x20@2x.png", + "scale": "2x" + }, + { + "size": "29x29", + "idiom": "ipad", + "filename": "Icon-App-29x29@1x.png", + "scale": "1x" + }, + { + "size": "29x29", + "idiom": "ipad", + "filename": "Icon-App-29x29@2x.png", + "scale": "2x" + }, + { + "size": "40x40", + "idiom": "ipad", + "filename": "Icon-App-40x40@1x.png", + "scale": "1x" + }, + { + "size": "40x40", + "idiom": "ipad", + "filename": "Icon-App-40x40@2x.png", + "scale": "2x" + }, + { + "size": "76x76", + "idiom": "ipad", + "filename": "Icon-App-76x76@1x.png", + "scale": "1x" + }, + { + "size": "76x76", + "idiom": "ipad", + "filename": "Icon-App-76x76@2x.png", + "scale": "2x" + }, + { + "size": "83.5x83.5", + "idiom": "ipad", + "filename": "Icon-App-83.5x83.5@2x.png", + "scale": "2x" + }, + { + "size": "1024x1024", + "idiom": "ios-marketing", + "filename": "Icon-App-1024x1024@1x.png", + "scale": "1x" + } + ], + "info": { + "version": 1, + "author": "xcode" + } +} diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 00000000..dc9ada47 Binary files /dev/null and b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 00000000..7353c41e Binary files /dev/null and b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 00000000..797d452e Binary files /dev/null and b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 00000000..6ed2d933 Binary files /dev/null and b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 00000000..4cd7b009 Binary files /dev/null and b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 00000000..fe730945 Binary files /dev/null and b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 00000000..321773cd Binary files /dev/null and b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 00000000..797d452e Binary files /dev/null and b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 00000000..502f463a Binary files /dev/null and b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 00000000..0ec30343 Binary files /dev/null and b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 00000000..0ec30343 Binary files /dev/null and b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 00000000..e9f5fea2 Binary files /dev/null and b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 00000000..84ac32ae Binary files /dev/null and b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 00000000..8953cba0 Binary files /dev/null and b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 00000000..0467bf12 Binary files /dev/null and b/flutter-ory-network/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/flutter-ory-network/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 00000000..781d7cdc --- /dev/null +++ b/flutter-ory-network/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images": [ + { + "idiom": "universal", + "filename": "LaunchImage.png", + "scale": "1x" + }, + { + "idiom": "universal", + "filename": "LaunchImage@2x.png", + "scale": "2x" + }, + { + "idiom": "universal", + "filename": "LaunchImage@3x.png", + "scale": "3x" + } + ], + "info": { + "version": 1, + "author": "xcode" + } +} diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/flutter-ory-network/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 00000000..9da19eac Binary files /dev/null and b/flutter-ory-network/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/flutter-ory-network/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 00000000..9da19eac Binary files /dev/null and b/flutter-ory-network/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/flutter-ory-network/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 00000000..9da19eac Binary files /dev/null and b/flutter-ory-network/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/flutter-ory-network/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/flutter-ory-network/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 00000000..09c4940e --- /dev/null +++ b/flutter-ory-network/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,8 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing +the image files in this directory. + +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. diff --git a/flutter-ory-network/ios/Runner/Base.lproj/LaunchScreen.storyboard b/flutter-ory-network/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..f2e259c7 --- /dev/null +++ b/flutter-ory-network/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/flutter-ory-network/ios/Runner/Base.lproj/Main.storyboard b/flutter-ory-network/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 00000000..f3c28516 --- /dev/null +++ b/flutter-ory-network/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/flutter-ory-network/ios/Runner/Info.plist b/flutter-ory-network/ios/Runner/Info.plist new file mode 100644 index 00000000..f339f58a --- /dev/null +++ b/flutter-ory-network/ios/Runner/Info.plist @@ -0,0 +1,63 @@ + + + + + CADisableMinimumFrameDurationOnPhone + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Ory Network Flutter + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + flutter_ory_network + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLSchemes + + + IOS_URL_SCHEME + + + + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + + diff --git a/flutter-ory-network/ios/Runner/Runner-Bridging-Header.h b/flutter-ory-network/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 00000000..308a2a56 --- /dev/null +++ b/flutter-ory-network/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/flutter-ory-network/ios/Runner/Runner.entitlements b/flutter-ory-network/ios/Runner/Runner.entitlements new file mode 100644 index 00000000..a812db50 --- /dev/null +++ b/flutter-ory-network/ios/Runner/Runner.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.developer.applesignin + + Default + + + diff --git a/flutter-ory-network/ios/RunnerTests/RunnerTests.swift b/flutter-ory-network/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 00000000..86a7c3b1 --- /dev/null +++ b/flutter-ory-network/ios/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Flutter +import UIKit +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/flutter-ory-network/lib/blocs/auth/auth_bloc.dart b/flutter-ory-network/lib/blocs/auth/auth_bloc.dart new file mode 100644 index 00000000..b843fda2 --- /dev/null +++ b/flutter-ory-network/lib/blocs/auth/auth_bloc.dart @@ -0,0 +1,84 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:ory_client/ory_client.dart'; + +import '../../repositories/auth.dart'; +import '../../services/exceptions.dart'; + +part 'auth_event.dart'; +part 'auth_state.dart'; +part 'auth_bloc.freezed.dart'; + +class AuthBloc extends Bloc { + final AuthRepository repository; + AuthBloc({required this.repository}) + : super(const AuthState.uninitialized()) { + on(_onGetCurrentSessionInformation); + on(_onRequireLocationChange); + on(_onAddSession); + on(_onChangeAuthStatus); + on(_onLogOut); + } + + _onRequireLocationChange( + RequireLocationChange event, Emitter emit) { + emit(AuthState.locationChangeRequired(url: event.url)); + } + + _onAddSession(AddSession event, Emitter emit) { + emit(AuthState.authenticated( + session: event.session, conditions: event.conditions)); + } + + _onChangeAuthStatus(ChangeAuthStatus event, Emitter emit) { + switch (event.status) { + case AuthStatus.unauthenticated: + emit(const AuthState.unauthenticated()); + case AuthStatus.aal2Requested: + emit(AuthState.aal2Requested(conditions: event.conditions)); + default: + emit(state); + } + emit(state.copyWith(status: event.status, isLoading: false)); + } + + Future _onGetCurrentSessionInformation( + GetCurrentSessionInformation event, Emitter emit) async { + try { + emit(state.copyWith(isLoading: true, errorMessage: null)); + + final session = await repository.getCurrentSessionInformation(); + + emit(AuthState.authenticated( + session: session, conditions: event.conditions)); + } on UnauthorizedException catch (_) { + emit(const AuthState.unauthenticated()); + } on TwoFactorAuthRequiredException catch (_) { + emit(AuthState.aal2Requested(conditions: event.conditions)); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, errorMessage: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); + } + } + + Future _onLogOut(LogOut event, Emitter emit) async { + try { + emit(state.copyWith(isLoading: true, errorMessage: null)); + + await repository.logout(); + + emit(const AuthState.unauthenticated()); + } on UnauthorizedException catch (_) { + emit(const AuthState.unauthenticated()); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, errorMessage: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); + } + } +} diff --git a/flutter-ory-network/lib/blocs/auth/auth_bloc.freezed.dart b/flutter-ory-network/lib/blocs/auth/auth_bloc.freezed.dart new file mode 100644 index 00000000..2e8f82b1 --- /dev/null +++ b/flutter-ory-network/lib/blocs/auth/auth_bloc.freezed.dart @@ -0,0 +1,1435 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'auth_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +/// @nodoc +mixin _$AuthState { + AuthStatus get status => throw _privateConstructorUsedError; + List get conditions => throw _privateConstructorUsedError; + bool get isLoading => throw _privateConstructorUsedError; + String? get errorMessage => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult when({ + required TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage) + uninitialized, + required TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage) + unauthenticated, + required TResult Function(AuthStatus status, Session session, + List conditions, bool isLoading, String? errorMessage) + authenticated, + required TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage) + aal2Requested, + required TResult Function(AuthStatus status, List conditions, + String url, bool isLoading, String? errorMessage) + locationChangeRequired, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + uninitialized, + TResult? Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + unauthenticated, + TResult? Function(AuthStatus status, Session session, + List conditions, bool isLoading, String? errorMessage)? + authenticated, + TResult? Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + aal2Requested, + TResult? Function(AuthStatus status, List conditions, String url, + bool isLoading, String? errorMessage)? + locationChangeRequired, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + uninitialized, + TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + unauthenticated, + TResult Function(AuthStatus status, Session session, + List conditions, bool isLoading, String? errorMessage)? + authenticated, + TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + aal2Requested, + TResult Function(AuthStatus status, List conditions, String url, + bool isLoading, String? errorMessage)? + locationChangeRequired, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(AuthUninitialized value) uninitialized, + required TResult Function(AuthUnauthenticated value) unauthenticated, + required TResult Function(AuthAuthenticated value) authenticated, + required TResult Function(Aal2Requested value) aal2Requested, + required TResult Function(LocationChangeRequired value) + locationChangeRequired, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthUninitialized value)? uninitialized, + TResult? Function(AuthUnauthenticated value)? unauthenticated, + TResult? Function(AuthAuthenticated value)? authenticated, + TResult? Function(Aal2Requested value)? aal2Requested, + TResult? Function(LocationChangeRequired value)? locationChangeRequired, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthUninitialized value)? uninitialized, + TResult Function(AuthUnauthenticated value)? unauthenticated, + TResult Function(AuthAuthenticated value)? authenticated, + TResult Function(Aal2Requested value)? aal2Requested, + TResult Function(LocationChangeRequired value)? locationChangeRequired, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $AuthStateCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $AuthStateCopyWith<$Res> { + factory $AuthStateCopyWith(AuthState value, $Res Function(AuthState) then) = + _$AuthStateCopyWithImpl<$Res, AuthState>; + @useResult + $Res call( + {AuthStatus status, + List conditions, + bool isLoading, + String? errorMessage}); +} + +/// @nodoc +class _$AuthStateCopyWithImpl<$Res, $Val extends AuthState> + implements $AuthStateCopyWith<$Res> { + _$AuthStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? status = null, + Object? conditions = null, + Object? isLoading = null, + Object? errorMessage = freezed, + }) { + return _then(_value.copyWith( + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as AuthStatus, + conditions: null == conditions + ? _value.conditions + : conditions // ignore: cast_nullable_to_non_nullable + as List, + isLoading: null == isLoading + ? _value.isLoading + : isLoading // ignore: cast_nullable_to_non_nullable + as bool, + errorMessage: freezed == errorMessage + ? _value.errorMessage + : errorMessage // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$AuthUninitializedImplCopyWith<$Res> + implements $AuthStateCopyWith<$Res> { + factory _$$AuthUninitializedImplCopyWith(_$AuthUninitializedImpl value, + $Res Function(_$AuthUninitializedImpl) then) = + __$$AuthUninitializedImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {AuthStatus status, + List conditions, + bool isLoading, + String? errorMessage}); +} + +/// @nodoc +class __$$AuthUninitializedImplCopyWithImpl<$Res> + extends _$AuthStateCopyWithImpl<$Res, _$AuthUninitializedImpl> + implements _$$AuthUninitializedImplCopyWith<$Res> { + __$$AuthUninitializedImplCopyWithImpl(_$AuthUninitializedImpl _value, + $Res Function(_$AuthUninitializedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? status = null, + Object? conditions = null, + Object? isLoading = null, + Object? errorMessage = freezed, + }) { + return _then(_$AuthUninitializedImpl( + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as AuthStatus, + conditions: null == conditions + ? _value._conditions + : conditions // ignore: cast_nullable_to_non_nullable + as List, + isLoading: null == isLoading + ? _value.isLoading + : isLoading // ignore: cast_nullable_to_non_nullable + as bool, + errorMessage: freezed == errorMessage + ? _value.errorMessage + : errorMessage // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$AuthUninitializedImpl implements AuthUninitialized { + const _$AuthUninitializedImpl( + {this.status = AuthStatus.uninitialized, + final List conditions = const [], + this.isLoading = false, + this.errorMessage}) + : _conditions = conditions; + + @override + @JsonKey() + final AuthStatus status; + final List _conditions; + @override + @JsonKey() + List get conditions { + if (_conditions is EqualUnmodifiableListView) return _conditions; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_conditions); + } + + @override + @JsonKey() + final bool isLoading; + @override + final String? errorMessage; + + @override + String toString() { + return 'AuthState.uninitialized(status: $status, conditions: $conditions, isLoading: $isLoading, errorMessage: $errorMessage)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AuthUninitializedImpl && + (identical(other.status, status) || other.status == status) && + const DeepCollectionEquality() + .equals(other._conditions, _conditions) && + (identical(other.isLoading, isLoading) || + other.isLoading == isLoading) && + (identical(other.errorMessage, errorMessage) || + other.errorMessage == errorMessage)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + status, + const DeepCollectionEquality().hash(_conditions), + isLoading, + errorMessage); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$AuthUninitializedImplCopyWith<_$AuthUninitializedImpl> get copyWith => + __$$AuthUninitializedImplCopyWithImpl<_$AuthUninitializedImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage) + uninitialized, + required TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage) + unauthenticated, + required TResult Function(AuthStatus status, Session session, + List conditions, bool isLoading, String? errorMessage) + authenticated, + required TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage) + aal2Requested, + required TResult Function(AuthStatus status, List conditions, + String url, bool isLoading, String? errorMessage) + locationChangeRequired, + }) { + return uninitialized(status, conditions, isLoading, errorMessage); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + uninitialized, + TResult? Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + unauthenticated, + TResult? Function(AuthStatus status, Session session, + List conditions, bool isLoading, String? errorMessage)? + authenticated, + TResult? Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + aal2Requested, + TResult? Function(AuthStatus status, List conditions, String url, + bool isLoading, String? errorMessage)? + locationChangeRequired, + }) { + return uninitialized?.call(status, conditions, isLoading, errorMessage); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + uninitialized, + TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + unauthenticated, + TResult Function(AuthStatus status, Session session, + List conditions, bool isLoading, String? errorMessage)? + authenticated, + TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + aal2Requested, + TResult Function(AuthStatus status, List conditions, String url, + bool isLoading, String? errorMessage)? + locationChangeRequired, + required TResult orElse(), + }) { + if (uninitialized != null) { + return uninitialized(status, conditions, isLoading, errorMessage); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AuthUninitialized value) uninitialized, + required TResult Function(AuthUnauthenticated value) unauthenticated, + required TResult Function(AuthAuthenticated value) authenticated, + required TResult Function(Aal2Requested value) aal2Requested, + required TResult Function(LocationChangeRequired value) + locationChangeRequired, + }) { + return uninitialized(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthUninitialized value)? uninitialized, + TResult? Function(AuthUnauthenticated value)? unauthenticated, + TResult? Function(AuthAuthenticated value)? authenticated, + TResult? Function(Aal2Requested value)? aal2Requested, + TResult? Function(LocationChangeRequired value)? locationChangeRequired, + }) { + return uninitialized?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthUninitialized value)? uninitialized, + TResult Function(AuthUnauthenticated value)? unauthenticated, + TResult Function(AuthAuthenticated value)? authenticated, + TResult Function(Aal2Requested value)? aal2Requested, + TResult Function(LocationChangeRequired value)? locationChangeRequired, + required TResult orElse(), + }) { + if (uninitialized != null) { + return uninitialized(this); + } + return orElse(); + } +} + +abstract class AuthUninitialized implements AuthState { + const factory AuthUninitialized( + {final AuthStatus status, + final List conditions, + final bool isLoading, + final String? errorMessage}) = _$AuthUninitializedImpl; + + @override + AuthStatus get status; + @override + List get conditions; + @override + bool get isLoading; + @override + String? get errorMessage; + @override + @JsonKey(ignore: true) + _$$AuthUninitializedImplCopyWith<_$AuthUninitializedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$AuthUnauthenticatedImplCopyWith<$Res> + implements $AuthStateCopyWith<$Res> { + factory _$$AuthUnauthenticatedImplCopyWith(_$AuthUnauthenticatedImpl value, + $Res Function(_$AuthUnauthenticatedImpl) then) = + __$$AuthUnauthenticatedImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {AuthStatus status, + List conditions, + bool isLoading, + String? errorMessage}); +} + +/// @nodoc +class __$$AuthUnauthenticatedImplCopyWithImpl<$Res> + extends _$AuthStateCopyWithImpl<$Res, _$AuthUnauthenticatedImpl> + implements _$$AuthUnauthenticatedImplCopyWith<$Res> { + __$$AuthUnauthenticatedImplCopyWithImpl(_$AuthUnauthenticatedImpl _value, + $Res Function(_$AuthUnauthenticatedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? status = null, + Object? conditions = null, + Object? isLoading = null, + Object? errorMessage = freezed, + }) { + return _then(_$AuthUnauthenticatedImpl( + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as AuthStatus, + conditions: null == conditions + ? _value._conditions + : conditions // ignore: cast_nullable_to_non_nullable + as List, + isLoading: null == isLoading + ? _value.isLoading + : isLoading // ignore: cast_nullable_to_non_nullable + as bool, + errorMessage: freezed == errorMessage + ? _value.errorMessage + : errorMessage // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$AuthUnauthenticatedImpl implements AuthUnauthenticated { + const _$AuthUnauthenticatedImpl( + {this.status = AuthStatus.unauthenticated, + final List conditions = const [], + this.isLoading = false, + this.errorMessage}) + : _conditions = conditions; + + @override + @JsonKey() + final AuthStatus status; + final List _conditions; + @override + @JsonKey() + List get conditions { + if (_conditions is EqualUnmodifiableListView) return _conditions; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_conditions); + } + + @override + @JsonKey() + final bool isLoading; + @override + final String? errorMessage; + + @override + String toString() { + return 'AuthState.unauthenticated(status: $status, conditions: $conditions, isLoading: $isLoading, errorMessage: $errorMessage)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AuthUnauthenticatedImpl && + (identical(other.status, status) || other.status == status) && + const DeepCollectionEquality() + .equals(other._conditions, _conditions) && + (identical(other.isLoading, isLoading) || + other.isLoading == isLoading) && + (identical(other.errorMessage, errorMessage) || + other.errorMessage == errorMessage)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + status, + const DeepCollectionEquality().hash(_conditions), + isLoading, + errorMessage); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$AuthUnauthenticatedImplCopyWith<_$AuthUnauthenticatedImpl> get copyWith => + __$$AuthUnauthenticatedImplCopyWithImpl<_$AuthUnauthenticatedImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage) + uninitialized, + required TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage) + unauthenticated, + required TResult Function(AuthStatus status, Session session, + List conditions, bool isLoading, String? errorMessage) + authenticated, + required TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage) + aal2Requested, + required TResult Function(AuthStatus status, List conditions, + String url, bool isLoading, String? errorMessage) + locationChangeRequired, + }) { + return unauthenticated(status, conditions, isLoading, errorMessage); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + uninitialized, + TResult? Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + unauthenticated, + TResult? Function(AuthStatus status, Session session, + List conditions, bool isLoading, String? errorMessage)? + authenticated, + TResult? Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + aal2Requested, + TResult? Function(AuthStatus status, List conditions, String url, + bool isLoading, String? errorMessage)? + locationChangeRequired, + }) { + return unauthenticated?.call(status, conditions, isLoading, errorMessage); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + uninitialized, + TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + unauthenticated, + TResult Function(AuthStatus status, Session session, + List conditions, bool isLoading, String? errorMessage)? + authenticated, + TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + aal2Requested, + TResult Function(AuthStatus status, List conditions, String url, + bool isLoading, String? errorMessage)? + locationChangeRequired, + required TResult orElse(), + }) { + if (unauthenticated != null) { + return unauthenticated(status, conditions, isLoading, errorMessage); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AuthUninitialized value) uninitialized, + required TResult Function(AuthUnauthenticated value) unauthenticated, + required TResult Function(AuthAuthenticated value) authenticated, + required TResult Function(Aal2Requested value) aal2Requested, + required TResult Function(LocationChangeRequired value) + locationChangeRequired, + }) { + return unauthenticated(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthUninitialized value)? uninitialized, + TResult? Function(AuthUnauthenticated value)? unauthenticated, + TResult? Function(AuthAuthenticated value)? authenticated, + TResult? Function(Aal2Requested value)? aal2Requested, + TResult? Function(LocationChangeRequired value)? locationChangeRequired, + }) { + return unauthenticated?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthUninitialized value)? uninitialized, + TResult Function(AuthUnauthenticated value)? unauthenticated, + TResult Function(AuthAuthenticated value)? authenticated, + TResult Function(Aal2Requested value)? aal2Requested, + TResult Function(LocationChangeRequired value)? locationChangeRequired, + required TResult orElse(), + }) { + if (unauthenticated != null) { + return unauthenticated(this); + } + return orElse(); + } +} + +abstract class AuthUnauthenticated implements AuthState { + const factory AuthUnauthenticated( + {final AuthStatus status, + final List conditions, + final bool isLoading, + final String? errorMessage}) = _$AuthUnauthenticatedImpl; + + @override + AuthStatus get status; + @override + List get conditions; + @override + bool get isLoading; + @override + String? get errorMessage; + @override + @JsonKey(ignore: true) + _$$AuthUnauthenticatedImplCopyWith<_$AuthUnauthenticatedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$AuthAuthenticatedImplCopyWith<$Res> + implements $AuthStateCopyWith<$Res> { + factory _$$AuthAuthenticatedImplCopyWith(_$AuthAuthenticatedImpl value, + $Res Function(_$AuthAuthenticatedImpl) then) = + __$$AuthAuthenticatedImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {AuthStatus status, + Session session, + List conditions, + bool isLoading, + String? errorMessage}); +} + +/// @nodoc +class __$$AuthAuthenticatedImplCopyWithImpl<$Res> + extends _$AuthStateCopyWithImpl<$Res, _$AuthAuthenticatedImpl> + implements _$$AuthAuthenticatedImplCopyWith<$Res> { + __$$AuthAuthenticatedImplCopyWithImpl(_$AuthAuthenticatedImpl _value, + $Res Function(_$AuthAuthenticatedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? status = null, + Object? session = null, + Object? conditions = null, + Object? isLoading = null, + Object? errorMessage = freezed, + }) { + return _then(_$AuthAuthenticatedImpl( + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as AuthStatus, + session: null == session + ? _value.session + : session // ignore: cast_nullable_to_non_nullable + as Session, + conditions: null == conditions + ? _value._conditions + : conditions // ignore: cast_nullable_to_non_nullable + as List, + isLoading: null == isLoading + ? _value.isLoading + : isLoading // ignore: cast_nullable_to_non_nullable + as bool, + errorMessage: freezed == errorMessage + ? _value.errorMessage + : errorMessage // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$AuthAuthenticatedImpl implements AuthAuthenticated { + const _$AuthAuthenticatedImpl( + {this.status = AuthStatus.authenticated, + required this.session, + final List conditions = const [], + this.isLoading = false, + this.errorMessage}) + : _conditions = conditions; + + @override + @JsonKey() + final AuthStatus status; + @override + final Session session; + final List _conditions; + @override + @JsonKey() + List get conditions { + if (_conditions is EqualUnmodifiableListView) return _conditions; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_conditions); + } + + @override + @JsonKey() + final bool isLoading; + @override + final String? errorMessage; + + @override + String toString() { + return 'AuthState.authenticated(status: $status, session: $session, conditions: $conditions, isLoading: $isLoading, errorMessage: $errorMessage)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AuthAuthenticatedImpl && + (identical(other.status, status) || other.status == status) && + (identical(other.session, session) || other.session == session) && + const DeepCollectionEquality() + .equals(other._conditions, _conditions) && + (identical(other.isLoading, isLoading) || + other.isLoading == isLoading) && + (identical(other.errorMessage, errorMessage) || + other.errorMessage == errorMessage)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + status, + session, + const DeepCollectionEquality().hash(_conditions), + isLoading, + errorMessage); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$AuthAuthenticatedImplCopyWith<_$AuthAuthenticatedImpl> get copyWith => + __$$AuthAuthenticatedImplCopyWithImpl<_$AuthAuthenticatedImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage) + uninitialized, + required TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage) + unauthenticated, + required TResult Function(AuthStatus status, Session session, + List conditions, bool isLoading, String? errorMessage) + authenticated, + required TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage) + aal2Requested, + required TResult Function(AuthStatus status, List conditions, + String url, bool isLoading, String? errorMessage) + locationChangeRequired, + }) { + return authenticated(status, session, conditions, isLoading, errorMessage); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + uninitialized, + TResult? Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + unauthenticated, + TResult? Function(AuthStatus status, Session session, + List conditions, bool isLoading, String? errorMessage)? + authenticated, + TResult? Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + aal2Requested, + TResult? Function(AuthStatus status, List conditions, String url, + bool isLoading, String? errorMessage)? + locationChangeRequired, + }) { + return authenticated?.call( + status, session, conditions, isLoading, errorMessage); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + uninitialized, + TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + unauthenticated, + TResult Function(AuthStatus status, Session session, + List conditions, bool isLoading, String? errorMessage)? + authenticated, + TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + aal2Requested, + TResult Function(AuthStatus status, List conditions, String url, + bool isLoading, String? errorMessage)? + locationChangeRequired, + required TResult orElse(), + }) { + if (authenticated != null) { + return authenticated( + status, session, conditions, isLoading, errorMessage); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AuthUninitialized value) uninitialized, + required TResult Function(AuthUnauthenticated value) unauthenticated, + required TResult Function(AuthAuthenticated value) authenticated, + required TResult Function(Aal2Requested value) aal2Requested, + required TResult Function(LocationChangeRequired value) + locationChangeRequired, + }) { + return authenticated(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthUninitialized value)? uninitialized, + TResult? Function(AuthUnauthenticated value)? unauthenticated, + TResult? Function(AuthAuthenticated value)? authenticated, + TResult? Function(Aal2Requested value)? aal2Requested, + TResult? Function(LocationChangeRequired value)? locationChangeRequired, + }) { + return authenticated?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthUninitialized value)? uninitialized, + TResult Function(AuthUnauthenticated value)? unauthenticated, + TResult Function(AuthAuthenticated value)? authenticated, + TResult Function(Aal2Requested value)? aal2Requested, + TResult Function(LocationChangeRequired value)? locationChangeRequired, + required TResult orElse(), + }) { + if (authenticated != null) { + return authenticated(this); + } + return orElse(); + } +} + +abstract class AuthAuthenticated implements AuthState { + const factory AuthAuthenticated( + {final AuthStatus status, + required final Session session, + final List conditions, + final bool isLoading, + final String? errorMessage}) = _$AuthAuthenticatedImpl; + + @override + AuthStatus get status; + Session get session; + @override + List get conditions; + @override + bool get isLoading; + @override + String? get errorMessage; + @override + @JsonKey(ignore: true) + _$$AuthAuthenticatedImplCopyWith<_$AuthAuthenticatedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$Aal2RequestedImplCopyWith<$Res> + implements $AuthStateCopyWith<$Res> { + factory _$$Aal2RequestedImplCopyWith( + _$Aal2RequestedImpl value, $Res Function(_$Aal2RequestedImpl) then) = + __$$Aal2RequestedImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {AuthStatus status, + List conditions, + bool isLoading, + String? errorMessage}); +} + +/// @nodoc +class __$$Aal2RequestedImplCopyWithImpl<$Res> + extends _$AuthStateCopyWithImpl<$Res, _$Aal2RequestedImpl> + implements _$$Aal2RequestedImplCopyWith<$Res> { + __$$Aal2RequestedImplCopyWithImpl( + _$Aal2RequestedImpl _value, $Res Function(_$Aal2RequestedImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? status = null, + Object? conditions = null, + Object? isLoading = null, + Object? errorMessage = freezed, + }) { + return _then(_$Aal2RequestedImpl( + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as AuthStatus, + conditions: null == conditions + ? _value._conditions + : conditions // ignore: cast_nullable_to_non_nullable + as List, + isLoading: null == isLoading + ? _value.isLoading + : isLoading // ignore: cast_nullable_to_non_nullable + as bool, + errorMessage: freezed == errorMessage + ? _value.errorMessage + : errorMessage // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$Aal2RequestedImpl implements Aal2Requested { + const _$Aal2RequestedImpl( + {this.status = AuthStatus.aal2Requested, + final List conditions = const [], + this.isLoading = false, + this.errorMessage}) + : _conditions = conditions; + + @override + @JsonKey() + final AuthStatus status; + final List _conditions; + @override + @JsonKey() + List get conditions { + if (_conditions is EqualUnmodifiableListView) return _conditions; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_conditions); + } + + @override + @JsonKey() + final bool isLoading; + @override + final String? errorMessage; + + @override + String toString() { + return 'AuthState.aal2Requested(status: $status, conditions: $conditions, isLoading: $isLoading, errorMessage: $errorMessage)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$Aal2RequestedImpl && + (identical(other.status, status) || other.status == status) && + const DeepCollectionEquality() + .equals(other._conditions, _conditions) && + (identical(other.isLoading, isLoading) || + other.isLoading == isLoading) && + (identical(other.errorMessage, errorMessage) || + other.errorMessage == errorMessage)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + status, + const DeepCollectionEquality().hash(_conditions), + isLoading, + errorMessage); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$Aal2RequestedImplCopyWith<_$Aal2RequestedImpl> get copyWith => + __$$Aal2RequestedImplCopyWithImpl<_$Aal2RequestedImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage) + uninitialized, + required TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage) + unauthenticated, + required TResult Function(AuthStatus status, Session session, + List conditions, bool isLoading, String? errorMessage) + authenticated, + required TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage) + aal2Requested, + required TResult Function(AuthStatus status, List conditions, + String url, bool isLoading, String? errorMessage) + locationChangeRequired, + }) { + return aal2Requested(status, conditions, isLoading, errorMessage); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + uninitialized, + TResult? Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + unauthenticated, + TResult? Function(AuthStatus status, Session session, + List conditions, bool isLoading, String? errorMessage)? + authenticated, + TResult? Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + aal2Requested, + TResult? Function(AuthStatus status, List conditions, String url, + bool isLoading, String? errorMessage)? + locationChangeRequired, + }) { + return aal2Requested?.call(status, conditions, isLoading, errorMessage); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + uninitialized, + TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + unauthenticated, + TResult Function(AuthStatus status, Session session, + List conditions, bool isLoading, String? errorMessage)? + authenticated, + TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + aal2Requested, + TResult Function(AuthStatus status, List conditions, String url, + bool isLoading, String? errorMessage)? + locationChangeRequired, + required TResult orElse(), + }) { + if (aal2Requested != null) { + return aal2Requested(status, conditions, isLoading, errorMessage); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AuthUninitialized value) uninitialized, + required TResult Function(AuthUnauthenticated value) unauthenticated, + required TResult Function(AuthAuthenticated value) authenticated, + required TResult Function(Aal2Requested value) aal2Requested, + required TResult Function(LocationChangeRequired value) + locationChangeRequired, + }) { + return aal2Requested(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthUninitialized value)? uninitialized, + TResult? Function(AuthUnauthenticated value)? unauthenticated, + TResult? Function(AuthAuthenticated value)? authenticated, + TResult? Function(Aal2Requested value)? aal2Requested, + TResult? Function(LocationChangeRequired value)? locationChangeRequired, + }) { + return aal2Requested?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthUninitialized value)? uninitialized, + TResult Function(AuthUnauthenticated value)? unauthenticated, + TResult Function(AuthAuthenticated value)? authenticated, + TResult Function(Aal2Requested value)? aal2Requested, + TResult Function(LocationChangeRequired value)? locationChangeRequired, + required TResult orElse(), + }) { + if (aal2Requested != null) { + return aal2Requested(this); + } + return orElse(); + } +} + +abstract class Aal2Requested implements AuthState { + const factory Aal2Requested( + {final AuthStatus status, + final List conditions, + final bool isLoading, + final String? errorMessage}) = _$Aal2RequestedImpl; + + @override + AuthStatus get status; + @override + List get conditions; + @override + bool get isLoading; + @override + String? get errorMessage; + @override + @JsonKey(ignore: true) + _$$Aal2RequestedImplCopyWith<_$Aal2RequestedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$LocationChangeRequiredImplCopyWith<$Res> + implements $AuthStateCopyWith<$Res> { + factory _$$LocationChangeRequiredImplCopyWith( + _$LocationChangeRequiredImpl value, + $Res Function(_$LocationChangeRequiredImpl) then) = + __$$LocationChangeRequiredImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {AuthStatus status, + List conditions, + String url, + bool isLoading, + String? errorMessage}); +} + +/// @nodoc +class __$$LocationChangeRequiredImplCopyWithImpl<$Res> + extends _$AuthStateCopyWithImpl<$Res, _$LocationChangeRequiredImpl> + implements _$$LocationChangeRequiredImplCopyWith<$Res> { + __$$LocationChangeRequiredImplCopyWithImpl( + _$LocationChangeRequiredImpl _value, + $Res Function(_$LocationChangeRequiredImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? status = null, + Object? conditions = null, + Object? url = null, + Object? isLoading = null, + Object? errorMessage = freezed, + }) { + return _then(_$LocationChangeRequiredImpl( + status: null == status + ? _value.status + : status // ignore: cast_nullable_to_non_nullable + as AuthStatus, + conditions: null == conditions + ? _value._conditions + : conditions // ignore: cast_nullable_to_non_nullable + as List, + url: null == url + ? _value.url + : url // ignore: cast_nullable_to_non_nullable + as String, + isLoading: null == isLoading + ? _value.isLoading + : isLoading // ignore: cast_nullable_to_non_nullable + as bool, + errorMessage: freezed == errorMessage + ? _value.errorMessage + : errorMessage // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$LocationChangeRequiredImpl implements LocationChangeRequired { + const _$LocationChangeRequiredImpl( + {this.status = AuthStatus.locationChangeRequired, + final List conditions = const [], + required this.url, + this.isLoading = false, + this.errorMessage}) + : _conditions = conditions; + + @override + @JsonKey() + final AuthStatus status; + final List _conditions; + @override + @JsonKey() + List get conditions { + if (_conditions is EqualUnmodifiableListView) return _conditions; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_conditions); + } + + @override + final String url; + @override + @JsonKey() + final bool isLoading; + @override + final String? errorMessage; + + @override + String toString() { + return 'AuthState.locationChangeRequired(status: $status, conditions: $conditions, url: $url, isLoading: $isLoading, errorMessage: $errorMessage)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$LocationChangeRequiredImpl && + (identical(other.status, status) || other.status == status) && + const DeepCollectionEquality() + .equals(other._conditions, _conditions) && + (identical(other.url, url) || other.url == url) && + (identical(other.isLoading, isLoading) || + other.isLoading == isLoading) && + (identical(other.errorMessage, errorMessage) || + other.errorMessage == errorMessage)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + status, + const DeepCollectionEquality().hash(_conditions), + url, + isLoading, + errorMessage); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$LocationChangeRequiredImplCopyWith<_$LocationChangeRequiredImpl> + get copyWith => __$$LocationChangeRequiredImplCopyWithImpl< + _$LocationChangeRequiredImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage) + uninitialized, + required TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage) + unauthenticated, + required TResult Function(AuthStatus status, Session session, + List conditions, bool isLoading, String? errorMessage) + authenticated, + required TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage) + aal2Requested, + required TResult Function(AuthStatus status, List conditions, + String url, bool isLoading, String? errorMessage) + locationChangeRequired, + }) { + return locationChangeRequired( + status, conditions, url, isLoading, errorMessage); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + uninitialized, + TResult? Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + unauthenticated, + TResult? Function(AuthStatus status, Session session, + List conditions, bool isLoading, String? errorMessage)? + authenticated, + TResult? Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + aal2Requested, + TResult? Function(AuthStatus status, List conditions, String url, + bool isLoading, String? errorMessage)? + locationChangeRequired, + }) { + return locationChangeRequired?.call( + status, conditions, url, isLoading, errorMessage); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + uninitialized, + TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + unauthenticated, + TResult Function(AuthStatus status, Session session, + List conditions, bool isLoading, String? errorMessage)? + authenticated, + TResult Function(AuthStatus status, List conditions, + bool isLoading, String? errorMessage)? + aal2Requested, + TResult Function(AuthStatus status, List conditions, String url, + bool isLoading, String? errorMessage)? + locationChangeRequired, + required TResult orElse(), + }) { + if (locationChangeRequired != null) { + return locationChangeRequired( + status, conditions, url, isLoading, errorMessage); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AuthUninitialized value) uninitialized, + required TResult Function(AuthUnauthenticated value) unauthenticated, + required TResult Function(AuthAuthenticated value) authenticated, + required TResult Function(Aal2Requested value) aal2Requested, + required TResult Function(LocationChangeRequired value) + locationChangeRequired, + }) { + return locationChangeRequired(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AuthUninitialized value)? uninitialized, + TResult? Function(AuthUnauthenticated value)? unauthenticated, + TResult? Function(AuthAuthenticated value)? authenticated, + TResult? Function(Aal2Requested value)? aal2Requested, + TResult? Function(LocationChangeRequired value)? locationChangeRequired, + }) { + return locationChangeRequired?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AuthUninitialized value)? uninitialized, + TResult Function(AuthUnauthenticated value)? unauthenticated, + TResult Function(AuthAuthenticated value)? authenticated, + TResult Function(Aal2Requested value)? aal2Requested, + TResult Function(LocationChangeRequired value)? locationChangeRequired, + required TResult orElse(), + }) { + if (locationChangeRequired != null) { + return locationChangeRequired(this); + } + return orElse(); + } +} + +abstract class LocationChangeRequired implements AuthState { + const factory LocationChangeRequired( + {final AuthStatus status, + final List conditions, + required final String url, + final bool isLoading, + final String? errorMessage}) = _$LocationChangeRequiredImpl; + + @override + AuthStatus get status; + @override + List get conditions; + String get url; + @override + bool get isLoading; + @override + String? get errorMessage; + @override + @JsonKey(ignore: true) + _$$LocationChangeRequiredImplCopyWith<_$LocationChangeRequiredImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/flutter-ory-network/lib/blocs/auth/auth_event.dart b/flutter-ory-network/lib/blocs/auth/auth_event.dart new file mode 100644 index 00000000..5ef70cfd --- /dev/null +++ b/flutter-ory-network/lib/blocs/auth/auth_event.dart @@ -0,0 +1,49 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +part of 'auth_bloc.dart'; + +@immutable +sealed class AuthEvent extends Equatable { + @override + List get props => []; +} + +final class ChangeAuthStatus extends AuthEvent { + final AuthStatus status; + final List conditions; + final Session? session; + + ChangeAuthStatus( + {required this.status, this.session, this.conditions = const []}); + @override + List get props => [status, session, conditions]; +} + +final class GetCurrentSessionInformation extends AuthEvent { + final List conditions; + + GetCurrentSessionInformation({this.conditions = const []}); + + @override + List get props => [conditions]; +} + +final class RequireLocationChange extends AuthEvent { + final String url; + + RequireLocationChange({required this.url}); + @override + List get props => [url]; +} + +final class AddSession extends AuthEvent { + final Session session; + final List conditions; + + AddSession({required this.session, this.conditions = const []}); + @override + List get props => [session, conditions]; +} + +final class LogOut extends AuthEvent {} diff --git a/flutter-ory-network/lib/blocs/auth/auth_state.dart b/flutter-ory-network/lib/blocs/auth/auth_state.dart new file mode 100644 index 00000000..d05b6434 --- /dev/null +++ b/flutter-ory-network/lib/blocs/auth/auth_state.dart @@ -0,0 +1,46 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +part of 'auth_bloc.dart'; + +@freezed +sealed class AuthState with _$AuthState { + const factory AuthState.uninitialized( + {@Default(AuthStatus.uninitialized) final AuthStatus status, + @Default([]) List conditions, + @Default(false) bool isLoading, + String? errorMessage}) = AuthUninitialized; + const factory AuthState.unauthenticated( + {@Default(AuthStatus.unauthenticated) final AuthStatus status, + @Default([]) List conditions, + @Default(false) bool isLoading, + String? errorMessage}) = AuthUnauthenticated; + const factory AuthState.authenticated( + {@Default(AuthStatus.authenticated) final AuthStatus status, + required Session session, + @Default([]) List conditions, + @Default(false) bool isLoading, + String? errorMessage}) = AuthAuthenticated; + const factory AuthState.aal2Requested( + {@Default(AuthStatus.aal2Requested) final AuthStatus status, + @Default([]) List conditions, + @Default(false) bool isLoading, + String? errorMessage}) = Aal2Requested; + + const factory AuthState.locationChangeRequired( + {@Default(AuthStatus.locationChangeRequired) final AuthStatus status, + @Default([]) List conditions, + required String url, + @Default(false) bool isLoading, + String? errorMessage}) = LocationChangeRequired; +} + +class Condition {} + +class RecoveryRequested extends Condition { + final String settingsFlowId; + + RecoveryRequested({required this.settingsFlowId}); +} + +class SessionRefreshRequested extends Condition {} diff --git a/flutter-ory-network/lib/blocs/bloc/recovery_bloc.dart b/flutter-ory-network/lib/blocs/bloc/recovery_bloc.dart new file mode 100644 index 00000000..e6c3592c --- /dev/null +++ b/flutter-ory-network/lib/blocs/bloc/recovery_bloc.dart @@ -0,0 +1,67 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:ory_client/ory_client.dart'; +import 'package:ory_network_flutter/repositories/auth.dart'; + +import '../../services/exceptions.dart'; + +part 'recovery_event.dart'; +part 'recovery_state.dart'; +part 'recovery_bloc.freezed.dart'; + +class RecoveryBloc extends Bloc { + final AuthRepository repository; + RecoveryBloc({required this.repository}) : super(const RecoveryState()) { + on(_onCreateRecoveryFlow); + on(_onChangeNodeValue); + // on(_onGetRecoveryFlow); + on(_onUpdateRecoveryFlow); + } + + Future _onCreateRecoveryFlow( + CreateRecoveryFlow event, Emitter emit) async { + try { + emit(state.copyWith(isLoading: true, message: null)); + + final recoveryFlow = await repository.createRecoveryFlow(); + + emit(state.copyWith(recoveryFlow: recoveryFlow, isLoading: false)); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, message: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); + } + } + + _onChangeNodeValue(ChangeNodeValue event, Emitter emit) { + if (state.recoveryFlow != null) { + final newRecoveryState = repository.changeRecoveryNodeValue( + flow: state.recoveryFlow!, name: event.name, value: event.value); + emit(state.copyWith(recoveryFlow: newRecoveryState, message: null)); + } + } + + Future _onUpdateRecoveryFlow( + UpdateRecoveryFlow event, Emitter emit) async { + try { + if (state.recoveryFlow != null) { + emit(state.copyWith(isLoading: true, message: null)); + final recoveryFlow = await repository.updateRecoveryFlow( + flowId: state.recoveryFlow!.id, + group: event.group, + name: event.name, + value: event.value, + nodes: state.recoveryFlow!.ui.nodes.toList()); + emit(state.copyWith(recoveryFlow: recoveryFlow, isLoading: false)); + } + } on BadRequestException catch (e) { + emit(state.copyWith(recoveryFlow: e.flow, isLoading: false)); + } on settingsRedirectRequired catch (e) { + emit(state.copyWith(settingsFlowId: e.settingsFlowId)); + } + } +} diff --git a/flutter-ory-network/lib/blocs/bloc/recovery_bloc.freezed.dart b/flutter-ory-network/lib/blocs/bloc/recovery_bloc.freezed.dart new file mode 100644 index 00000000..7a14e67e --- /dev/null +++ b/flutter-ory-network/lib/blocs/bloc/recovery_bloc.freezed.dart @@ -0,0 +1,200 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'recovery_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +/// @nodoc +mixin _$RecoveryState { + RecoveryFlow? get recoveryFlow => throw _privateConstructorUsedError; + dynamic get isLoading => throw _privateConstructorUsedError; + String? get settingsFlowId => throw _privateConstructorUsedError; + String? get message => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $RecoveryStateCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $RecoveryStateCopyWith<$Res> { + factory $RecoveryStateCopyWith( + RecoveryState value, $Res Function(RecoveryState) then) = + _$RecoveryStateCopyWithImpl<$Res, RecoveryState>; + @useResult + $Res call( + {RecoveryFlow? recoveryFlow, + dynamic isLoading, + String? settingsFlowId, + String? message}); +} + +/// @nodoc +class _$RecoveryStateCopyWithImpl<$Res, $Val extends RecoveryState> + implements $RecoveryStateCopyWith<$Res> { + _$RecoveryStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? recoveryFlow = freezed, + Object? isLoading = freezed, + Object? settingsFlowId = freezed, + Object? message = freezed, + }) { + return _then(_value.copyWith( + recoveryFlow: freezed == recoveryFlow + ? _value.recoveryFlow + : recoveryFlow // ignore: cast_nullable_to_non_nullable + as RecoveryFlow?, + isLoading: freezed == isLoading + ? _value.isLoading + : isLoading // ignore: cast_nullable_to_non_nullable + as dynamic, + settingsFlowId: freezed == settingsFlowId + ? _value.settingsFlowId + : settingsFlowId // ignore: cast_nullable_to_non_nullable + as String?, + message: freezed == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$RecoveryStateImplCopyWith<$Res> + implements $RecoveryStateCopyWith<$Res> { + factory _$$RecoveryStateImplCopyWith( + _$RecoveryStateImpl value, $Res Function(_$RecoveryStateImpl) then) = + __$$RecoveryStateImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {RecoveryFlow? recoveryFlow, + dynamic isLoading, + String? settingsFlowId, + String? message}); +} + +/// @nodoc +class __$$RecoveryStateImplCopyWithImpl<$Res> + extends _$RecoveryStateCopyWithImpl<$Res, _$RecoveryStateImpl> + implements _$$RecoveryStateImplCopyWith<$Res> { + __$$RecoveryStateImplCopyWithImpl( + _$RecoveryStateImpl _value, $Res Function(_$RecoveryStateImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? recoveryFlow = freezed, + Object? isLoading = freezed, + Object? settingsFlowId = freezed, + Object? message = freezed, + }) { + return _then(_$RecoveryStateImpl( + recoveryFlow: freezed == recoveryFlow + ? _value.recoveryFlow + : recoveryFlow // ignore: cast_nullable_to_non_nullable + as RecoveryFlow?, + isLoading: freezed == isLoading ? _value.isLoading! : isLoading, + settingsFlowId: freezed == settingsFlowId + ? _value.settingsFlowId + : settingsFlowId // ignore: cast_nullable_to_non_nullable + as String?, + message: freezed == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$RecoveryStateImpl implements _RecoveryState { + const _$RecoveryStateImpl( + {this.recoveryFlow, + this.isLoading = false, + this.settingsFlowId, + this.message}); + + @override + final RecoveryFlow? recoveryFlow; + @override + @JsonKey() + final dynamic isLoading; + @override + final String? settingsFlowId; + @override + final String? message; + + @override + String toString() { + return 'RecoveryState(recoveryFlow: $recoveryFlow, isLoading: $isLoading, settingsFlowId: $settingsFlowId, message: $message)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RecoveryStateImpl && + (identical(other.recoveryFlow, recoveryFlow) || + other.recoveryFlow == recoveryFlow) && + const DeepCollectionEquality().equals(other.isLoading, isLoading) && + (identical(other.settingsFlowId, settingsFlowId) || + other.settingsFlowId == settingsFlowId) && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, recoveryFlow, + const DeepCollectionEquality().hash(isLoading), settingsFlowId, message); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$RecoveryStateImplCopyWith<_$RecoveryStateImpl> get copyWith => + __$$RecoveryStateImplCopyWithImpl<_$RecoveryStateImpl>(this, _$identity); +} + +abstract class _RecoveryState implements RecoveryState { + const factory _RecoveryState( + {final RecoveryFlow? recoveryFlow, + final dynamic isLoading, + final String? settingsFlowId, + final String? message}) = _$RecoveryStateImpl; + + @override + RecoveryFlow? get recoveryFlow; + @override + dynamic get isLoading; + @override + String? get settingsFlowId; + @override + String? get message; + @override + @JsonKey(ignore: true) + _$$RecoveryStateImplCopyWith<_$RecoveryStateImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/flutter-ory-network/lib/blocs/bloc/recovery_event.dart b/flutter-ory-network/lib/blocs/bloc/recovery_event.dart new file mode 100644 index 00000000..4ca73733 --- /dev/null +++ b/flutter-ory-network/lib/blocs/bloc/recovery_event.dart @@ -0,0 +1,39 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +part of 'recovery_bloc.dart'; + +@immutable +sealed class RecoveryEvent extends Equatable { + @override + List get props => []; +} + +class CreateRecoveryFlow extends RecoveryEvent {} + +class GetRecoveryFlow extends RecoveryEvent { + final String flowId; + GetRecoveryFlow({required this.flowId}); + @override + List get props => [flowId]; +} + +class UpdateRecoveryFlow extends RecoveryEvent { + final UiNodeGroupEnum group; + final String name; + final String value; + + UpdateRecoveryFlow( + {required this.group, required this.name, required this.value}); + @override + List get props => [group, name, value]; +} + +class ChangeNodeValue extends RecoveryEvent { + final String value; + final String name; + + ChangeNodeValue({required this.value, required this.name}); + @override + List get props => [value, name]; +} diff --git a/flutter-ory-network/lib/blocs/bloc/recovery_state.dart b/flutter-ory-network/lib/blocs/bloc/recovery_state.dart new file mode 100644 index 00000000..f87276c4 --- /dev/null +++ b/flutter-ory-network/lib/blocs/bloc/recovery_state.dart @@ -0,0 +1,13 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +part of 'recovery_bloc.dart'; + +@freezed +sealed class RecoveryState with _$RecoveryState { + const factory RecoveryState( + {RecoveryFlow? recoveryFlow, + @Default(false) isLoading, + String? settingsFlowId, + String? message}) = _RecoveryState; +} diff --git a/flutter-ory-network/lib/blocs/login/login_bloc.dart b/flutter-ory-network/lib/blocs/login/login_bloc.dart new file mode 100644 index 00000000..f3f0ad72 --- /dev/null +++ b/flutter-ory-network/lib/blocs/login/login_bloc.dart @@ -0,0 +1,132 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:bloc/bloc.dart'; +import 'package:collection/collection.dart'; +import 'package:equatable/equatable.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:ory_client/ory_client.dart'; +import 'package:ory_network_flutter/widgets/helpers.dart'; + +import '../../repositories/auth.dart'; +import '../../services/exceptions.dart'; +import '../auth/auth_bloc.dart'; + +part 'login_event.dart'; +part 'login_state.dart'; +part 'login_bloc.freezed.dart'; + +class LoginBloc extends Bloc { + final AuthBloc authBloc; + final AuthRepository repository; + final List conditions; + + LoginBloc( + {required this.authBloc, + required this.repository, + this.conditions = const []}) + : super(LoginState(conditions: conditions)) { + on(_onCreateLoginFlow); + on(_onGetLoginFlow); + on(_onExchangesCodeForSessionToken); + on(_onLoginWithWebAuth); + on(_onChangeNodeValue); + on(_onUpdateLoginFlow); + } + + Future _onCreateLoginFlow( + CreateLoginFlow event, Emitter emit) async { + try { + emit(state.copyWith(isLoading: true, message: null)); + final refresh = isSessionRefreshRequired(state.conditions); + final loginFlow = + await repository.createLoginFlow(aal: event.aal, refresh: refresh); + emit(state.copyWith(loginFlow: loginFlow, isLoading: false)); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, message: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); + } + } + + Future _onGetLoginFlow( + GetLoginFlow event, Emitter emit) async { + try { + emit(state.copyWith(isLoading: true, message: null)); + final loginFlow = await repository.getLoginFlow(flowId: event.flowId); + emit(state.copyWith(loginFlow: loginFlow, isLoading: false)); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, message: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); + } + } + + Future _onLoginWithWebAuth( + LoginWithWebAuth event, Emitter emit) async { + try { + final code = await repository.getWebAuthCode(url: event.url); + add(ExchangeCodesForSessionToken(returnToCode: code)); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, message: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); + } + } + + _onExchangesCodeForSessionToken( + ExchangeCodesForSessionToken event, Emitter emit) async { + try { + emit(state.copyWith(isLoading: true, message: null)); + + final session = await repository.exchangeCodesForSessionToken( + flowId: state.loginFlow?.id, + initCode: state.loginFlow?.sessionTokenExchangeCode!, + returnToCode: event.returnToCode); + authBloc.add(AddSession(session: session)); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, message: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); + } + } + + _onChangeNodeValue(ChangeNodeValue event, Emitter emit) { + if (state.loginFlow != null) { + final newLoginState = repository.changeLoginNodeValue( + flow: state.loginFlow!, name: event.name, value: event.value); + emit(state.copyWith(loginFlow: newLoginState, message: null)); + } + } + + _onUpdateLoginFlow(UpdateLoginFlow event, Emitter emit) async { + try { + emit(state.copyWith(isLoading: true, message: null)); + final session = await repository.updateLoginFlow( + flowId: state.loginFlow!.id, + group: event.group, + name: event.name, + value: event.value, + nodes: state.loginFlow!.ui.nodes.toList()); + + authBloc.add(AddSession(session: session, conditions: state.conditions)); + emit(state.copyWith(isLoading: false)); + } on BadRequestException catch (e) { + emit(state.copyWith(loginFlow: e.flow, isLoading: false)); + } on LocationChangeRequiredException catch (e) { + emit(state.copyWith(isLoading: false)); + add(LoginWithWebAuth(url: e.url)); + } on UnauthorizedException catch (_) { + authBloc.add(ChangeAuthStatus(status: AuthStatus.unauthenticated)); + } on FlowExpiredException catch (e) { + add(GetLoginFlow(flowId: e.flowId)); + } on TwoFactorAuthRequiredException catch (_) { + authBloc.add(ChangeAuthStatus( + status: AuthStatus.aal2Requested, conditions: state.conditions)); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, message: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); + } + } +} diff --git a/flutter-ory-network/lib/blocs/login/login_bloc.freezed.dart b/flutter-ory-network/lib/blocs/login/login_bloc.freezed.dart new file mode 100644 index 00000000..e28011d3 --- /dev/null +++ b/flutter-ory-network/lib/blocs/login/login_bloc.freezed.dart @@ -0,0 +1,212 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'login_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +/// @nodoc +mixin _$LoginState { + LoginFlow? get loginFlow => throw _privateConstructorUsedError; + List get conditions => throw _privateConstructorUsedError; + bool get isLoading => throw _privateConstructorUsedError; + String? get message => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $LoginStateCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $LoginStateCopyWith<$Res> { + factory $LoginStateCopyWith( + LoginState value, $Res Function(LoginState) then) = + _$LoginStateCopyWithImpl<$Res, LoginState>; + @useResult + $Res call( + {LoginFlow? loginFlow, + List conditions, + bool isLoading, + String? message}); +} + +/// @nodoc +class _$LoginStateCopyWithImpl<$Res, $Val extends LoginState> + implements $LoginStateCopyWith<$Res> { + _$LoginStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? loginFlow = freezed, + Object? conditions = null, + Object? isLoading = null, + Object? message = freezed, + }) { + return _then(_value.copyWith( + loginFlow: freezed == loginFlow + ? _value.loginFlow + : loginFlow // ignore: cast_nullable_to_non_nullable + as LoginFlow?, + conditions: null == conditions + ? _value.conditions + : conditions // ignore: cast_nullable_to_non_nullable + as List, + isLoading: null == isLoading + ? _value.isLoading + : isLoading // ignore: cast_nullable_to_non_nullable + as bool, + message: freezed == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$LoginStateImplCopyWith<$Res> + implements $LoginStateCopyWith<$Res> { + factory _$$LoginStateImplCopyWith( + _$LoginStateImpl value, $Res Function(_$LoginStateImpl) then) = + __$$LoginStateImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {LoginFlow? loginFlow, + List conditions, + bool isLoading, + String? message}); +} + +/// @nodoc +class __$$LoginStateImplCopyWithImpl<$Res> + extends _$LoginStateCopyWithImpl<$Res, _$LoginStateImpl> + implements _$$LoginStateImplCopyWith<$Res> { + __$$LoginStateImplCopyWithImpl( + _$LoginStateImpl _value, $Res Function(_$LoginStateImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? loginFlow = freezed, + Object? conditions = null, + Object? isLoading = null, + Object? message = freezed, + }) { + return _then(_$LoginStateImpl( + loginFlow: freezed == loginFlow + ? _value.loginFlow + : loginFlow // ignore: cast_nullable_to_non_nullable + as LoginFlow?, + conditions: null == conditions + ? _value._conditions + : conditions // ignore: cast_nullable_to_non_nullable + as List, + isLoading: null == isLoading + ? _value.isLoading + : isLoading // ignore: cast_nullable_to_non_nullable + as bool, + message: freezed == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$LoginStateImpl implements _LoginState { + const _$LoginStateImpl( + {this.loginFlow, + final List conditions = const [], + this.isLoading = false, + this.message}) + : _conditions = conditions; + + @override + final LoginFlow? loginFlow; + final List _conditions; + @override + @JsonKey() + List get conditions { + if (_conditions is EqualUnmodifiableListView) return _conditions; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_conditions); + } + + @override + @JsonKey() + final bool isLoading; + @override + final String? message; + + @override + String toString() { + return 'LoginState(loginFlow: $loginFlow, conditions: $conditions, isLoading: $isLoading, message: $message)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$LoginStateImpl && + (identical(other.loginFlow, loginFlow) || + other.loginFlow == loginFlow) && + const DeepCollectionEquality() + .equals(other._conditions, _conditions) && + (identical(other.isLoading, isLoading) || + other.isLoading == isLoading) && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, loginFlow, + const DeepCollectionEquality().hash(_conditions), isLoading, message); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$LoginStateImplCopyWith<_$LoginStateImpl> get copyWith => + __$$LoginStateImplCopyWithImpl<_$LoginStateImpl>(this, _$identity); +} + +abstract class _LoginState implements LoginState { + const factory _LoginState( + {final LoginFlow? loginFlow, + final List conditions, + final bool isLoading, + final String? message}) = _$LoginStateImpl; + + @override + LoginFlow? get loginFlow; + @override + List get conditions; + @override + bool get isLoading; + @override + String? get message; + @override + @JsonKey(ignore: true) + _$$LoginStateImplCopyWith<_$LoginStateImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/flutter-ory-network/lib/blocs/login/login_event.dart b/flutter-ory-network/lib/blocs/login/login_event.dart new file mode 100644 index 00000000..6cab8f7e --- /dev/null +++ b/flutter-ory-network/lib/blocs/login/login_event.dart @@ -0,0 +1,67 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +part of 'login_bloc.dart'; + +@immutable +sealed class LoginEvent extends Equatable { + @override + List get props => []; +} + +final class CreateLoginFlow extends LoginEvent { + final String aal; + final bool refresh; + + CreateLoginFlow({this.refresh = false, required this.aal}); + @override + List get props => [refresh, aal]; +} + +class ChangeNodeValue extends LoginEvent { + final String value; + final String name; + + ChangeNodeValue({required this.value, required this.name}); + @override + List get props => [value, name]; +} + +class ExchangeCodesForSessionToken extends LoginEvent { + final String returnToCode; + + ExchangeCodesForSessionToken({required this.returnToCode}); + @override + List get props => [returnToCode]; +} + +class LoginWithWebAuth extends LoginEvent { + final String url; + + LoginWithWebAuth({required this.url}); + @override + List get props => [url]; +} + +class GetLoginFlow extends LoginEvent { + final String flowId; + + GetLoginFlow({required this.flowId}); + @override + List get props => [flowId]; +} + +class UpdateLoginFlow extends LoginEvent { + final UiNodeGroupEnum group; + final String name; + final String value; + final bool recoveryRequested; + + UpdateLoginFlow( + {required this.group, + required this.name, + required this.value, + this.recoveryRequested = false}); + @override + List get props => [group, name, value, recoveryRequested]; +} diff --git a/flutter-ory-network/lib/blocs/login/login_state.dart b/flutter-ory-network/lib/blocs/login/login_state.dart new file mode 100644 index 00000000..037e6cec --- /dev/null +++ b/flutter-ory-network/lib/blocs/login/login_state.dart @@ -0,0 +1,13 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +part of 'login_bloc.dart'; + +@freezed +sealed class LoginState with _$LoginState { + const factory LoginState( + {LoginFlow? loginFlow, + @Default([]) List conditions, + @Default(false) bool isLoading, + String? message}) = _LoginState; +} diff --git a/flutter-ory-network/lib/blocs/registration/registration_bloc.dart b/flutter-ory-network/lib/blocs/registration/registration_bloc.dart new file mode 100644 index 00000000..1bc2f124 --- /dev/null +++ b/flutter-ory-network/lib/blocs/registration/registration_bloc.dart @@ -0,0 +1,120 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:bloc/bloc.dart'; +import 'package:equatable/equatable.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:ory_client/ory_client.dart'; + +import '../../repositories/auth.dart'; +import '../../services/exceptions.dart'; +import '../auth/auth_bloc.dart'; + +part 'registration_event.dart'; +part 'registration_state.dart'; +part 'registration_bloc.freezed.dart'; + +class RegistrationBloc extends Bloc { + final AuthBloc authBloc; + final AuthRepository repository; + RegistrationBloc({required this.authBloc, required this.repository}) + : super(const RegistrationState()) { + on(_onCreateRegistrationFlow); + on(_onGetRegistrationFlow); + on(_onRegisterWithWebAuth); + on(_onExchangeCodesForSessionToken); + on(_onChangeNodeValue); + on(_onUpdateRegistrationFlow); + } + + Future _onCreateRegistrationFlow( + CreateRegistrationFlow event, Emitter emit) async { + try { + emit(state.copyWith(isLoading: true, message: null)); + final flow = await repository.createRegistrationFlow(); + emit(state.copyWith(registrationFlow: flow, isLoading: false)); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, message: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); + } + } + + Future _onGetRegistrationFlow( + GetRegistrationFlow event, Emitter emit) async { + try { + emit(state.copyWith(isLoading: true, message: null)); + final flow = await repository.getRegistrationFlow(flowId: event.flowId); + emit(state.copyWith(registrationFlow: flow, isLoading: false)); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, message: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); + } + } + + _onChangeNodeValue(ChangeNodeValue event, Emitter emit) { + if (state.registrationFlow != null) { + final newRegistrationState = repository.changeRegistrationNodeValue( + flow: state.registrationFlow!, name: event.name, value: event.value); + emit(state.copyWith( + registrationFlow: newRegistrationState, message: null)); + } + } + + Future _onRegisterWithWebAuth( + RegisterWithWebAuth event, Emitter emit) async { + try { + final code = await repository.getWebAuthCode(url: event.url); + add(ExchangeCodesForSessionToken(returnToCode: code)); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, message: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); + } + } + + _onExchangeCodesForSessionToken(ExchangeCodesForSessionToken event, + Emitter emit) async { + try { + emit(state.copyWith(isLoading: true, message: null)); + + final session = await repository.exchangeCodesForSessionToken( + flowId: state.registrationFlow?.id, + initCode: state.registrationFlow?.sessionTokenExchangeCode, + returnToCode: event.returnToCode); + authBloc.add(AddSession(session: session)); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, message: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); + } + } + + Future _onUpdateRegistrationFlow( + UpdateRegistrationFlow event, Emitter emit) async { + try { + if (state.registrationFlow != null) { + emit(state.copyWith(isLoading: true, message: null)); + final session = await repository.updateRegistrationFlow( + flowId: state.registrationFlow!.id, + group: event.group, + name: event.name, + value: event.value, + nodes: state.registrationFlow!.ui.nodes.toList()); + authBloc.add(AddSession(session: session)); + } + } on BadRequestException catch (e) { + emit(state.copyWith(registrationFlow: e.flow, isLoading: false)); + } on LocationChangeRequiredException catch (e) { + emit(state.copyWith(isLoading: false)); + add(RegisterWithWebAuth(url: e.url)); + } on FlowExpiredException catch (e) { + add(GetRegistrationFlow(flowId: e.flowId)); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, message: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); + } + } +} diff --git a/flutter-ory-network/lib/blocs/registration/registration_bloc.freezed.dart b/flutter-ory-network/lib/blocs/registration/registration_bloc.freezed.dart new file mode 100644 index 00000000..fb6d4487 --- /dev/null +++ b/flutter-ory-network/lib/blocs/registration/registration_bloc.freezed.dart @@ -0,0 +1,178 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'registration_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +/// @nodoc +mixin _$RegistrationState { + RegistrationFlow? get registrationFlow => throw _privateConstructorUsedError; + bool get isLoading => throw _privateConstructorUsedError; + String? get message => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $RegistrationStateCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $RegistrationStateCopyWith<$Res> { + factory $RegistrationStateCopyWith( + RegistrationState value, $Res Function(RegistrationState) then) = + _$RegistrationStateCopyWithImpl<$Res, RegistrationState>; + @useResult + $Res call( + {RegistrationFlow? registrationFlow, bool isLoading, String? message}); +} + +/// @nodoc +class _$RegistrationStateCopyWithImpl<$Res, $Val extends RegistrationState> + implements $RegistrationStateCopyWith<$Res> { + _$RegistrationStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? registrationFlow = freezed, + Object? isLoading = null, + Object? message = freezed, + }) { + return _then(_value.copyWith( + registrationFlow: freezed == registrationFlow + ? _value.registrationFlow + : registrationFlow // ignore: cast_nullable_to_non_nullable + as RegistrationFlow?, + isLoading: null == isLoading + ? _value.isLoading + : isLoading // ignore: cast_nullable_to_non_nullable + as bool, + message: freezed == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$RegistrationStateImplCopyWith<$Res> + implements $RegistrationStateCopyWith<$Res> { + factory _$$RegistrationStateImplCopyWith(_$RegistrationStateImpl value, + $Res Function(_$RegistrationStateImpl) then) = + __$$RegistrationStateImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {RegistrationFlow? registrationFlow, bool isLoading, String? message}); +} + +/// @nodoc +class __$$RegistrationStateImplCopyWithImpl<$Res> + extends _$RegistrationStateCopyWithImpl<$Res, _$RegistrationStateImpl> + implements _$$RegistrationStateImplCopyWith<$Res> { + __$$RegistrationStateImplCopyWithImpl(_$RegistrationStateImpl _value, + $Res Function(_$RegistrationStateImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? registrationFlow = freezed, + Object? isLoading = null, + Object? message = freezed, + }) { + return _then(_$RegistrationStateImpl( + registrationFlow: freezed == registrationFlow + ? _value.registrationFlow + : registrationFlow // ignore: cast_nullable_to_non_nullable + as RegistrationFlow?, + isLoading: null == isLoading + ? _value.isLoading + : isLoading // ignore: cast_nullable_to_non_nullable + as bool, + message: freezed == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$RegistrationStateImpl implements _RegistrationState { + const _$RegistrationStateImpl( + {this.registrationFlow, this.isLoading = false, this.message}); + + @override + final RegistrationFlow? registrationFlow; + @override + @JsonKey() + final bool isLoading; + @override + final String? message; + + @override + String toString() { + return 'RegistrationState(registrationFlow: $registrationFlow, isLoading: $isLoading, message: $message)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RegistrationStateImpl && + (identical(other.registrationFlow, registrationFlow) || + other.registrationFlow == registrationFlow) && + (identical(other.isLoading, isLoading) || + other.isLoading == isLoading) && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => + Object.hash(runtimeType, registrationFlow, isLoading, message); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$RegistrationStateImplCopyWith<_$RegistrationStateImpl> get copyWith => + __$$RegistrationStateImplCopyWithImpl<_$RegistrationStateImpl>( + this, _$identity); +} + +abstract class _RegistrationState implements RegistrationState { + const factory _RegistrationState( + {final RegistrationFlow? registrationFlow, + final bool isLoading, + final String? message}) = _$RegistrationStateImpl; + + @override + RegistrationFlow? get registrationFlow; + @override + bool get isLoading; + @override + String? get message; + @override + @JsonKey(ignore: true) + _$$RegistrationStateImplCopyWith<_$RegistrationStateImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/flutter-ory-network/lib/blocs/registration/registration_event.dart b/flutter-ory-network/lib/blocs/registration/registration_event.dart new file mode 100644 index 00000000..88a10554 --- /dev/null +++ b/flutter-ory-network/lib/blocs/registration/registration_event.dart @@ -0,0 +1,56 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +part of 'registration_bloc.dart'; + +@immutable +sealed class RegistrationEvent extends Equatable { + @override + List get props => []; +} + +final class CreateRegistrationFlow extends RegistrationEvent {} + +final class GetRegistrationFlow extends RegistrationEvent { + final String flowId; + + GetRegistrationFlow({required this.flowId}); + @override + List get props => [flowId]; +} + +class ExchangeCodesForSessionToken extends RegistrationEvent { + final String returnToCode; + + ExchangeCodesForSessionToken({required this.returnToCode}); + @override + List get props => [returnToCode]; +} + +class RegisterWithWebAuth extends RegistrationEvent { + final String url; + + RegisterWithWebAuth({required this.url}); + @override + List get props => [url]; +} + +class ChangeNodeValue extends RegistrationEvent { + final String value; + final String name; + + ChangeNodeValue({required this.value, required this.name}); + @override + List get props => [value, name]; +} + +class UpdateRegistrationFlow extends RegistrationEvent { + final UiNodeGroupEnum group; + final String name; + final String value; + + UpdateRegistrationFlow( + {required this.group, required this.name, required this.value}); + @override + List get props => [group, name, value]; +} diff --git a/flutter-ory-network/lib/blocs/registration/registration_state.dart b/flutter-ory-network/lib/blocs/registration/registration_state.dart new file mode 100644 index 00000000..123dd83d --- /dev/null +++ b/flutter-ory-network/lib/blocs/registration/registration_state.dart @@ -0,0 +1,12 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +part of 'registration_bloc.dart'; + +@freezed +sealed class RegistrationState with _$RegistrationState { + const factory RegistrationState( + {RegistrationFlow? registrationFlow, + @Default(false) bool isLoading, + String? message}) = _RegistrationState; +} diff --git a/flutter-ory-network/lib/blocs/settings/settings_bloc.dart b/flutter-ory-network/lib/blocs/settings/settings_bloc.dart new file mode 100644 index 00000000..5bb5909f --- /dev/null +++ b/flutter-ory-network/lib/blocs/settings/settings_bloc.dart @@ -0,0 +1,149 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:bloc/bloc.dart'; +import 'package:bloc_concurrency/bloc_concurrency.dart'; +import 'package:equatable/equatable.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:ory_client/ory_client.dart'; +import 'package:ory_network_flutter/repositories/auth.dart'; + +import '../../repositories/settings.dart'; +import '../../services/exceptions.dart'; +import '../auth/auth_bloc.dart'; + +part 'settings_event.dart'; +part 'settings_state.dart'; + +part 'settings_bloc.freezed.dart'; + +class SettingsBloc extends Bloc { + final AuthBloc authBloc; + final SettingsRepository repository; + late SettingsEvent? _previousEvent; + SettingsBloc({required this.authBloc, required this.repository}) + : super(const SettingsState()) { + on(_onCreateSettingsFlow); + on(_onGetSettingsFlow); + on(_onChangeNodeValue, transformer: sequential()); + on(_onResetSettings); + on(_onUpdateSettingsFlow, transformer: sequential()); + } + + @override + void onEvent(SettingsEvent event) { + super.onEvent(event); + _previousEvent = event; + } + + void retry() { + if (_previousEvent != null) { + add(_previousEvent!); + } + } + + _onChangeNodeValue( + ChangeSettingsNodeValue event, Emitter emit) { + if (state.settingsFlow != null) { + final newSettingsState = repository.changeNodeValue( + settings: state.settingsFlow!, name: event.name, value: event.value); + emit(state.copyWith(settingsFlow: newSettingsState, message: null)); + } + } + + _onResetSettings(ResetSettings event, Emitter emit) async { + try { + if (state.settingsFlow != null) { + emit(state.copyWith(isLoading: true)); + final settings = + await repository.getSettingsFlow(flowId: state.settingsFlow!.id); + List updatedConditions = List.from(state.conditions); + updatedConditions + .removeWhere((element) => element is SessionRefreshRequested); + emit(state.copyWith( + settingsFlow: settings, + conditions: updatedConditions, + isLoading: false)); + } + } on UnauthorizedException catch (_) { + // change auth status as the user is not authenticated + authBloc.add(ChangeAuthStatus(status: AuthStatus.unauthenticated)); + } on FlowExpiredException catch (e) { + // get new settings flow + add(GetSettingsFlow(flowId: e.flowId)); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, message: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); + } + } + + Future _onUpdateSettingsFlow( + UpdateSettingsFlow event, Emitter emit) async { + try { + if (state.settingsFlow != null) { + List updatedConditions = List.from(state.conditions); + updatedConditions + .removeWhere((element) => element is SessionRefreshRequested); + emit(state.copyWith( + isLoading: true, conditions: updatedConditions, message: null)); + final settings = await repository.updateSettingsFlow( + flowId: state.settingsFlow!.id, + group: event.group, + nodes: state.settingsFlow!.ui.nodes.toList()); + emit(state.copyWith(isLoading: false, settingsFlow: settings)); + } + } on UnauthorizedException catch (_) { + // change auth status as the user is not authenticated + authBloc.add(ChangeAuthStatus(status: AuthStatus.unauthenticated)); + } on FlowExpiredException catch (e) { + // get new settings flow + add(GetSettingsFlow(flowId: e.flowId)); + } on SessionRefreshRequiredException catch (_) { + // set session refresh required flag to navigate to login page + List currentConditions = + List.from(state.conditions, growable: true); + currentConditions.add(SessionRefreshRequested()); + emit(state.copyWith(conditions: currentConditions, isLoading: false)); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, message: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); + } + } + + Future _onCreateSettingsFlow( + SettingsEvent event, Emitter emit) async { + try { + emit(state.copyWith(isLoading: true, message: null)); + + final settingsFlow = await repository.createSettingsFlow(); + + emit(state.copyWith(isLoading: false, settingsFlow: settingsFlow)); + } on UnauthorizedException catch (_) { + // change auth status as the user is not authenticated + authBloc.add(ChangeAuthStatus(status: AuthStatus.unauthenticated)); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, message: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); + } + } + + Future _onGetSettingsFlow( + GetSettingsFlow event, Emitter emit) async { + try { + emit(state.copyWith(isLoading: true)); + final settingsFlow = + await repository.getSettingsFlow(flowId: event.flowId); + emit(state.copyWith(isLoading: false, settingsFlow: settingsFlow)); + } on UnauthorizedException catch (_) { + // change auth status as the user is not authenticated + authBloc.add(ChangeAuthStatus(status: AuthStatus.unauthenticated)); + } on UnknownException catch (e) { + emit(state.copyWith(isLoading: false, message: e.message)); + } catch (_) { + emit(state.copyWith(isLoading: false)); + } + } +} diff --git a/flutter-ory-network/lib/blocs/settings/settings_bloc.freezed.dart b/flutter-ory-network/lib/blocs/settings/settings_bloc.freezed.dart new file mode 100644 index 00000000..5ebe4c61 --- /dev/null +++ b/flutter-ory-network/lib/blocs/settings/settings_bloc.freezed.dart @@ -0,0 +1,212 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'settings_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +/// @nodoc +mixin _$SettingsState { + SettingsFlow? get settingsFlow => throw _privateConstructorUsedError; + bool get isLoading => throw _privateConstructorUsedError; + List get conditions => throw _privateConstructorUsedError; + String? get message => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $SettingsStateCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $SettingsStateCopyWith<$Res> { + factory $SettingsStateCopyWith( + SettingsState value, $Res Function(SettingsState) then) = + _$SettingsStateCopyWithImpl<$Res, SettingsState>; + @useResult + $Res call( + {SettingsFlow? settingsFlow, + bool isLoading, + List conditions, + String? message}); +} + +/// @nodoc +class _$SettingsStateCopyWithImpl<$Res, $Val extends SettingsState> + implements $SettingsStateCopyWith<$Res> { + _$SettingsStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? settingsFlow = freezed, + Object? isLoading = null, + Object? conditions = null, + Object? message = freezed, + }) { + return _then(_value.copyWith( + settingsFlow: freezed == settingsFlow + ? _value.settingsFlow + : settingsFlow // ignore: cast_nullable_to_non_nullable + as SettingsFlow?, + isLoading: null == isLoading + ? _value.isLoading + : isLoading // ignore: cast_nullable_to_non_nullable + as bool, + conditions: null == conditions + ? _value.conditions + : conditions // ignore: cast_nullable_to_non_nullable + as List, + message: freezed == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$SettingsStateImplCopyWith<$Res> + implements $SettingsStateCopyWith<$Res> { + factory _$$SettingsStateImplCopyWith( + _$SettingsStateImpl value, $Res Function(_$SettingsStateImpl) then) = + __$$SettingsStateImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {SettingsFlow? settingsFlow, + bool isLoading, + List conditions, + String? message}); +} + +/// @nodoc +class __$$SettingsStateImplCopyWithImpl<$Res> + extends _$SettingsStateCopyWithImpl<$Res, _$SettingsStateImpl> + implements _$$SettingsStateImplCopyWith<$Res> { + __$$SettingsStateImplCopyWithImpl( + _$SettingsStateImpl _value, $Res Function(_$SettingsStateImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? settingsFlow = freezed, + Object? isLoading = null, + Object? conditions = null, + Object? message = freezed, + }) { + return _then(_$SettingsStateImpl( + settingsFlow: freezed == settingsFlow + ? _value.settingsFlow + : settingsFlow // ignore: cast_nullable_to_non_nullable + as SettingsFlow?, + isLoading: null == isLoading + ? _value.isLoading + : isLoading // ignore: cast_nullable_to_non_nullable + as bool, + conditions: null == conditions + ? _value._conditions + : conditions // ignore: cast_nullable_to_non_nullable + as List, + message: freezed == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$SettingsStateImpl implements _SettingsState { + const _$SettingsStateImpl( + {this.settingsFlow, + this.isLoading = false, + final List conditions = const [], + this.message}) + : _conditions = conditions; + + @override + final SettingsFlow? settingsFlow; + @override + @JsonKey() + final bool isLoading; + final List _conditions; + @override + @JsonKey() + List get conditions { + if (_conditions is EqualUnmodifiableListView) return _conditions; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_conditions); + } + + @override + final String? message; + + @override + String toString() { + return 'SettingsState(settingsFlow: $settingsFlow, isLoading: $isLoading, conditions: $conditions, message: $message)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SettingsStateImpl && + (identical(other.settingsFlow, settingsFlow) || + other.settingsFlow == settingsFlow) && + (identical(other.isLoading, isLoading) || + other.isLoading == isLoading) && + const DeepCollectionEquality() + .equals(other._conditions, _conditions) && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, settingsFlow, isLoading, + const DeepCollectionEquality().hash(_conditions), message); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$SettingsStateImplCopyWith<_$SettingsStateImpl> get copyWith => + __$$SettingsStateImplCopyWithImpl<_$SettingsStateImpl>(this, _$identity); +} + +abstract class _SettingsState implements SettingsState { + const factory _SettingsState( + {final SettingsFlow? settingsFlow, + final bool isLoading, + final List conditions, + final String? message}) = _$SettingsStateImpl; + + @override + SettingsFlow? get settingsFlow; + @override + bool get isLoading; + @override + List get conditions; + @override + String? get message; + @override + @JsonKey(ignore: true) + _$$SettingsStateImplCopyWith<_$SettingsStateImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/flutter-ory-network/lib/blocs/settings/settings_event.dart b/flutter-ory-network/lib/blocs/settings/settings_event.dart new file mode 100644 index 00000000..13434520 --- /dev/null +++ b/flutter-ory-network/lib/blocs/settings/settings_event.dart @@ -0,0 +1,39 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +part of 'settings_bloc.dart'; + +@immutable +sealed class SettingsEvent extends Equatable { + @override + List get props => []; +} + +final class CreateSettingsFlow extends SettingsEvent {} + +final class GetSettingsFlow extends SettingsEvent { + final String flowId; + + GetSettingsFlow({required this.flowId}); + @override + List get props => [flowId]; +} + +class ChangeSettingsNodeValue extends SettingsEvent { + final String value; + final String name; + + ChangeSettingsNodeValue({required this.value, required this.name}); + @override + List get props => [value, name]; +} + +class ResetSettings extends SettingsEvent {} + +class UpdateSettingsFlow extends SettingsEvent { + final UiNodeGroupEnum group; + + UpdateSettingsFlow({required this.group}); + @override + List get props => [group]; +} diff --git a/flutter-ory-network/lib/blocs/settings/settings_state.dart b/flutter-ory-network/lib/blocs/settings/settings_state.dart new file mode 100644 index 00000000..2f6cace0 --- /dev/null +++ b/flutter-ory-network/lib/blocs/settings/settings_state.dart @@ -0,0 +1,13 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +part of 'settings_bloc.dart'; + +@freezed +sealed class SettingsState with _$SettingsState { + const factory SettingsState( + {SettingsFlow? settingsFlow, + @Default(false) bool isLoading, + @Default([]) List conditions, + String? message}) = _SettingsState; +} diff --git a/flutter-ory-network/lib/main.dart b/flutter-ory-network/lib/main.dart new file mode 100644 index 00000000..2fbc2cc4 --- /dev/null +++ b/flutter-ory-network/lib/main.dart @@ -0,0 +1,143 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:collection/collection.dart'; +import 'package:dio/dio.dart'; +import 'package:dio/io.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_dotenv/flutter_dotenv.dart'; +import 'package:google_sign_in/google_sign_in.dart'; +import 'package:ory_network_flutter/pages/settings.dart'; +import 'package:ory_network_flutter/widgets/helpers.dart'; +import 'package:ory_network_flutter/widgets/ory_theme.dart'; +import 'dart:io' show Platform; + +import 'blocs/auth/auth_bloc.dart'; +import 'pages/home.dart'; +import 'pages/login.dart'; +import 'pages/entry.dart'; + +import 'repositories/auth.dart'; +import 'services/auth.dart'; + +Future main() async { + await dotenv.load(fileName: '.env'); + final baseUrl = dotenv.get('ORY_BASE_URL'); + + // create the dio client for http requests + final options = BaseOptions( + baseUrl: baseUrl, + connectTimeout: const Duration(seconds: 10000), + receiveTimeout: const Duration(seconds: 5000), + headers: { + 'Accept': 'application/json', + }, + validateStatus: (status) { + // prevent the request from throwing null exception + return status != null && status < 500 ? true : false; + }, + ); + final dio = DioForNative(options); + + final authService = AuthService(dio); + +// We use Web Client ID for Android devices as omitting Client ID +// leads to id Token being null. For more information, +// see https://github.com/flutter/flutter/issues/33393#issuecomment-964728679 + final googleSignIn = GoogleSignIn.instance; + + googleSignIn.initialize( + clientId: Platform.isAndroid + ? dotenv.get('WEB_CLIENT_ID') + : dotenv.get('IOS_CLIENT_ID')); + final authRepository = + AuthRepository(googleSignIn: googleSignIn, service: authService); + runApp(RepositoryProvider.value( + value: authRepository, + child: BlocProvider( + create: (context) => AuthBloc(repository: authRepository) + ..add(GetCurrentSessionInformation()), + child: const MyApp(), + ))); +} + +class MyApp extends StatelessWidget { + const MyApp({super.key}); + + // This widget is the root of your application. + @override + Widget build(BuildContext context) { + return const MaterialApp( + title: 'Flutter Ory Network Demo', + home: MyAppView(), + ); + } +} + +class MyAppView extends StatefulWidget { + const MyAppView({super.key}); + + @override + State createState() => _MyAppViewState(); +} + +class _MyAppViewState extends State { + final _navigatorKey = GlobalKey(); + + NavigatorState get _navigator => _navigatorKey.currentState!; + + @override + Widget build(BuildContext context) { + return MaterialApp( + theme: OryTheme.defaultTheme, + navigatorKey: _navigatorKey, + builder: (context, child) { + return BlocListener( + // navigate to pages only when auth status has changed + listenWhen: (previous, current) => previous.status != current.status, + listener: (context, state) { + state.mapOrNull(unauthenticated: (_) { + _navigator.pushAndRemoveUntil( + MaterialPageRoute( + builder: (BuildContext context) => + const LoginPage(aal: 'aal1')), + (Route route) => false); + }, authenticated: (authState) { + // if user is authenticated and didn't request a recovery, + // navigate to home page + if (!isRecoveryRequired(authState.conditions)) { + _navigator.pushAndRemoveUntil( + MaterialPageRoute( + builder: (BuildContext context) => const HomePage()), + (Route route) => false); + } else { + // otherwise, navigate to settings page + // with provided settings flow id + final recovery = authState.conditions.firstWhereOrNull( + (element) => element is RecoveryRequested)! + as RecoveryRequested; + + _navigator.pushAndRemoveUntil( + MaterialPageRoute( + builder: (BuildContext context) => SettingsPage( + flowId: recovery.settingsFlowId, + )), + (route) => false); + } + }, aal2Requested: (authState) { + _navigator.pushAndRemoveUntil( + MaterialPageRoute( + builder: (BuildContext context) => LoginPage( + conditions: authState.conditions, aal: 'aal2')), + (Route route) => false); + }); + }, + child: child, + ); + }, + onGenerateRoute: (_) => MaterialPageRoute( + builder: (BuildContext context) => const EntryPage()), + ); + } +} diff --git a/flutter-ory-network/lib/pages/entry.dart b/flutter-ory-network/lib/pages/entry.dart new file mode 100644 index 00000000..0e9309d4 --- /dev/null +++ b/flutter-ory-network/lib/pages/entry.dart @@ -0,0 +1,20 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:flutter/material.dart'; + +class EntryPage extends StatelessWidget { + const EntryPage({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Image.asset( + 'assets/images/ory_logo.png', + width: 100, + ), + ), + ); + } +} diff --git a/flutter-ory-network/lib/pages/home.dart b/flutter-ory-network/lib/pages/home.dart new file mode 100644 index 00000000..87d45b37 --- /dev/null +++ b/flutter-ory-network/lib/pages/home.dart @@ -0,0 +1,147 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:ory_client/ory_client.dart'; +import 'package:ory_network_flutter/pages/settings.dart'; + +import '../blocs/auth/auth_bloc.dart'; + +class HomePage extends StatefulWidget { + const HomePage({super.key}); + + @override + State createState() => _HomePageState(); +} + +class _HomePageState extends State { + @override + void initState() { + super.initState(); + // get current session information when the page opens + context.read().add(GetCurrentSessionInformation()); + } + + @override + Widget build(BuildContext context) { + // get loading state + final isLoading = + context.select((AuthBloc authBloc) => authBloc.state.isLoading); + + return Scaffold( + appBar: AppBar( + backgroundColor: Colors.transparent, + title: Image.asset( + 'assets/images/ory_logo.png', + width: 40, + ), + elevation: 0, + actions: [ + IconButton( + onPressed: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const SettingsPage())), + icon: Image.asset('assets/icons/settings.png'), + ), + // if auth is loading, show progress indicator, otherwise a logout icon + isLoading + ? const Padding( + padding: EdgeInsets.only(right: 20.0), + child: Center( + widthFactor: 1, + heightFactor: 1, + child: SizedBox( + height: 24, + width: 24, + child: CircularProgressIndicator(), + ), + ), + ) + : IconButton( + onPressed: () => context.read()..add(LogOut()), + icon: Image.asset('assets/icons/logout.png'), + ), + ], + ), + body: BlocBuilder( + bloc: context.read(), + builder: (BuildContext context, AuthState state) { + switch (state) { + case AuthAuthenticated(session: var session): + return _buildSessionInformation(context, session); + default: + return _buildSessionNotFetched(context, state); + } + }, + )); + } + + _buildSessionInformation(BuildContext context, Session session) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 32), + child: SingleChildScrollView( + physics: const BouncingScrollPhysics(), + child: Column( + children: [ + Text( + 'Welcome back,\n${session.identity?.id}!', + style: const TextStyle(fontWeight: FontWeight.w900, fontSize: 35), + ), + const Padding( + padding: EdgeInsets.only(top: 15.0), + child: Text( + 'Hello, nice to have you! You signed up with this data:'), + ), + Padding( + padding: const EdgeInsets.only(top: 15.0), + child: Container( + padding: const EdgeInsets.all(35), + width: double.infinity, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8), + color: Colors.grey[600]), + child: Text(session.identity!.traits.toString(), + style: const TextStyle( + fontWeight: FontWeight.w500, color: Colors.white)), + ), + ), + const Padding( + padding: EdgeInsets.only(top: 15.0), + child: Text( + 'This app makes REST requests to Ory Kratos Public API to validate and decode the Ory Kratos Session payload:')), + Padding( + padding: const EdgeInsets.only(top: 15.0), + child: Container( + padding: const EdgeInsets.all(35), + width: double.infinity, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8), + color: Colors.grey[600]), + child: Text(session.toString(), + style: const TextStyle( + fontWeight: FontWeight.w500, color: Colors.white)), + ), + ), + ], + ), + ), + ); + } + + _buildSessionNotFetched(BuildContext context, AuthState state) { + if (state.errorMessage != null) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 32), + child: Center( + child: Text( + state.errorMessage!, + style: const TextStyle(color: Colors.red), + )), + ); + } else { + return const Center(child: CircularProgressIndicator()); + } + } +} diff --git a/flutter-ory-network/lib/pages/login.dart b/flutter-ory-network/lib/pages/login.dart new file mode 100644 index 00000000..19932616 --- /dev/null +++ b/flutter-ory-network/lib/pages/login.dart @@ -0,0 +1,281 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:ory_client/ory_client.dart'; + +import '../blocs/auth/auth_bloc.dart'; +import '../blocs/login/login_bloc.dart'; +import '../repositories/auth.dart'; +import '../widgets/helpers.dart'; +import 'recovery.dart'; +import 'registration.dart'; + +class LoginPage extends StatelessWidget { + final List conditions; + final String aal; + + const LoginPage({super.key, this.conditions = const [], required this.aal}); + + @override + Widget build(BuildContext context) { + final sessionRefreshRequested = isSessionRefreshRequired(conditions); + return BlocListener( + // navigate to previous page only if the user refreshed the session + listenWhen: (previous, current) { + final previousSession = + previous.mapOrNull(authenticated: (value) => value.session); + final currentSession = + current.mapOrNull(authenticated: (value) => value.session); + final sessionRefreshRequested = isSessionRefreshRequired(conditions); + return previousSession != currentSession && + previousSession != null && + currentSession != null && + sessionRefreshRequested; + }, + listener: (context, state) { + Navigator.of(context).pop(true); + }, + child: Scaffold( + extendBodyBehindAppBar: !sessionRefreshRequested, + appBar: sessionRefreshRequested + ? AppBar( + backgroundColor: Colors.transparent, + elevation: 0, + leadingWidth: 72, + toolbarHeight: 72, + // use row to avoid force resizing of leading widget + leading: Row( + children: [ + Padding( + padding: const EdgeInsets.only(left: 32, top: 32), + child: GestureDetector( + onTap: () => Navigator.of(context).pop(), + child: Container( + height: 40, + width: 40, + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + border: Border.all( + width: 1, color: const Color(0xFFE2E8F0))), + child: const Icon(Icons.arrow_back, size: 16), + ), + ), + ), + ], + )) + : null, + body: BlocProvider( + create: (context) => LoginBloc( + authBloc: context.read(), + repository: RepositoryProvider.of(context), + conditions: conditions) + ..add(CreateLoginFlow(aal: aal)), + child: LoginForm(isSessionRefresh: sessionRefreshRequested)), + ), + ); + } +} + +class LoginForm extends StatelessWidget { + final bool isSessionRefresh; + + const LoginForm({super.key, this.isSessionRefresh = false}); + + @override + Widget build(BuildContext context) { + return BlocBuilder( + buildWhen: (previous, current) => previous.isLoading != current.isLoading, + builder: (context, state) { + if (state.loginFlow != null) { + return _buildUi(context, state); + } else { + return buildFlowNotCreated(context, state.message); + } + }, + ); + } + + Widget _buildUi(BuildContext context, LoginState state) { + final nodes = state.loginFlow!.ui.nodes; + + // get default nodes from all nodes + final defaultNodes = getNodesOfGroup(UiNodeGroupEnum.default_, nodes); + + // get code nodes from all nodes + final codeNodes = getNodesOfGroup(UiNodeGroupEnum.code, nodes); + + // get password nodes from all nodes + final passwordNodes = getNodesOfGroup(UiNodeGroupEnum.password, nodes); + + // get lookup secret nodes from all nodes + final lookupSecretNodes = + getNodesOfGroup(UiNodeGroupEnum.lookupSecret, nodes); + + // get totp nodes from all nodes + final totpNodes = getNodesOfGroup(UiNodeGroupEnum.totp, nodes); + + // get oidc nodes from all nodes + final oidcNodes = getNodesOfGroup(UiNodeGroupEnum.oidc, nodes); + + return Stack(children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 32), + child: SingleChildScrollView( + // do not show scrolling indicator + physics: const BouncingScrollPhysics(), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (!isSessionRefresh) + Padding( + padding: EdgeInsets.only( + //status bar height + padding + top: MediaQuery.of(context).viewPadding.top + 48), + child: Image.asset( + 'assets/images/ory_logo.png', + width: 70, + ), + ), + // show header depending on auth state + Padding( + padding: const EdgeInsets.symmetric(vertical: 32), + child: BlocSelector( + bloc: (context).read(), + selector: (AuthState state) => + state.status == AuthStatus.aal2Requested, + builder: (BuildContext context, bool boolState) { + return Text( + boolState ? 'Two-Factor Authentication' : 'Sign in', + style: const TextStyle( + fontWeight: FontWeight.w600, + height: 1.5, + fontSize: 18)); + }, + ), + ), + + if (oidcNodes.isNotEmpty) + buildGroup(context, UiNodeGroupEnum.oidc, oidcNodes, + _onInputChange, _onInputSubmit), + if (defaultNodes.isNotEmpty) + buildGroup(context, UiNodeGroupEnum.default_, + defaultNodes, _onInputChange, _onInputSubmit), + if (codeNodes.isNotEmpty) + buildGroup(context, UiNodeGroupEnum.code, codeNodes, + _onInputChange, _onInputSubmit), + if (passwordNodes.isNotEmpty) + Column( + children: [ + buildGroup(context, UiNodeGroupEnum.password, + passwordNodes, _onInputChange, _onInputSubmit), + Padding( + padding: const EdgeInsets.only(top: 10.0), + child: Row( + children: [ + TextButton( + onPressed: () => Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => + const RecoveryPage())), + child: const Text("Forgot password?"), + ), + ], + ), + ), + ], + ), + if (lookupSecretNodes.isNotEmpty) + buildGroup(context, UiNodeGroupEnum.lookupSecret, + lookupSecretNodes, _onInputChange, _onInputSubmit), + if (totpNodes.isNotEmpty) + buildGroup(context, UiNodeGroupEnum.totp, totpNodes, + _onInputChange, _onInputSubmit), + const SizedBox( + height: 32, + ), + if (state.loginFlow?.ui.messages != null) + for (var message in state.loginFlow!.ui.messages!) + Text( + message.text, + style: TextStyle(color: getMessageColor(message.type)), + ), + // show logout button if aal2 requested, otherwise sign up + BlocSelector( + bloc: (context).read(), + selector: (AuthState state) => + state.status == AuthStatus.aal2Requested, + builder: (BuildContext context, bool isAal2Requested) { + if (isAal2Requested || isSessionRefresh) { + return Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const Text('Something\'s not working?'), + TextButton( + onPressed: () => + (context).read().add(LogOut()), + child: const Text('Logout')) + ], + ); + } else { + return Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const Text('No account?'), + TextButton( + onPressed: () => Navigator.of(context) + .pushReplacement(MaterialPageRoute( + builder: (context) => + const RegistrationPage())), + child: const Text('Sign up')) + ], + ); + } + }), + ], + ), + ), + ), + // build progress indicator when state is loading + BlocSelector( + bloc: (context).read(), + selector: (LoginState state) => state.isLoading, + builder: (BuildContext context, bool isLoading) { + if (isLoading) { + return const Opacity( + opacity: 0.8, + child: ModalBarrier(dismissible: false, color: Colors.white30), + ); + } else { + return Container(); + } + }), + BlocSelector( + bloc: (context).read(), + selector: (LoginState state) => state.isLoading, + builder: (BuildContext context, bool isLoading) { + if (isLoading) { + return const Center( + child: CircularProgressIndicator(), + ); + } else { + return Container(); + } + }) + ]); + } + + _onInputChange(BuildContext context, String value, String name) { + context.read().add(ChangeNodeValue(value: value, name: name)); + } + + _onInputSubmit( + BuildContext context, UiNodeGroupEnum group, String name, String value) { + context + .read() + .add(UpdateLoginFlow(group: group, name: name, value: value)); + } +} diff --git a/flutter-ory-network/lib/pages/recovery.dart b/flutter-ory-network/lib/pages/recovery.dart new file mode 100644 index 00000000..3613cd54 --- /dev/null +++ b/flutter-ory-network/lib/pages/recovery.dart @@ -0,0 +1,193 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:ory_client/ory_client.dart'; +import 'package:ory_network_flutter/blocs/bloc/recovery_bloc.dart'; +import 'package:ory_network_flutter/repositories/auth.dart'; +import 'package:ory_network_flutter/widgets/helpers.dart'; + +import '../blocs/auth/auth_bloc.dart'; + +class RecoveryPage extends StatelessWidget { + const RecoveryPage({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: Colors.transparent, + elevation: 0, + leadingWidth: 72, + toolbarHeight: 72, + // use row to avoid force resizing of leading widget + leading: Row( + children: [ + Padding( + padding: const EdgeInsets.only(left: 32, top: 32), + child: GestureDetector( + onTap: () => Navigator.of(context).pop(), + child: Container( + height: 40, + width: 40, + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + border: Border.all( + width: 1, color: const Color(0xFFE2E8F0))), + child: const Icon(Icons.arrow_back, size: 16), + ), + ), + ), + ], + )), + body: BlocProvider( + create: (context) => RecoveryBloc( + repository: RepositoryProvider.of(context)) + ..add(CreateRecoveryFlow()), + child: const RecoveryForm(), + )); + } +} + +class RecoveryForm extends StatelessWidget { + const RecoveryForm({super.key}); + + @override + Widget build(BuildContext context) { + return BlocListener( + listener: (context, state) { + // recovery flow was successful, + // get session information + if (state.settingsFlowId != null) { + final authBloc = (context).read(); + authBloc.add(GetCurrentSessionInformation(conditions: [ + RecoveryRequested(settingsFlowId: state.settingsFlowId!) + ])); + } + }, + child: BlocBuilder( + buildWhen: (previous, current) => + previous.isLoading != current.isLoading, + builder: (context, state) { + if (state.recoveryFlow != null) { + return _buildUi(context, state); + } else { + return buildFlowNotCreated(context, state.message); + } + }, + )); + } + + _buildUi(BuildContext context, RecoveryState state) { + final nodes = state.recoveryFlow!.ui.nodes; + + // get default nodes from all nodes + final defaultNodes = nodes.where((node) { + if (node.group == UiNodeGroupEnum.default_) { + if (node.attributes.oneOf.isType(UiNodeInputAttributes)) { + final attributes = + node.attributes.oneOf.value as UiNodeInputAttributes; + if (attributes.type == UiNodeInputAttributesTypeEnum.hidden) { + return false; + } else { + return true; + } + } + } + return false; + }).toList(); + + // get code nodes from all nodes + final codeNodes = nodes.where((node) { + if (node.group == UiNodeGroupEnum.code) { + if (node.attributes.oneOf.isType(UiNodeInputAttributes)) { + final attributes = + node.attributes.oneOf.value as UiNodeInputAttributes; + if (attributes.type == UiNodeInputAttributesTypeEnum.hidden) { + return false; + } else { + return true; + } + } + } + return false; + }).toList(); + + return Stack(children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 32), + child: SingleChildScrollView( + // do not show scrolling indicator + physics: const BouncingScrollPhysics(), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Padding( + padding: EdgeInsets.symmetric(vertical: 32), + child: Text('Recovery', + style: TextStyle( + fontWeight: FontWeight.w600, + height: 1.5, + fontSize: 18))), + if (defaultNodes.isNotEmpty) + buildGroup(context, UiNodeGroupEnum.default_, + defaultNodes, _onInputChange, _onInputSubmit), + if (codeNodes.isNotEmpty) + buildGroup(context, UiNodeGroupEnum.code, + codeNodes, _onInputChange, _onInputSubmit), + const SizedBox( + height: 32, + ), + if (state.recoveryFlow?.ui.messages != null) + for (var message in state.recoveryFlow!.ui.messages!) + Text( + message.text, + style: TextStyle(color: getMessageColor(message.type)), + ), + ], + ), + ), + ), + // build progress indicator when state is loading + BlocSelector( + bloc: (context).read(), + selector: (RecoveryState state) => state.isLoading, + builder: (BuildContext context, bool isLoading) { + if (isLoading) { + return const Opacity( + opacity: 0.8, + child: ModalBarrier(dismissible: false, color: Colors.white30), + ); + } else { + return Container(); + } + }), + BlocSelector( + bloc: (context).read(), + selector: (RecoveryState state) => state.isLoading, + builder: (BuildContext context, bool isLoading) { + if (isLoading) { + return const Center( + child: CircularProgressIndicator(), + ); + } else { + return Container(); + } + }) + ]); + } + + _onInputChange(BuildContext context, String value, String name) { + context.read().add(ChangeNodeValue(value: value, name: name)); + } + + _onInputSubmit( + BuildContext context, UiNodeGroupEnum group, String name, String value) { + context + .read() + .add(UpdateRecoveryFlow(group: group, name: name, value: value)); + } +} diff --git a/flutter-ory-network/lib/pages/registration.dart b/flutter-ory-network/lib/pages/registration.dart new file mode 100644 index 00000000..e291f753 --- /dev/null +++ b/flutter-ory-network/lib/pages/registration.dart @@ -0,0 +1,191 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:ory_client/ory_client.dart'; + +import '../blocs/auth/auth_bloc.dart'; +import '../blocs/registration/registration_bloc.dart'; +import '../repositories/auth.dart'; +import '../widgets/helpers.dart'; +import 'login.dart'; + +class RegistrationPage extends StatelessWidget { + const RegistrationPage({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: BlocProvider( + create: (context) => RegistrationBloc( + authBloc: context.read(), + repository: RepositoryProvider.of(context)) + ..add(CreateRegistrationFlow()), + child: const RegistrationForm()), + ); + } +} + +class RegistrationForm extends StatefulWidget { + const RegistrationForm({super.key}); + + @override + State createState() => RegistrationFormState(); +} + +class RegistrationFormState extends State { + final emailController = TextEditingController(); + final passwordController = TextEditingController(); + + @override + Widget build(BuildContext context) { + return BlocBuilder( + buildWhen: (previous, current) => previous.isLoading != current.isLoading, + builder: (context, state) { + if (state.registrationFlow != null) { + return _buildUi(context, state); + } else { + return buildFlowNotCreated(context, state.message); + } + }, + ); + } + + _buildUi(BuildContext context, RegistrationState state) { + final nodes = state.registrationFlow!.ui.nodes; + + // get default nodes from all nodes + final defaultNodes = getNodesOfGroup(UiNodeGroupEnum.default_, nodes); + + // get code nodes from all nodes + final codeNodes = getNodesOfGroup(UiNodeGroupEnum.code, nodes); + + // get password nodes from all nodes + final passwordNodes = getNodesOfGroup(UiNodeGroupEnum.password, nodes); + + // get lookup secret nodes from all nodes + final lookupSecretNodes = + getNodesOfGroup(UiNodeGroupEnum.lookupSecret, nodes); + + // get totp nodes from all nodes + final totpNodes = getNodesOfGroup(UiNodeGroupEnum.totp, nodes); + + // get oidc nodes from all nodes + final oidcNodes = getNodesOfGroup(UiNodeGroupEnum.oidc, nodes); + + return Stack(children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 32), + child: SingleChildScrollView( + // do not show scrolling indicator + physics: const BouncingScrollPhysics(), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only( + //status bar height + padding + top: MediaQuery.of(context).viewPadding.top + 48), + child: Image.asset( + 'assets/images/ory_logo.png', + width: 70, + ), + ), + const SizedBox( + height: 32, + ), + const Text('Sign up', + style: TextStyle( + fontWeight: FontWeight.w600, height: 1.5, fontSize: 18)), + if (oidcNodes.isNotEmpty) + buildGroup(context, UiNodeGroupEnum.oidc, + oidcNodes, _onInputChange, _onInputSubmit), + if (defaultNodes.isNotEmpty) + buildGroup(context, UiNodeGroupEnum.default_, + defaultNodes, _onInputChange, _onInputSubmit), + if (codeNodes.isNotEmpty) + buildGroup(context, UiNodeGroupEnum.code, + codeNodes, _onInputChange, _onInputSubmit), + if (passwordNodes.isNotEmpty) + buildGroup(context, UiNodeGroupEnum.password, + passwordNodes, _onInputChange, _onInputSubmit), + if (lookupSecretNodes.isNotEmpty) + buildGroup( + context, + UiNodeGroupEnum.lookupSecret, + lookupSecretNodes, + _onInputChange, + _onInputSubmit), + if (totpNodes.isNotEmpty) + buildGroup(context, UiNodeGroupEnum.totp, + totpNodes, _onInputChange, _onInputSubmit), + const SizedBox( + height: 32, + ), + if (state.registrationFlow?.ui.messages != null) + for (var message in state.registrationFlow!.ui.messages!) + Text( + message.text, + style: TextStyle(color: getMessageColor(message.type)), + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const Text('Already have an account?'), + TextButton( + onPressed: () => Navigator.of(context) + .pushReplacement(MaterialPageRoute( + builder: (context) => const LoginPage( + aal: 'aal1', + ))), + child: const Text('Sign in')) + ], + ) + ], + ), + ), + ), + // build progress indicator when state is loading + BlocSelector( + bloc: (context).read(), + selector: (RegistrationState state) => state.isLoading, + builder: (BuildContext context, bool isLoading) { + if (isLoading) { + return const Opacity( + opacity: 0.8, + child: ModalBarrier(dismissible: false, color: Colors.white30), + ); + } else { + return Container(); + } + }), + BlocSelector( + bloc: (context).read(), + selector: (RegistrationState state) => state.isLoading, + builder: (BuildContext context, bool isLoading) { + if (isLoading) { + return const Center( + child: CircularProgressIndicator(), + ); + } else { + return Container(); + } + }) + ]); + } + + _onInputChange(BuildContext context, String value, String name) { + context + .read() + .add(ChangeNodeValue(value: value, name: name)); + } + + _onInputSubmit( + BuildContext context, UiNodeGroupEnum group, String name, String value) { + context + .read() + .add(UpdateRegistrationFlow(group: group, name: name, value: value)); + } +} diff --git a/flutter-ory-network/lib/pages/settings.dart b/flutter-ory-network/lib/pages/settings.dart new file mode 100644 index 00000000..461d714d --- /dev/null +++ b/flutter-ory-network/lib/pages/settings.dart @@ -0,0 +1,355 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:ory_client/ory_client.dart'; +import 'package:ory_network_flutter/repositories/settings.dart'; + +import '../blocs/auth/auth_bloc.dart'; +import '../blocs/settings/settings_bloc.dart'; +import '../repositories/auth.dart'; +import '../widgets/helpers.dart'; +import 'home.dart'; +import 'login.dart'; + +class SettingsPage extends StatelessWidget { + final String? flowId; + const SettingsPage({super.key, this.flowId}); + + @override + Widget build(BuildContext context) { + final service = RepositoryProvider.of(context).service; + return Scaffold( + appBar: AppBar( + backgroundColor: Colors.transparent, + elevation: 0, + leadingWidth: 72, + toolbarHeight: 72, + // use row to avoid force resizing of leading widget + leading: Row( + children: [ + Padding( + padding: const EdgeInsets.only(left: 32, top: 32), + child: !Navigator.of(context).canPop() + ? GestureDetector( + onTap: () => Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (BuildContext context) => + const HomePage())), + child: Container( + height: 40, + width: 40, + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + border: Border.all( + width: 1, color: const Color(0xFFE2E8F0))), + child: const Icon(Icons.cancel, size: 16), + ), + ) + : GestureDetector( + onTap: () => Navigator.of(context).pop(), + child: Container( + height: 40, + width: 40, + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + border: Border.all( + width: 1, color: const Color(0xFFE2E8F0))), + child: const Icon(Icons.arrow_back, size: 16), + ), + ), + ), + ], + )), + body: BlocProvider( + create: (context) => SettingsBloc( + authBloc: context.read(), + repository: SettingsRepository(service: service)) + ..add(flowId != null + ? GetSettingsFlow(flowId: flowId!) + : CreateSettingsFlow()), + child: const SettingsForm()), + ); + } +} + +class SettingsForm extends StatelessWidget { + const SettingsForm({super.key}); + + @override + Widget build(BuildContext context) { + final settingsBloc = BlocProvider.of(context); + return MultiBlocListener( + listeners: [ + BlocListener( + bloc: settingsBloc, + listenWhen: (SettingsState previous, SettingsState current) { + final wasSessionRefreshRequested = + isSessionRefreshRequired(previous.conditions); + final isSessionRefreshRequested = + isSessionRefreshRequired(current.conditions); + return wasSessionRefreshRequested != isSessionRefreshRequested; + }, + listener: (BuildContext context, SettingsState state) async { + // if session needs to be refreshed, navigate to login flow screen + if (isSessionRefreshRequired(state.conditions)) { + await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => LoginPage( + conditions: [SessionRefreshRequested()], + aal: 'aal1', + ))).then((value) { + // retry updating settings when session was refreshed + if (value != null) { + if (value && state.settingsFlow?.id != null) { + settingsBloc.retry(); + } + } else { + // if user goes back without finishing login, + // reset settings + settingsBloc.add(ResetSettings()); + } + }); + } + }, + ), + // listen to message changes and display them as a snackbar + BlocListener( + bloc: settingsBloc, + listenWhen: (SettingsState previous, SettingsState current) => + // listen to changes only when current + // state is not loading (e.g. updating settings), + // previous state was loading, + // there is a new message, + // and session refresh is not required + !current.isLoading && + previous.isLoading && + current.settingsFlow?.ui.messages != null && + !isSessionRefreshRequired(current.conditions), + listener: (BuildContext context, SettingsState state) { + if (state.settingsFlow!.ui.messages != null) { + // for simplicity, we will only show the first message in snackbar + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + backgroundColor: getMessageColor( + state.settingsFlow!.ui.messages!.first.type), + content: Text(state.settingsFlow!.ui.messages!.first.text), + )); + } + }), + + // when there is a general message, + // jump to the page start in order to show the message + BlocListener( + bloc: settingsBloc, + listener: (BuildContext context, SettingsState state) { + if (state.message != null) { + // for simplicity, + // we will only show the first message in snackbar + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + backgroundColor: Colors.red, + content: Text(state.message!), + )); + } + }), + // remove snackbars when loading + BlocListener( + bloc: settingsBloc, + listener: (BuildContext context, SettingsState state) { + if (state.isLoading) { + ScaffoldMessenger.of(context).clearSnackBars(); + } + }) + ], + child: BlocBuilder( + buildWhen: (previous, current) => + previous.isLoading != current.isLoading, + builder: (context, state) { + // settings flow was created + if (state.settingsFlow != null) { + return _buildUi(context, state); + } // otherwise, show loading or error + else { + return buildFlowNotCreated(context, state.message); + } + }, + )); + } + + _buildUi(BuildContext context, SettingsState state) { + final nodes = state.settingsFlow!.ui.nodes; + + // get default nodes from all nodes + final defaultNodes = nodes.where((node) { + if (node.group == UiNodeGroupEnum.default_) { + if (node.attributes.oneOf.isType(UiNodeInputAttributes)) { + final attributes = + node.attributes.oneOf.value as UiNodeInputAttributes; + if (attributes.type == UiNodeInputAttributesTypeEnum.hidden) { + return false; + } else { + return true; + } + } + } + return false; + }).toList(); + + // get profile nodes from all nodes + final profileNodes = getNodesOfGroup(UiNodeGroupEnum.profile, nodes); + + // get password nodes from all nodes + final passwordNodes = getNodesOfGroup(UiNodeGroupEnum.password, nodes); + + // get lookup secret nodes from all nodes + final lookupSecretNodes = + getNodesOfGroup(UiNodeGroupEnum.lookupSecret, nodes); + + // get totp nodes from all nodes + final totpNodes = getNodesOfGroup(UiNodeGroupEnum.totp, nodes); + + return Stack(children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 32), + child: SingleChildScrollView( + // do not show scrolling indicator + physics: const BouncingScrollPhysics(), + child: Column( + children: [ + if (defaultNodes.isNotEmpty) + buildGroup(context, UiNodeGroupEnum.default_, + defaultNodes, _onInputChange, _onInputSubmit), + if (profileNodes.isNotEmpty) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(_buildGroupHeadingText(UiNodeGroupEnum.profile), + style: const TextStyle( + fontWeight: FontWeight.bold, + height: 1.5, + fontSize: 18)), + const SizedBox( + height: 20, + ), + buildGroup(context, UiNodeGroupEnum.profile, + profileNodes, _onInputChange, _onInputSubmit) + ], + ), + if (passwordNodes.isNotEmpty) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(_buildGroupHeadingText(UiNodeGroupEnum.password), + style: const TextStyle( + fontWeight: FontWeight.bold, + height: 1.5, + fontSize: 18)), + const SizedBox( + height: 20, + ), + buildGroup(context, UiNodeGroupEnum.password, + passwordNodes, _onInputChange, _onInputSubmit) + ], + ), + if (lookupSecretNodes.isNotEmpty) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(_buildGroupHeadingText(UiNodeGroupEnum.lookupSecret), + style: const TextStyle( + fontWeight: FontWeight.bold, + height: 1.5, + fontSize: 18)), + const SizedBox( + height: 20, + ), + buildGroup( + context, + UiNodeGroupEnum.lookupSecret, + lookupSecretNodes, + _onInputChange, + _onInputSubmit) + ], + ), + if (totpNodes.isNotEmpty) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(_buildGroupHeadingText(UiNodeGroupEnum.totp), + style: const TextStyle( + fontWeight: FontWeight.bold, + height: 1.5, + fontSize: 18)), + const SizedBox( + height: 20, + ), + buildGroup(context, UiNodeGroupEnum.totp, + totpNodes, _onInputChange, _onInputSubmit), + ], + ), + const SizedBox( + height: 32, + ) + ], + ), + ), + ), + // build progress indicator when state is loading + BlocSelector( + bloc: (context).read(), + selector: (SettingsState state) => state.isLoading, + builder: (BuildContext context, bool booleanState) { + if (booleanState) { + return const Opacity( + opacity: 0.8, + child: ModalBarrier(dismissible: false, color: Colors.white30), + ); + } else { + return Container(); + } + }), + BlocSelector( + bloc: (context).read(), + selector: (SettingsState state) => state.isLoading, + builder: (BuildContext context, bool booleanState) { + if (booleanState) { + return const Center( + child: CircularProgressIndicator(), + ); + } else { + return Container(); + } + }), + ]); + } + + // get group heading + _buildGroupHeadingText(UiNodeGroupEnum group) { + switch (group) { + case UiNodeGroupEnum.lookupSecret: + return 'Backup Recovery Codes'; + case UiNodeGroupEnum.password: + return 'Change Password'; + case UiNodeGroupEnum.profile: + return 'Profile Settings'; + case UiNodeGroupEnum.totp: + return '2FA Authenticator'; + default: + return 'Settings'; + } + } + + _onInputChange(BuildContext context, String value, String name) { + context + .read() + .add(ChangeSettingsNodeValue(value: value, name: name)); + } + + _onInputSubmit( + BuildContext context, UiNodeGroupEnum group, String name, String value) { + context.read().add(UpdateSettingsFlow(group: group)); + } +} diff --git a/flutter-ory-network/lib/repositories/auth.dart b/flutter-ory-network/lib/repositories/auth.dart new file mode 100644 index 00000000..e8d2004e --- /dev/null +++ b/flutter-ory-network/lib/repositories/auth.dart @@ -0,0 +1,356 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'dart:convert'; +import 'dart:io' show Platform; + +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/json_object.dart'; +import 'package:crypto/crypto.dart'; +import 'package:deep_collection/deep_collection.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_web_auth/flutter_web_auth.dart'; +import 'package:google_sign_in/google_sign_in.dart'; +import 'package:one_of/one_of.dart'; +import 'package:ory_client/ory_client.dart'; +import 'package:collection/collection.dart'; +import 'package:ory_network_flutter/services/exceptions.dart'; +import 'package:ory_network_flutter/widgets/helpers.dart'; +import 'package:sign_in_with_apple/sign_in_with_apple.dart'; + +import '../services/auth.dart'; + +enum AuthStatus { + uninitialized, + authenticated, + unauthenticated, + aal2Requested, + locationChangeRequired +} + +class AuthRepository { + final AuthService service; + final GoogleSignIn googleSignIn; + + AuthRepository({required this.googleSignIn, required this.service}); + + Future getCurrentSessionInformation() async { + final session = await service.getCurrentSessionInformation(); + return session; + } + + Future createLoginFlow( + {required String aal, required bool refresh}) async { + final flow = await service.createLoginFlow(aal: aal, refresh: refresh); + return flow; + } + + Future createRegistrationFlow() async { + final flow = await service.createRegistrationFlow(); + return flow; + } + + Future createRecoveryFlow() async { + final flow = await service.createRecoveryFlow(); + return flow; + } + + Future getLoginFlow({required String flowId}) async { + final flow = await service.getLoginFlow(flowId: flowId); + return flow; + } + + Future getRegistrationFlow({required String flowId}) async { + final flow = await service.getRegistrationFlow(flowId: flowId); + return flow; + } + + Future logout() async { + await service.logout(); + } + + Future getWebAuthCode({required String url}) async { + try { + final result = + await FlutterWebAuth.authenticate(url: url, callbackUrlScheme: 'ory'); + // get return to code + final code = Uri.parse(result).queryParameters['code']; + if (code != null) { + return code; + } else { + throw const CustomException.unknown(); + } + } on PlatformException catch (_) { + throw const CustomException.unknown(); + } + } + + Future exchangeCodesForSessionToken( + {String? flowId, String? initCode, String? returnToCode}) async { + if (flowId != null && initCode != null && returnToCode != null) { + final session = service.exchangeCodesForSessionToken( + flowId: flowId, initCode: initCode, returnToCode: returnToCode); + return session; + } else { + throw const CustomException.unknown(); + } + } + + Future updateRegistrationFlow( + {required String flowId, + required UiNodeGroupEnum group, + required String name, + required String value, + required List nodes}) async { + // create request body + var body = _createRequestBody( + group: group, name: name, value: value, nodes: nodes); + // user used social sign in + if (group == UiNodeGroupEnum.oidc) { + if (value.contains('google')) { + final idToken = await _loginWithGoogle(); + // update body with id token and nonce + _addIdTokenAndNonceToBody(idToken, body); + } + if (value.contains('apple')) { + final idToken = + Platform.isAndroid ? await null : await _logInWithAppleOnIOS(); + // update body with id token and nonce + if (idToken != null) { + _addIdTokenAndNonceToBody(idToken, body); + } + } + } + // submit registration and retrieve session + final session = await service.updateRegistrationFlow( + flowId: flowId, group: group, value: body); + return session; + } + + Future updateLoginFlow( + {required String flowId, + required UiNodeGroupEnum group, + required String name, + required String value, + required List nodes}) async { + // create request body + var body = _createRequestBody( + group: group, name: name, value: value, nodes: nodes); + // user used social sign in + if (group == UiNodeGroupEnum.oidc) { + if (value.contains('google')) { + final idToken = await _loginWithGoogle(); + // update body with id token and nonce + _addIdTokenAndNonceToBody(idToken, body); + } + if (value.contains('apple')) { + final idToken = + Platform.isAndroid ? null : await _logInWithAppleOnIOS(); + // update body with id token and nonce + if (idToken != null) { + _addIdTokenAndNonceToBody(idToken, body); + } + } + } + // submit login + final session = await service.updateLoginFlow( + flowId: flowId, group: group, value: body); + return session; + } + + Future updateRecoveryFlow( + {required String flowId, + required UiNodeGroupEnum group, + required String name, + required String value, + required List nodes}) async { + // create request body + var body = _createRequestBody( + group: group, name: name, value: value, nodes: nodes); + + // submit recovery + final recovery = + await service.updateRecoveryFlow(flowId: flowId, value: body); + return recovery; + } + + Map _getMapFromJWT(String splittedToken) { + String normalizedSource = base64Url.normalize(splittedToken); + return jsonDecode(utf8.decode(base64Url.decode(normalizedSource))); + } + + void _addIdTokenAndNonceToBody(String idToken, Map body) { + // get nonce value from id token + final jwtParts = idToken.split('.'); + final jwt = _getMapFromJWT(jwtParts[1]); + // add id token and nonce to body + body.addAll({'id_token': idToken, 'nonce': jwt['nonce']}); + } + + Future _loginWithGoogle() async { + try { + final GoogleSignInAccount account = await googleSignIn.authenticate(); + + final GoogleSignInAuthentication googleAuth = account.authentication; + if (googleAuth.idToken != null) { + return googleAuth.idToken!; + } else { + throw const CustomException.unknown(); + } + } catch (e) { + throw const CustomException.unknown(); + } + } + + Future _logInWithAppleOnIOS() async { + try { + //Check if Apple SignIn is available for the device or not + if (await SignInWithApple.isAvailable()) { + // create nonce + final rawNonce = generateNonce(); + final nonceInBytes = utf8.encode(rawNonce); + final nonce = sha256.convert(nonceInBytes); + // login + final AuthorizationCredentialAppleID credential = + await SignInWithApple.getAppleIDCredential( + scopes: [AppleIDAuthorizationScopes.email], + nonce: nonce.toString(), + ); + + if (credential.identityToken != null) { + return credential.identityToken!; + } else { + throw const CustomException.unknown(); + } + } else { + throw const CustomException.unknown( + message: 'Sign in with Apple is not available on your device'); + } + } catch (e) { + throw const CustomException.unknown(); + } + } + + Map _createRequestBody( + {required UiNodeGroupEnum group, + required String name, + required String value, + required List nodes}) { + // find default nodes (e.g identifier) + var inputNodes = + nodes.where((node) => node.group == UiNodeGroupEnum.default_).toList(); + // create maps from attribute names and their values + var nestedMaps = inputNodes.map((node) { + final attributes = asInputAttributes(node); + final nodeValue = getInputNodeValue(attributes); + + return generateNestedMap(attributes.name, nodeValue); + }).toList(); + + // if name of submitted node is method, find all nodes that belong to the group + if (name == 'method') { + // get input nodes of the same group + final methodNodes = nodes.where((node) { + if (isInputNode(node)) { + final attributes = asInputAttributes(node); + + return node.group == group && + attributes.type != UiNodeInputAttributesTypeEnum.button && + attributes.type != UiNodeInputAttributesTypeEnum.submit; + } else { + return false; + } + }).toList(); + inputNodes = inputNodes + methodNodes; + // create maps from attribute names and their values + final methodMaps = methodNodes.map((node) { + final attributes = asInputAttributes(node); + final nodeValue = getInputNodeValue(attributes); + + return generateNestedMap(attributes.name, nodeValue); + }).toList(); + // add method maps to default maps + nestedMaps.addAll(methodMaps); + } else { + // add single map to default maps + nestedMaps.add({name: value}); + } + + // merge nested maps into one + final mergedMap = + nestedMaps.reduce((value, element) => value.deepMerge(element)); + + return mergedMap; + } + + RegistrationFlow changeRegistrationNodeValue( + {required RegistrationFlow flow, + required String name, + required String value}) { + // update node value + final updatedNodes = + updateNodes(nodes: flow.ui.nodes, name: name, value: value); + // update registration flow + final newFlow = flow.rebuild((p0) => p0..ui.nodes.replace(updatedNodes)); + return newFlow; + } + + LoginFlow changeLoginNodeValue( + {required LoginFlow flow, required String name, required String value}) { + // update node value + final updatedNodes = + updateNodes(nodes: flow.ui.nodes, name: name, value: value); + // update login flow + final newFlow = flow.rebuild((p0) => p0..ui.nodes.replace(updatedNodes)); + return newFlow; + } + + RecoveryFlow changeRecoveryNodeValue( + {required RecoveryFlow flow, + required String name, + required String value}) { + // update node value + final updatedNodes = + updateNodes(nodes: flow.ui.nodes, name: name, value: value); + // update login flow + final newFlow = flow.rebuild((p0) => p0..ui.nodes.replace(updatedNodes)); + return newFlow; + } + + BuiltList updateNodes( + {required BuiltList nodes, + required String name, + required String value}) { + // get edited node + final node = nodes.firstWhereOrNull((element) { + if (isInputNode(element)) { + return asInputAttributes(element).name == name; + } else { + return false; + } + }); + + // udate value of edited node + final updatedNode = node?.rebuild((p0) => p0 + ..attributes.update((b) { + final oldValue = b.oneOf?.value as UiNodeInputAttributes; + final newValue = oldValue.rebuild((p0) => p0.value = JsonObject(value)); + b.oneOf = OneOf1(value: newValue); + })); + // get index of to be updated node + final nodeIndex = nodes.indexOf(node!); + // update list of nodes to iclude updated node + return nodes.rebuild((p0) => p0 + ..removeAt(nodeIndex) + ..insert(nodeIndex, updatedNode!)); + } + + Map generateNestedMap(String path, String value) { + var steps = path.split('.'); + Object? result = value; + for (var step in steps.reversed) { + result = {step: result}; + } + return result as Map; + } +} diff --git a/flutter-ory-network/lib/repositories/settings.dart b/flutter-ory-network/lib/repositories/settings.dart new file mode 100644 index 00000000..bdbc2ba4 --- /dev/null +++ b/flutter-ory-network/lib/repositories/settings.dart @@ -0,0 +1,124 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:built_value/json_object.dart'; +import 'package:deep_collection/deep_collection.dart'; +import 'package:one_of/one_of.dart'; +import 'package:ory_client/ory_client.dart'; +import 'package:collection/collection.dart'; + +import '../services/auth.dart'; + +class SettingsRepository { + final AuthService service; + + SettingsRepository({required this.service}); + + Future createSettingsFlow() async { + final settingsFlow = await service.createSettingsFlow(); + return resetButtonValues(settingsFlow: settingsFlow); + } + + Future getSettingsFlow({required String flowId}) async { + final settingsFlow = await service.getSettingsFlow(flowId: flowId); + return resetButtonValues(settingsFlow: settingsFlow); + } + + SettingsFlow resetButtonValues({required SettingsFlow settingsFlow}) { + final submitInputNodes = settingsFlow.ui.nodes.where((p0) { + if (p0.attributes.oneOf.isType(UiNodeInputAttributes)) { + final attributes = p0.attributes.oneOf.value as UiNodeInputAttributes; + final type = attributes.type; + + if ((type == UiNodeInputAttributesTypeEnum.button || + type == UiNodeInputAttributesTypeEnum.submit) && + attributes.value?.asString == 'true') { + return true; + } + } + return false; + }); + for (var node in submitInputNodes) { + final attributes = node.attributes.oneOf.value as UiNodeInputAttributes; + // reset button value to false + // to prevent submitting values that were not selected + settingsFlow = changeNodeValue( + settings: settingsFlow, name: attributes.name, value: 'false'); + } + return settingsFlow; + } + + Future updateSettingsFlow( + {required String flowId, + required UiNodeGroupEnum group, + required List nodes}) async { + // get input nodes of the same group + final inputNodes = nodes.where((p0) { + if (p0.attributes.oneOf.isType(UiNodeInputAttributes)) { + final type = (p0.attributes.oneOf.value as UiNodeInputAttributes).type; + return p0.group == group && + type != UiNodeInputAttributesTypeEnum.button; + } else { + return false; + } + }); + + // create maps from attribute names and their values + final nestedMaps = inputNodes.map((e) { + final attributes = e.attributes.oneOf.value as UiNodeInputAttributes; + + return generateNestedMap(attributes.name, attributes.value?.asString); + }).toList(); + + // merge nested maps into one + final mergedMap = + nestedMaps.reduce((value, element) => value.deepMerge(element)); + + final updatedSettings = await service.updateSettingsFlow( + flowId: flowId, group: group, value: mergedMap); + return resetButtonValues(settingsFlow: updatedSettings); + } + + SettingsFlow changeNodeValue( + {required SettingsFlow settings, + required String name, + required String value}) { + // get edited node + final node = settings.ui.nodes.firstWhereOrNull((element) { + if (element.attributes.oneOf.isType(UiNodeInputAttributes)) { + return (element.attributes.oneOf.value as UiNodeInputAttributes).name == + name; + } else { + return false; + } + }); + + // udate value of edited node + final updatedNode = node?.rebuild((p0) => p0 + ..attributes.update((b) { + final oldValue = b.oneOf?.value as UiNodeInputAttributes; + final newValue = oldValue.rebuild((p0) => p0.value = JsonObject(value)); + b.oneOf = OneOf1(value: newValue); + })); + // get index of to be updated node + final nodeIndex = settings.ui.nodes.indexOf(node!); + // update list of nodes to iclude updated node + final newList = settings.ui.nodes.rebuild((p0) => p0 + ..removeAt(nodeIndex) + ..insert(nodeIndex, updatedNode!)); + // update settings' node + final newSettings = settings.rebuild((p0) => p0..ui.nodes.replace(newList)); + return newSettings; + } + + /// Generate nested map from [path] with [value] + Map generateNestedMap(String path, String? value) { + var steps = path.split('.'); + Object? result = value; + for (var step in steps.reversed) { + // if value is null, set to an empty string + result = {step: result ?? ''}; + } + return result as Map; + } +} diff --git a/flutter-ory-network/lib/services/auth.dart b/flutter-ory-network/lib/services/auth.dart new file mode 100644 index 00000000..b665e1f0 --- /dev/null +++ b/flutter-ory-network/lib/services/auth.dart @@ -0,0 +1,570 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:built_value/json_object.dart'; +import 'package:dio/dio.dart'; +import 'package:one_of/one_of.dart'; +import 'package:ory_client/ory_client.dart'; +import 'exceptions.dart'; +import 'storage.dart'; + +class AuthService { + final _storage = SecureStorage(); + final FrontendApi _ory; + AuthService(Dio dio) : _ory = OryClient(dio: dio).getFrontendApi(); + + /// Get current session information + Future getCurrentSessionInformation() async { + try { + final token = await _storage.getToken(); + final response = await _ory.toSession(xSessionToken: token); + + if (response.data != null) { + // return session + return response.data!; + } else { + throw const CustomException.unknown(); + } + } on DioException catch (e) { + if (e.response?.statusCode == 401) { + await _storage.deleteToken(); + throw const CustomException.unauthorized(); + } else if (e.response?.statusCode == 403) { + if (e.response?.data['error']['id'] == 'session_aal2_required') { + throw const CustomException.twoFactorAuthRequired(); + } else { + throw _handleUnknownException(e.response?.data); + } + } else { + throw _handleUnknownException(e.response?.data); + } + } + } + + /// Create login flow + Future createLoginFlow( + {required String aal, required bool refresh}) async { + try { + final token = await _storage.getToken(); + final response = await _ory.createNativeLoginFlow( + aal: aal, + refresh: refresh, + xSessionToken: token, + returnSessionTokenExchangeCode: true, + returnTo: 'ory://flutter-ory-network'); + if (response.data != null) { + // return flow + return response.data!; + } else { + throw const CustomException.unknown(); + } + } on DioException catch (e) { + throw _handleUnknownException(e.response?.data); + } + } + + /// Create registration flow + Future createRegistrationFlow() async { + try { + final response = await _ory.createNativeRegistrationFlow( + returnSessionTokenExchangeCode: true, + returnTo: 'ory://flutter-ory-network'); + if (response.data != null) { + // return flow + return response.data!; + } else { + throw const CustomException.unknown(); + } + } on DioException catch (e) { + throw _handleUnknownException(e.response?.data); + } + } + + /// Create recovery flow + Future createRecoveryFlow() async { + try { + final response = await _ory.createNativeRecoveryFlow(); + if (response.data != null) { + // return flow + return response.data!; + } else { + throw const CustomException.unknown(); + } + } on DioException catch (e) { + throw _handleUnknownException(e.response?.data); + } + } + + /// Update login flow with [flowId] for [group] with [value] + Future updateLoginFlow( + {required String flowId, + required UiNodeGroupEnum group, + required Map value}) async { + try { + final token = await _storage.getToken(); + final OneOf oneOf; + + // create update body depending on method + switch (group) { + case UiNodeGroupEnum.password: + oneOf = OneOf.fromValue1( + value: UpdateLoginFlowWithPasswordMethod((b) => b + ..method = group.name + ..identifier = value['identifier'] + ..password = value['password'])); + case UiNodeGroupEnum.lookupSecret: + oneOf = OneOf.fromValue1( + value: UpdateLoginFlowWithLookupSecretMethod((b) => b + // use pre-defined string as enum value doesn't include an underscore + ..method = 'lookup_secret' + ..lookupSecret = value['lookup_secret'])); + case UiNodeGroupEnum.totp: + oneOf = OneOf.fromValue1( + value: UpdateLoginFlowWithTotpMethod((b) => b + ..method = group.name + ..totpCode = value['totp_code'])); + case UiNodeGroupEnum.oidc: + oneOf = OneOf.fromValue1( + value: UpdateLoginFlowWithOidcMethod((b) => b + ..method = group.name + ..provider = value['provider'] + ..idToken = value['id_token'] + ..idTokenNonce = value['nonce'])); + case UiNodeGroupEnum.code: + oneOf = OneOf.fromValue1( + value: UpdateLoginFlowWithCodeMethod((b) => b + ..csrfToken = '' + ..method = group.name + ..identifier = value['identifier'] + ..code = value['resend'] != null ? null : value['code'] + ..resend = value['resend'])); + + // if method is not implemented, throw exception + default: + throw const CustomException.unknown(); + } + + final response = await _ory.updateLoginFlow( + flow: flowId, + xSessionToken: token, + updateLoginFlowBody: UpdateLoginFlowBody((b) => b..oneOf = oneOf)); + + if (response.data?.session != null) { + // save session token after successful login + await _storage.persistToken(response.data!.sessionToken!); + if (response.data!.session.identity != null) { + return response.data!.session; + } else { + // identity is null, aal2 is required + throw const CustomException.twoFactorAuthRequired(); + } + } else { + throw const CustomException.unknown(); + } + } on DioException catch (e) { + if (e.response?.statusCode == 401) { + await _storage.deleteToken(); + throw const CustomException.unauthorized(); + } else if (e.response?.statusCode == 400) { + final loginFlow = standardSerializers.deserializeWith( + LoginFlow.serializer, e.response?.data); + if (loginFlow != null) { + throw CustomException.badRequest(flow: loginFlow); + } else { + throw const CustomException.unknown(); + } + } else if (e.response?.statusCode == 410) { + // settings flow expired, use new flow id + throw CustomException.flowExpired( + flowId: e.response?.data['use_flow_id']); + } else if (e.response?.statusCode == 422) { + final error = e.response?.data['error']; + if (error['id'] == 'browser_location_change_required') { + throw CustomException.locationChangeRequired( + url: e.response?.data['redirect_browser_to']); + } + throw const CustomException.unknown(); + } else { + throw _handleUnknownException(e.response?.data); + } + } + } + + /// Get login flow with [flowId] + Future getLoginFlow({required String flowId}) async { + try { + final response = await _ory.getLoginFlow(id: flowId); + + if (response.data != null) { + // return flow + return response.data!; + } else { + throw const CustomException.unknown(); + } + } on DioException catch (e) { + if (e.response?.statusCode == 401) { + await _storage.deleteToken(); + throw const CustomException.unauthorized(); + } else if (e.response?.statusCode == 410) { + // settings flow expired, use new flow id and add error message + throw CustomException.flowExpired( + flowId: e.response?.data['use_flow_id']); + } else { + throw _handleUnknownException(e.response?.data); + } + } + } + + /// Get registration flow with [flowId] + Future getRegistrationFlow({required String flowId}) async { + try { + final response = await _ory.getRegistrationFlow(id: flowId); + + if (response.data != null) { + // return flow + return response.data!; + } else { + throw const CustomException.unknown(); + } + } on DioException catch (e) { + throw _handleUnknownException(e.response?.data); + } + } + + /// When using oidc flow with [flowId], excange [initCode] and [returnToCode] for a session token + Future exchangeCodesForSessionToken( + {required String flowId, + required String initCode, + required String returnToCode}) async { + try { + final response = await _ory.exchangeSessionToken( + initCode: initCode, returnToCode: returnToCode); + + if (response.data?.session != null) { + // save session token after successful login + await _storage.persistToken(response.data!.sessionToken!); + return response.data!.session; + } else { + throw const CustomException.unknown(); + } + } on DioException catch (e) { + throw _handleUnknownException(e.response?.data); + } + } + + /// Update registration flow with [flowId] for [group] with [value] + Future updateRegistrationFlow( + {required String flowId, + required UiNodeGroupEnum group, + required Map value}) async { + try { + final OneOf oneOf; + + // create update body depending on method + switch (group) { + case UiNodeGroupEnum.password: + oneOf = OneOf.fromValue1( + value: UpdateRegistrationFlowWithPasswordMethod((b) => b + ..method = group.name + ..traits = JsonObject(value['traits']) + ..password = value['password'])); + case UiNodeGroupEnum.oidc: + oneOf = OneOf.fromValue1( + value: UpdateRegistrationFlowWithOidcMethod((b) => b + ..method = group.name + ..provider = value['provider'] + ..idToken = value['id_token'] + ..idTokenNonce = value['nonce'])); + case UiNodeGroupEnum.code: + oneOf = OneOf.fromValue1( + value: UpdateRegistrationFlowWithCodeMethod((b) => b + ..csrfToken = '' + ..method = group.name + ..traits = JsonObject(value['traits']) + ..code = value['resend'] != null ? null : value['code'] + ..resend = value['resend'])); + + // if method is not implemented, throw exception + default: + throw const CustomException.unknown(); + } + + final response = await _ory.updateRegistrationFlow( + flow: flowId, + updateRegistrationFlowBody: + UpdateRegistrationFlowBody((b) => b..oneOf = oneOf)); + + if (response.data?.session != null) { + // save session token after successful login + await _storage.persistToken(response.data!.sessionToken!); + return response.data!.session!; + } else { + throw const CustomException.unknown(); + } + // dio throws exception 200 when logging in with google + } on DioException catch (e) { + // user tried to register with social sign in using already existing account + if (e.response?.statusCode == 200) { + final successfulLogin = standardSerializers.deserializeWith( + SuccessfulNativeLogin.serializer, e.response?.data); + if (successfulLogin?.session != null) { + // save session token after successful login + await _storage.persistToken(successfulLogin!.sessionToken!); + return successfulLogin.session; + } else { + throw const CustomException.unknown(); + } + } else if (e.response?.statusCode == 400) { + final registrationFlow = standardSerializers.deserializeWith( + RegistrationFlow.serializer, e.response?.data); + if (registrationFlow != null) { + throw CustomException.badRequest( + flow: registrationFlow); + } else { + throw const CustomException.unknown(); + } + } else if (e.response?.statusCode == 410) { + // settings flow expired, use new flow id and add error message + throw CustomException.flowExpired( + flowId: e.response?.data['use_flow_id']); + } else if (e.response?.statusCode == 422) { + final error = e.response?.data['error']; + if (error['id'] == 'browser_location_change_required') { + throw CustomException.locationChangeRequired( + url: e.response?.data['redirect_browser_to']); + } + throw const CustomException.unknown(); + } else { + throw _handleUnknownException(e.response?.data); + } + } catch (e) { + throw const CustomException.unknown(); + } + } + + /// Update recovery flow with [flowId] and [value] as body + Future updateRecoveryFlow( + {required String flowId, required Map value}) async { + try { + final oneOf = OneOf.fromValue1( + value: UpdateRecoveryFlowWithCodeMethod((b) => b + ..method = UpdateRecoveryFlowWithCodeMethodMethodEnum.code + ..email = value['email'] + ..code = value['code'])); + + final response = await _ory.updateRecoveryFlow( + flow: flowId, + updateRecoveryFlowBody: + UpdateRecoveryFlowBody((b) => b..oneOf = oneOf)); + if (response.data != null) { + if (response.data!.continueWith != null) { + // get session token from actions + final sessionTokenAction = response.data!.continueWith!.firstWhere( + (element) => + element.oneOf.isType(ContinueWithSetOrySessionToken)); + final token = + (sessionTokenAction.oneOf.value as ContinueWithSetOrySessionToken) + .orySessionToken; + // save session token + await _storage.persistToken(token); + // get flow id to redirect to settings and let the user change the password + final settingsFlowAction = response.data!.continueWith!.firstWhere( + (element) => element.oneOf.isType(ContinueWithSettingsUi)); + final settingsFlowId = + (settingsFlowAction.oneOf.value as ContinueWithSettingsUi) + .flow + .id; + throw CustomException.settingsRedirectRequired( + settingsFlowId: settingsFlowId); + } + return response.data!; + } else { + throw const CustomException.unknown(); + } + } on DioException catch (e) { + if (e.response?.statusCode == 400) { + final recoveryFlow = standardSerializers.deserializeWith( + RecoveryFlow.serializer, e.response?.data); + if (recoveryFlow != null) { + throw CustomException.badRequest(flow: recoveryFlow); + } else { + throw const CustomException.unknown(); + } + } else if (e.response?.statusCode == 410) { + // recovery flow expired, use new flow id and add error message + throw CustomException.flowExpired( + flowId: e.response?.data['use_flow_id']); + } else { + throw _handleUnknownException(e.response?.data); + } + } on CustomException catch (_) { + rethrow; + } catch (e) { + throw const CustomException.unknown(); + } + } + + Future logout() async { + try { + final token = await _storage.getToken(); + + final PerformNativeLogoutBody logoutBody = + PerformNativeLogoutBody((b) => b..sessionToken = token); + final response = + await _ory.performNativeLogout(performNativeLogoutBody: logoutBody); + if (response.statusCode == 204) { + await _storage.deleteToken(); + return; + } + } on DioException catch (e) { + if (e.response?.statusCode == 401) { + await _storage.deleteToken(); + throw const CustomException.unauthorized(); + } else { + throw _handleUnknownException(e.response?.data); + } + } + } + + /// Create settings flow + Future createSettingsFlow() async { + try { + final token = await _storage.getToken(); + final response = + await _ory.createNativeSettingsFlow(xSessionToken: token); + + if (response.data != null) { + // return flow + return response.data!; + } else { + throw const CustomException.unknown(); + } + } on DioException catch (e) { + if (e.response?.statusCode == 401) { + await _storage.deleteToken(); + throw const CustomException.unauthorized(); + } else { + throw _handleUnknownException(e.response?.data); + } + } + } + + /// Get settings flow with [flowId] + Future getSettingsFlow({required String flowId}) async { + try { + final token = await _storage.getToken(); + final response = + await _ory.getSettingsFlow(id: flowId, xSessionToken: token); + + if (response.data != null) { + // return flow + return response.data!; + } else { + throw const CustomException.unknown(); + } + } on DioException catch (e) { + if (e.response?.statusCode == 401) { + await _storage.deleteToken(); + throw const CustomException.unauthorized(); + } else if (e.response?.statusCode == 410) { + // settings flow expired, use new flow id + throw CustomException.flowExpired( + flowId: e.response?.data['use_flow_id']); + } else { + throw _handleUnknownException(e.response?.data); + } + } + } + + /// Update settings flow with [flowId] for [group] with [value] + Future updateSettingsFlow( + {required String flowId, + required UiNodeGroupEnum group, + required Map value}) async { + try { + final token = await _storage.getToken(); + final OneOf oneOf; + + // create update body depending on method + switch (group) { + case UiNodeGroupEnum.password: + oneOf = OneOf.fromValue1( + value: UpdateSettingsFlowWithPasswordMethod((b) => b + ..method = group.name + ..password = value['password'])); + case UiNodeGroupEnum.profile: + oneOf = OneOf.fromValue1( + value: UpdateSettingsFlowWithProfileMethod((b) => b + ..method = group.name + ..traits = JsonObject(value['traits']))); + case UiNodeGroupEnum.lookupSecret: + oneOf = OneOf.fromValue1( + value: UpdateSettingsFlowWithLookupMethod((b) => b + ..method = group.name + ..lookupSecretConfirm = + getBoolValue(value['lookup_secret_confirm']) + ..lookupSecretDisable = + getBoolValue(value['lookup_secret_disable']) + ..lookupSecretReveal = + getBoolValue(value['lookup_secret_reveal']) + ..lookupSecretRegenerate = + getBoolValue(value['lookup_secret_regenerate']))); + case UiNodeGroupEnum.totp: + oneOf = OneOf.fromValue1( + value: UpdateSettingsFlowWithTotpMethod((b) => b + ..method = group.name + ..totpCode = value['totp_code'] + ..totpUnlink = getBoolValue(value['totp_unlink']))); + // if method is not implemented, throw exception + default: + throw const CustomException.unknown(); + } + + final response = await _ory.updateSettingsFlow( + flow: flowId, + xSessionToken: token, + updateSettingsFlowBody: + UpdateSettingsFlowBody((b) => b..oneOf = oneOf)); + + if (response.data != null) { + // return updated settings flow + return response.data!; + } else { + throw const CustomException.unknown(); + } + } on DioException catch (e) { + if (e.response?.statusCode == 401) { + await _storage.deleteToken(); + throw const CustomException.unauthorized(); + } else if (e.response?.statusCode == 403) { + throw const CustomException.sessionRefreshRequired(); + } else if (e.response?.statusCode == 410) { + // settings flow expired, use new flow id and add error message + throw CustomException.flowExpired( + flowId: e.response?.data['use_flow_id']); + } else { + throw _handleUnknownException(e.response?.data); + } + } + } + + /// Get bool value of string [value] + bool? getBoolValue(String? value) { + if (value == null) { + return null; + } else { + return value == 'true' ? true : false; + } + } + + CustomException _handleUnknownException(Map? response) { + // use human-readable reason if response contains it, otherwise use default value + if (response != null && + response.containsKey('error') && + (response['error'] as Map).containsKey('reason')) { + return CustomException.unknown(message: response['error']['reason']); + } else { + return const CustomException.unknown(); + } + } +} diff --git a/flutter-ory-network/lib/services/exceptions.dart b/flutter-ory-network/lib/services/exceptions.dart new file mode 100644 index 00000000..553458d4 --- /dev/null +++ b/flutter-ory-network/lib/services/exceptions.dart @@ -0,0 +1,29 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:flutter/foundation.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:ory_client/ory_client.dart'; + +part 'exceptions.freezed.dart'; + +@freezed +sealed class CustomException with _$CustomException { + const CustomException._(); + const factory CustomException.sessionRefreshRequired({String? message}) = + SessionRefreshRequiredException; + const factory CustomException.badRequest({required T flow}) = + BadRequestException; + const factory CustomException.unauthorized() = UnauthorizedException; + const factory CustomException.flowExpired( + {required String flowId, String? message}) = FlowExpiredException; + const factory CustomException.twoFactorAuthRequired({Session? session}) = + TwoFactorAuthRequiredException; + const factory CustomException.locationChangeRequired({required String url}) = + LocationChangeRequiredException; + const factory CustomException.settingsRedirectRequired( + {String? settingsFlowId}) = settingsRedirectRequired; + const factory CustomException.unknown( + {@Default('An error occured. Please try again later.') + String message}) = UnknownException; +} diff --git a/flutter-ory-network/lib/services/exceptions.freezed.dart b/flutter-ory-network/lib/services/exceptions.freezed.dart new file mode 100644 index 00000000..89f2c2a9 --- /dev/null +++ b/flutter-ory-network/lib/services/exceptions.freezed.dart @@ -0,0 +1,1681 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'exceptions.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +/// @nodoc +mixin _$CustomException { + @optionalTypeArgs + TResult when({ + required TResult Function(String? message) sessionRefreshRequired, + required TResult Function(T flow) badRequest, + required TResult Function() unauthorized, + required TResult Function(String flowId, String? message) flowExpired, + required TResult Function(Session? session) twoFactorAuthRequired, + required TResult Function(String url) locationChangeRequired, + required TResult Function(String? settingsFlowId) settingsRedirectRequired, + required TResult Function(String message) unknown, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String? message)? sessionRefreshRequired, + TResult? Function(T flow)? badRequest, + TResult? Function()? unauthorized, + TResult? Function(String flowId, String? message)? flowExpired, + TResult? Function(Session? session)? twoFactorAuthRequired, + TResult? Function(String url)? locationChangeRequired, + TResult? Function(String? settingsFlowId)? settingsRedirectRequired, + TResult? Function(String message)? unknown, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String? message)? sessionRefreshRequired, + TResult Function(T flow)? badRequest, + TResult Function()? unauthorized, + TResult Function(String flowId, String? message)? flowExpired, + TResult Function(Session? session)? twoFactorAuthRequired, + TResult Function(String url)? locationChangeRequired, + TResult Function(String? settingsFlowId)? settingsRedirectRequired, + TResult Function(String message)? unknown, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(SessionRefreshRequiredException value) + sessionRefreshRequired, + required TResult Function(BadRequestException value) badRequest, + required TResult Function(UnauthorizedException value) unauthorized, + required TResult Function(FlowExpiredException value) flowExpired, + required TResult Function(TwoFactorAuthRequiredException value) + twoFactorAuthRequired, + required TResult Function(LocationChangeRequiredException value) + locationChangeRequired, + required TResult Function(settingsRedirectRequired value) + settingsRedirectRequired, + required TResult Function(UnknownException value) unknown, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SessionRefreshRequiredException value)? + sessionRefreshRequired, + TResult? Function(BadRequestException value)? badRequest, + TResult? Function(UnauthorizedException value)? unauthorized, + TResult? Function(FlowExpiredException value)? flowExpired, + TResult? Function(TwoFactorAuthRequiredException value)? + twoFactorAuthRequired, + TResult? Function(LocationChangeRequiredException value)? + locationChangeRequired, + TResult? Function(settingsRedirectRequired value)? + settingsRedirectRequired, + TResult? Function(UnknownException value)? unknown, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SessionRefreshRequiredException value)? + sessionRefreshRequired, + TResult Function(BadRequestException value)? badRequest, + TResult Function(UnauthorizedException value)? unauthorized, + TResult Function(FlowExpiredException value)? flowExpired, + TResult Function(TwoFactorAuthRequiredException value)? + twoFactorAuthRequired, + TResult Function(LocationChangeRequiredException value)? + locationChangeRequired, + TResult Function(settingsRedirectRequired value)? + settingsRedirectRequired, + TResult Function(UnknownException value)? unknown, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $CustomExceptionCopyWith { + factory $CustomExceptionCopyWith( + CustomException value, $Res Function(CustomException) then) = + _$CustomExceptionCopyWithImpl>; +} + +/// @nodoc +class _$CustomExceptionCopyWithImpl> + implements $CustomExceptionCopyWith { + _$CustomExceptionCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; +} + +/// @nodoc +abstract class _$$SessionRefreshRequiredExceptionImplCopyWith { + factory _$$SessionRefreshRequiredExceptionImplCopyWith( + _$SessionRefreshRequiredExceptionImpl value, + $Res Function(_$SessionRefreshRequiredExceptionImpl) then) = + __$$SessionRefreshRequiredExceptionImplCopyWithImpl; + @useResult + $Res call({String? message}); +} + +/// @nodoc +class __$$SessionRefreshRequiredExceptionImplCopyWithImpl + extends _$CustomExceptionCopyWithImpl> + implements _$$SessionRefreshRequiredExceptionImplCopyWith { + __$$SessionRefreshRequiredExceptionImplCopyWithImpl( + _$SessionRefreshRequiredExceptionImpl _value, + $Res Function(_$SessionRefreshRequiredExceptionImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = freezed, + }) { + return _then(_$SessionRefreshRequiredExceptionImpl( + message: freezed == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$SessionRefreshRequiredExceptionImpl + extends SessionRefreshRequiredException with DiagnosticableTreeMixin { + const _$SessionRefreshRequiredExceptionImpl({this.message}) : super._(); + + @override + final String? message; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { + return 'CustomException<$T>.sessionRefreshRequired(message: $message)'; + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty( + 'type', 'CustomException<$T>.sessionRefreshRequired')) + ..add(DiagnosticsProperty('message', message)); + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SessionRefreshRequiredExceptionImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$SessionRefreshRequiredExceptionImplCopyWith> + get copyWith => __$$SessionRefreshRequiredExceptionImplCopyWithImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String? message) sessionRefreshRequired, + required TResult Function(T flow) badRequest, + required TResult Function() unauthorized, + required TResult Function(String flowId, String? message) flowExpired, + required TResult Function(Session? session) twoFactorAuthRequired, + required TResult Function(String url) locationChangeRequired, + required TResult Function(String? settingsFlowId) settingsRedirectRequired, + required TResult Function(String message) unknown, + }) { + return sessionRefreshRequired(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String? message)? sessionRefreshRequired, + TResult? Function(T flow)? badRequest, + TResult? Function()? unauthorized, + TResult? Function(String flowId, String? message)? flowExpired, + TResult? Function(Session? session)? twoFactorAuthRequired, + TResult? Function(String url)? locationChangeRequired, + TResult? Function(String? settingsFlowId)? settingsRedirectRequired, + TResult? Function(String message)? unknown, + }) { + return sessionRefreshRequired?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String? message)? sessionRefreshRequired, + TResult Function(T flow)? badRequest, + TResult Function()? unauthorized, + TResult Function(String flowId, String? message)? flowExpired, + TResult Function(Session? session)? twoFactorAuthRequired, + TResult Function(String url)? locationChangeRequired, + TResult Function(String? settingsFlowId)? settingsRedirectRequired, + TResult Function(String message)? unknown, + required TResult orElse(), + }) { + if (sessionRefreshRequired != null) { + return sessionRefreshRequired(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SessionRefreshRequiredException value) + sessionRefreshRequired, + required TResult Function(BadRequestException value) badRequest, + required TResult Function(UnauthorizedException value) unauthorized, + required TResult Function(FlowExpiredException value) flowExpired, + required TResult Function(TwoFactorAuthRequiredException value) + twoFactorAuthRequired, + required TResult Function(LocationChangeRequiredException value) + locationChangeRequired, + required TResult Function(settingsRedirectRequired value) + settingsRedirectRequired, + required TResult Function(UnknownException value) unknown, + }) { + return sessionRefreshRequired(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SessionRefreshRequiredException value)? + sessionRefreshRequired, + TResult? Function(BadRequestException value)? badRequest, + TResult? Function(UnauthorizedException value)? unauthorized, + TResult? Function(FlowExpiredException value)? flowExpired, + TResult? Function(TwoFactorAuthRequiredException value)? + twoFactorAuthRequired, + TResult? Function(LocationChangeRequiredException value)? + locationChangeRequired, + TResult? Function(settingsRedirectRequired value)? + settingsRedirectRequired, + TResult? Function(UnknownException value)? unknown, + }) { + return sessionRefreshRequired?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SessionRefreshRequiredException value)? + sessionRefreshRequired, + TResult Function(BadRequestException value)? badRequest, + TResult Function(UnauthorizedException value)? unauthorized, + TResult Function(FlowExpiredException value)? flowExpired, + TResult Function(TwoFactorAuthRequiredException value)? + twoFactorAuthRequired, + TResult Function(LocationChangeRequiredException value)? + locationChangeRequired, + TResult Function(settingsRedirectRequired value)? + settingsRedirectRequired, + TResult Function(UnknownException value)? unknown, + required TResult orElse(), + }) { + if (sessionRefreshRequired != null) { + return sessionRefreshRequired(this); + } + return orElse(); + } +} + +abstract class SessionRefreshRequiredException extends CustomException { + const factory SessionRefreshRequiredException({final String? message}) = + _$SessionRefreshRequiredExceptionImpl; + const SessionRefreshRequiredException._() : super._(); + + String? get message; + @JsonKey(ignore: true) + _$$SessionRefreshRequiredExceptionImplCopyWith> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$BadRequestExceptionImplCopyWith { + factory _$$BadRequestExceptionImplCopyWith(_$BadRequestExceptionImpl value, + $Res Function(_$BadRequestExceptionImpl) then) = + __$$BadRequestExceptionImplCopyWithImpl; + @useResult + $Res call({T flow}); +} + +/// @nodoc +class __$$BadRequestExceptionImplCopyWithImpl + extends _$CustomExceptionCopyWithImpl> + implements _$$BadRequestExceptionImplCopyWith { + __$$BadRequestExceptionImplCopyWithImpl(_$BadRequestExceptionImpl _value, + $Res Function(_$BadRequestExceptionImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? flow = freezed, + }) { + return _then(_$BadRequestExceptionImpl( + flow: freezed == flow + ? _value.flow + : flow // ignore: cast_nullable_to_non_nullable + as T, + )); + } +} + +/// @nodoc + +class _$BadRequestExceptionImpl extends BadRequestException + with DiagnosticableTreeMixin { + const _$BadRequestExceptionImpl({required this.flow}) : super._(); + + @override + final T flow; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { + return 'CustomException<$T>.badRequest(flow: $flow)'; + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty('type', 'CustomException<$T>.badRequest')) + ..add(DiagnosticsProperty('flow', flow)); + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$BadRequestExceptionImpl && + const DeepCollectionEquality().equals(other.flow, flow)); + } + + @override + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(flow)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$BadRequestExceptionImplCopyWith> + get copyWith => __$$BadRequestExceptionImplCopyWithImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String? message) sessionRefreshRequired, + required TResult Function(T flow) badRequest, + required TResult Function() unauthorized, + required TResult Function(String flowId, String? message) flowExpired, + required TResult Function(Session? session) twoFactorAuthRequired, + required TResult Function(String url) locationChangeRequired, + required TResult Function(String? settingsFlowId) settingsRedirectRequired, + required TResult Function(String message) unknown, + }) { + return badRequest(flow); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String? message)? sessionRefreshRequired, + TResult? Function(T flow)? badRequest, + TResult? Function()? unauthorized, + TResult? Function(String flowId, String? message)? flowExpired, + TResult? Function(Session? session)? twoFactorAuthRequired, + TResult? Function(String url)? locationChangeRequired, + TResult? Function(String? settingsFlowId)? settingsRedirectRequired, + TResult? Function(String message)? unknown, + }) { + return badRequest?.call(flow); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String? message)? sessionRefreshRequired, + TResult Function(T flow)? badRequest, + TResult Function()? unauthorized, + TResult Function(String flowId, String? message)? flowExpired, + TResult Function(Session? session)? twoFactorAuthRequired, + TResult Function(String url)? locationChangeRequired, + TResult Function(String? settingsFlowId)? settingsRedirectRequired, + TResult Function(String message)? unknown, + required TResult orElse(), + }) { + if (badRequest != null) { + return badRequest(flow); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SessionRefreshRequiredException value) + sessionRefreshRequired, + required TResult Function(BadRequestException value) badRequest, + required TResult Function(UnauthorizedException value) unauthorized, + required TResult Function(FlowExpiredException value) flowExpired, + required TResult Function(TwoFactorAuthRequiredException value) + twoFactorAuthRequired, + required TResult Function(LocationChangeRequiredException value) + locationChangeRequired, + required TResult Function(settingsRedirectRequired value) + settingsRedirectRequired, + required TResult Function(UnknownException value) unknown, + }) { + return badRequest(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SessionRefreshRequiredException value)? + sessionRefreshRequired, + TResult? Function(BadRequestException value)? badRequest, + TResult? Function(UnauthorizedException value)? unauthorized, + TResult? Function(FlowExpiredException value)? flowExpired, + TResult? Function(TwoFactorAuthRequiredException value)? + twoFactorAuthRequired, + TResult? Function(LocationChangeRequiredException value)? + locationChangeRequired, + TResult? Function(settingsRedirectRequired value)? + settingsRedirectRequired, + TResult? Function(UnknownException value)? unknown, + }) { + return badRequest?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SessionRefreshRequiredException value)? + sessionRefreshRequired, + TResult Function(BadRequestException value)? badRequest, + TResult Function(UnauthorizedException value)? unauthorized, + TResult Function(FlowExpiredException value)? flowExpired, + TResult Function(TwoFactorAuthRequiredException value)? + twoFactorAuthRequired, + TResult Function(LocationChangeRequiredException value)? + locationChangeRequired, + TResult Function(settingsRedirectRequired value)? + settingsRedirectRequired, + TResult Function(UnknownException value)? unknown, + required TResult orElse(), + }) { + if (badRequest != null) { + return badRequest(this); + } + return orElse(); + } +} + +abstract class BadRequestException extends CustomException { + const factory BadRequestException({required final T flow}) = + _$BadRequestExceptionImpl; + const BadRequestException._() : super._(); + + T get flow; + @JsonKey(ignore: true) + _$$BadRequestExceptionImplCopyWith> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$UnauthorizedExceptionImplCopyWith { + factory _$$UnauthorizedExceptionImplCopyWith( + _$UnauthorizedExceptionImpl value, + $Res Function(_$UnauthorizedExceptionImpl) then) = + __$$UnauthorizedExceptionImplCopyWithImpl; +} + +/// @nodoc +class __$$UnauthorizedExceptionImplCopyWithImpl + extends _$CustomExceptionCopyWithImpl> + implements _$$UnauthorizedExceptionImplCopyWith { + __$$UnauthorizedExceptionImplCopyWithImpl( + _$UnauthorizedExceptionImpl _value, + $Res Function(_$UnauthorizedExceptionImpl) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$UnauthorizedExceptionImpl extends UnauthorizedException + with DiagnosticableTreeMixin { + const _$UnauthorizedExceptionImpl() : super._(); + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { + return 'CustomException<$T>.unauthorized()'; + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + .add(DiagnosticsProperty('type', 'CustomException<$T>.unauthorized')); + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$UnauthorizedExceptionImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String? message) sessionRefreshRequired, + required TResult Function(T flow) badRequest, + required TResult Function() unauthorized, + required TResult Function(String flowId, String? message) flowExpired, + required TResult Function(Session? session) twoFactorAuthRequired, + required TResult Function(String url) locationChangeRequired, + required TResult Function(String? settingsFlowId) settingsRedirectRequired, + required TResult Function(String message) unknown, + }) { + return unauthorized(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String? message)? sessionRefreshRequired, + TResult? Function(T flow)? badRequest, + TResult? Function()? unauthorized, + TResult? Function(String flowId, String? message)? flowExpired, + TResult? Function(Session? session)? twoFactorAuthRequired, + TResult? Function(String url)? locationChangeRequired, + TResult? Function(String? settingsFlowId)? settingsRedirectRequired, + TResult? Function(String message)? unknown, + }) { + return unauthorized?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String? message)? sessionRefreshRequired, + TResult Function(T flow)? badRequest, + TResult Function()? unauthorized, + TResult Function(String flowId, String? message)? flowExpired, + TResult Function(Session? session)? twoFactorAuthRequired, + TResult Function(String url)? locationChangeRequired, + TResult Function(String? settingsFlowId)? settingsRedirectRequired, + TResult Function(String message)? unknown, + required TResult orElse(), + }) { + if (unauthorized != null) { + return unauthorized(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SessionRefreshRequiredException value) + sessionRefreshRequired, + required TResult Function(BadRequestException value) badRequest, + required TResult Function(UnauthorizedException value) unauthorized, + required TResult Function(FlowExpiredException value) flowExpired, + required TResult Function(TwoFactorAuthRequiredException value) + twoFactorAuthRequired, + required TResult Function(LocationChangeRequiredException value) + locationChangeRequired, + required TResult Function(settingsRedirectRequired value) + settingsRedirectRequired, + required TResult Function(UnknownException value) unknown, + }) { + return unauthorized(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SessionRefreshRequiredException value)? + sessionRefreshRequired, + TResult? Function(BadRequestException value)? badRequest, + TResult? Function(UnauthorizedException value)? unauthorized, + TResult? Function(FlowExpiredException value)? flowExpired, + TResult? Function(TwoFactorAuthRequiredException value)? + twoFactorAuthRequired, + TResult? Function(LocationChangeRequiredException value)? + locationChangeRequired, + TResult? Function(settingsRedirectRequired value)? + settingsRedirectRequired, + TResult? Function(UnknownException value)? unknown, + }) { + return unauthorized?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SessionRefreshRequiredException value)? + sessionRefreshRequired, + TResult Function(BadRequestException value)? badRequest, + TResult Function(UnauthorizedException value)? unauthorized, + TResult Function(FlowExpiredException value)? flowExpired, + TResult Function(TwoFactorAuthRequiredException value)? + twoFactorAuthRequired, + TResult Function(LocationChangeRequiredException value)? + locationChangeRequired, + TResult Function(settingsRedirectRequired value)? + settingsRedirectRequired, + TResult Function(UnknownException value)? unknown, + required TResult orElse(), + }) { + if (unauthorized != null) { + return unauthorized(this); + } + return orElse(); + } +} + +abstract class UnauthorizedException extends CustomException { + const factory UnauthorizedException() = _$UnauthorizedExceptionImpl; + const UnauthorizedException._() : super._(); +} + +/// @nodoc +abstract class _$$FlowExpiredExceptionImplCopyWith { + factory _$$FlowExpiredExceptionImplCopyWith( + _$FlowExpiredExceptionImpl value, + $Res Function(_$FlowExpiredExceptionImpl) then) = + __$$FlowExpiredExceptionImplCopyWithImpl; + @useResult + $Res call({String flowId, String? message}); +} + +/// @nodoc +class __$$FlowExpiredExceptionImplCopyWithImpl + extends _$CustomExceptionCopyWithImpl> + implements _$$FlowExpiredExceptionImplCopyWith { + __$$FlowExpiredExceptionImplCopyWithImpl(_$FlowExpiredExceptionImpl _value, + $Res Function(_$FlowExpiredExceptionImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? flowId = null, + Object? message = freezed, + }) { + return _then(_$FlowExpiredExceptionImpl( + flowId: null == flowId + ? _value.flowId + : flowId // ignore: cast_nullable_to_non_nullable + as String, + message: freezed == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$FlowExpiredExceptionImpl extends FlowExpiredException + with DiagnosticableTreeMixin { + const _$FlowExpiredExceptionImpl({required this.flowId, this.message}) + : super._(); + + @override + final String flowId; + @override + final String? message; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { + return 'CustomException<$T>.flowExpired(flowId: $flowId, message: $message)'; + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty('type', 'CustomException<$T>.flowExpired')) + ..add(DiagnosticsProperty('flowId', flowId)) + ..add(DiagnosticsProperty('message', message)); + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$FlowExpiredExceptionImpl && + (identical(other.flowId, flowId) || other.flowId == flowId) && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, flowId, message); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$FlowExpiredExceptionImplCopyWith> + get copyWith => __$$FlowExpiredExceptionImplCopyWithImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String? message) sessionRefreshRequired, + required TResult Function(T flow) badRequest, + required TResult Function() unauthorized, + required TResult Function(String flowId, String? message) flowExpired, + required TResult Function(Session? session) twoFactorAuthRequired, + required TResult Function(String url) locationChangeRequired, + required TResult Function(String? settingsFlowId) settingsRedirectRequired, + required TResult Function(String message) unknown, + }) { + return flowExpired(flowId, message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String? message)? sessionRefreshRequired, + TResult? Function(T flow)? badRequest, + TResult? Function()? unauthorized, + TResult? Function(String flowId, String? message)? flowExpired, + TResult? Function(Session? session)? twoFactorAuthRequired, + TResult? Function(String url)? locationChangeRequired, + TResult? Function(String? settingsFlowId)? settingsRedirectRequired, + TResult? Function(String message)? unknown, + }) { + return flowExpired?.call(flowId, message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String? message)? sessionRefreshRequired, + TResult Function(T flow)? badRequest, + TResult Function()? unauthorized, + TResult Function(String flowId, String? message)? flowExpired, + TResult Function(Session? session)? twoFactorAuthRequired, + TResult Function(String url)? locationChangeRequired, + TResult Function(String? settingsFlowId)? settingsRedirectRequired, + TResult Function(String message)? unknown, + required TResult orElse(), + }) { + if (flowExpired != null) { + return flowExpired(flowId, message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SessionRefreshRequiredException value) + sessionRefreshRequired, + required TResult Function(BadRequestException value) badRequest, + required TResult Function(UnauthorizedException value) unauthorized, + required TResult Function(FlowExpiredException value) flowExpired, + required TResult Function(TwoFactorAuthRequiredException value) + twoFactorAuthRequired, + required TResult Function(LocationChangeRequiredException value) + locationChangeRequired, + required TResult Function(settingsRedirectRequired value) + settingsRedirectRequired, + required TResult Function(UnknownException value) unknown, + }) { + return flowExpired(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SessionRefreshRequiredException value)? + sessionRefreshRequired, + TResult? Function(BadRequestException value)? badRequest, + TResult? Function(UnauthorizedException value)? unauthorized, + TResult? Function(FlowExpiredException value)? flowExpired, + TResult? Function(TwoFactorAuthRequiredException value)? + twoFactorAuthRequired, + TResult? Function(LocationChangeRequiredException value)? + locationChangeRequired, + TResult? Function(settingsRedirectRequired value)? + settingsRedirectRequired, + TResult? Function(UnknownException value)? unknown, + }) { + return flowExpired?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SessionRefreshRequiredException value)? + sessionRefreshRequired, + TResult Function(BadRequestException value)? badRequest, + TResult Function(UnauthorizedException value)? unauthorized, + TResult Function(FlowExpiredException value)? flowExpired, + TResult Function(TwoFactorAuthRequiredException value)? + twoFactorAuthRequired, + TResult Function(LocationChangeRequiredException value)? + locationChangeRequired, + TResult Function(settingsRedirectRequired value)? + settingsRedirectRequired, + TResult Function(UnknownException value)? unknown, + required TResult orElse(), + }) { + if (flowExpired != null) { + return flowExpired(this); + } + return orElse(); + } +} + +abstract class FlowExpiredException extends CustomException { + const factory FlowExpiredException( + {required final String flowId, + final String? message}) = _$FlowExpiredExceptionImpl; + const FlowExpiredException._() : super._(); + + String get flowId; + String? get message; + @JsonKey(ignore: true) + _$$FlowExpiredExceptionImplCopyWith> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$TwoFactorAuthRequiredExceptionImplCopyWith { + factory _$$TwoFactorAuthRequiredExceptionImplCopyWith( + _$TwoFactorAuthRequiredExceptionImpl value, + $Res Function(_$TwoFactorAuthRequiredExceptionImpl) then) = + __$$TwoFactorAuthRequiredExceptionImplCopyWithImpl; + @useResult + $Res call({Session? session}); +} + +/// @nodoc +class __$$TwoFactorAuthRequiredExceptionImplCopyWithImpl + extends _$CustomExceptionCopyWithImpl> + implements _$$TwoFactorAuthRequiredExceptionImplCopyWith { + __$$TwoFactorAuthRequiredExceptionImplCopyWithImpl( + _$TwoFactorAuthRequiredExceptionImpl _value, + $Res Function(_$TwoFactorAuthRequiredExceptionImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? session = freezed, + }) { + return _then(_$TwoFactorAuthRequiredExceptionImpl( + session: freezed == session + ? _value.session + : session // ignore: cast_nullable_to_non_nullable + as Session?, + )); + } +} + +/// @nodoc + +class _$TwoFactorAuthRequiredExceptionImpl + extends TwoFactorAuthRequiredException with DiagnosticableTreeMixin { + const _$TwoFactorAuthRequiredExceptionImpl({this.session}) : super._(); + + @override + final Session? session; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { + return 'CustomException<$T>.twoFactorAuthRequired(session: $session)'; + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty( + 'type', 'CustomException<$T>.twoFactorAuthRequired')) + ..add(DiagnosticsProperty('session', session)); + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$TwoFactorAuthRequiredExceptionImpl && + (identical(other.session, session) || other.session == session)); + } + + @override + int get hashCode => Object.hash(runtimeType, session); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$TwoFactorAuthRequiredExceptionImplCopyWith> + get copyWith => __$$TwoFactorAuthRequiredExceptionImplCopyWithImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String? message) sessionRefreshRequired, + required TResult Function(T flow) badRequest, + required TResult Function() unauthorized, + required TResult Function(String flowId, String? message) flowExpired, + required TResult Function(Session? session) twoFactorAuthRequired, + required TResult Function(String url) locationChangeRequired, + required TResult Function(String? settingsFlowId) settingsRedirectRequired, + required TResult Function(String message) unknown, + }) { + return twoFactorAuthRequired(session); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String? message)? sessionRefreshRequired, + TResult? Function(T flow)? badRequest, + TResult? Function()? unauthorized, + TResult? Function(String flowId, String? message)? flowExpired, + TResult? Function(Session? session)? twoFactorAuthRequired, + TResult? Function(String url)? locationChangeRequired, + TResult? Function(String? settingsFlowId)? settingsRedirectRequired, + TResult? Function(String message)? unknown, + }) { + return twoFactorAuthRequired?.call(session); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String? message)? sessionRefreshRequired, + TResult Function(T flow)? badRequest, + TResult Function()? unauthorized, + TResult Function(String flowId, String? message)? flowExpired, + TResult Function(Session? session)? twoFactorAuthRequired, + TResult Function(String url)? locationChangeRequired, + TResult Function(String? settingsFlowId)? settingsRedirectRequired, + TResult Function(String message)? unknown, + required TResult orElse(), + }) { + if (twoFactorAuthRequired != null) { + return twoFactorAuthRequired(session); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SessionRefreshRequiredException value) + sessionRefreshRequired, + required TResult Function(BadRequestException value) badRequest, + required TResult Function(UnauthorizedException value) unauthorized, + required TResult Function(FlowExpiredException value) flowExpired, + required TResult Function(TwoFactorAuthRequiredException value) + twoFactorAuthRequired, + required TResult Function(LocationChangeRequiredException value) + locationChangeRequired, + required TResult Function(settingsRedirectRequired value) + settingsRedirectRequired, + required TResult Function(UnknownException value) unknown, + }) { + return twoFactorAuthRequired(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SessionRefreshRequiredException value)? + sessionRefreshRequired, + TResult? Function(BadRequestException value)? badRequest, + TResult? Function(UnauthorizedException value)? unauthorized, + TResult? Function(FlowExpiredException value)? flowExpired, + TResult? Function(TwoFactorAuthRequiredException value)? + twoFactorAuthRequired, + TResult? Function(LocationChangeRequiredException value)? + locationChangeRequired, + TResult? Function(settingsRedirectRequired value)? + settingsRedirectRequired, + TResult? Function(UnknownException value)? unknown, + }) { + return twoFactorAuthRequired?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SessionRefreshRequiredException value)? + sessionRefreshRequired, + TResult Function(BadRequestException value)? badRequest, + TResult Function(UnauthorizedException value)? unauthorized, + TResult Function(FlowExpiredException value)? flowExpired, + TResult Function(TwoFactorAuthRequiredException value)? + twoFactorAuthRequired, + TResult Function(LocationChangeRequiredException value)? + locationChangeRequired, + TResult Function(settingsRedirectRequired value)? + settingsRedirectRequired, + TResult Function(UnknownException value)? unknown, + required TResult orElse(), + }) { + if (twoFactorAuthRequired != null) { + return twoFactorAuthRequired(this); + } + return orElse(); + } +} + +abstract class TwoFactorAuthRequiredException extends CustomException { + const factory TwoFactorAuthRequiredException({final Session? session}) = + _$TwoFactorAuthRequiredExceptionImpl; + const TwoFactorAuthRequiredException._() : super._(); + + Session? get session; + @JsonKey(ignore: true) + _$$TwoFactorAuthRequiredExceptionImplCopyWith> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$LocationChangeRequiredExceptionImplCopyWith { + factory _$$LocationChangeRequiredExceptionImplCopyWith( + _$LocationChangeRequiredExceptionImpl value, + $Res Function(_$LocationChangeRequiredExceptionImpl) then) = + __$$LocationChangeRequiredExceptionImplCopyWithImpl; + @useResult + $Res call({String url}); +} + +/// @nodoc +class __$$LocationChangeRequiredExceptionImplCopyWithImpl + extends _$CustomExceptionCopyWithImpl> + implements _$$LocationChangeRequiredExceptionImplCopyWith { + __$$LocationChangeRequiredExceptionImplCopyWithImpl( + _$LocationChangeRequiredExceptionImpl _value, + $Res Function(_$LocationChangeRequiredExceptionImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? url = null, + }) { + return _then(_$LocationChangeRequiredExceptionImpl( + url: null == url + ? _value.url + : url // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$LocationChangeRequiredExceptionImpl + extends LocationChangeRequiredException with DiagnosticableTreeMixin { + const _$LocationChangeRequiredExceptionImpl({required this.url}) : super._(); + + @override + final String url; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { + return 'CustomException<$T>.locationChangeRequired(url: $url)'; + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty( + 'type', 'CustomException<$T>.locationChangeRequired')) + ..add(DiagnosticsProperty('url', url)); + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$LocationChangeRequiredExceptionImpl && + (identical(other.url, url) || other.url == url)); + } + + @override + int get hashCode => Object.hash(runtimeType, url); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$LocationChangeRequiredExceptionImplCopyWith> + get copyWith => __$$LocationChangeRequiredExceptionImplCopyWithImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String? message) sessionRefreshRequired, + required TResult Function(T flow) badRequest, + required TResult Function() unauthorized, + required TResult Function(String flowId, String? message) flowExpired, + required TResult Function(Session? session) twoFactorAuthRequired, + required TResult Function(String url) locationChangeRequired, + required TResult Function(String? settingsFlowId) settingsRedirectRequired, + required TResult Function(String message) unknown, + }) { + return locationChangeRequired(url); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String? message)? sessionRefreshRequired, + TResult? Function(T flow)? badRequest, + TResult? Function()? unauthorized, + TResult? Function(String flowId, String? message)? flowExpired, + TResult? Function(Session? session)? twoFactorAuthRequired, + TResult? Function(String url)? locationChangeRequired, + TResult? Function(String? settingsFlowId)? settingsRedirectRequired, + TResult? Function(String message)? unknown, + }) { + return locationChangeRequired?.call(url); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String? message)? sessionRefreshRequired, + TResult Function(T flow)? badRequest, + TResult Function()? unauthorized, + TResult Function(String flowId, String? message)? flowExpired, + TResult Function(Session? session)? twoFactorAuthRequired, + TResult Function(String url)? locationChangeRequired, + TResult Function(String? settingsFlowId)? settingsRedirectRequired, + TResult Function(String message)? unknown, + required TResult orElse(), + }) { + if (locationChangeRequired != null) { + return locationChangeRequired(url); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SessionRefreshRequiredException value) + sessionRefreshRequired, + required TResult Function(BadRequestException value) badRequest, + required TResult Function(UnauthorizedException value) unauthorized, + required TResult Function(FlowExpiredException value) flowExpired, + required TResult Function(TwoFactorAuthRequiredException value) + twoFactorAuthRequired, + required TResult Function(LocationChangeRequiredException value) + locationChangeRequired, + required TResult Function(settingsRedirectRequired value) + settingsRedirectRequired, + required TResult Function(UnknownException value) unknown, + }) { + return locationChangeRequired(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SessionRefreshRequiredException value)? + sessionRefreshRequired, + TResult? Function(BadRequestException value)? badRequest, + TResult? Function(UnauthorizedException value)? unauthorized, + TResult? Function(FlowExpiredException value)? flowExpired, + TResult? Function(TwoFactorAuthRequiredException value)? + twoFactorAuthRequired, + TResult? Function(LocationChangeRequiredException value)? + locationChangeRequired, + TResult? Function(settingsRedirectRequired value)? + settingsRedirectRequired, + TResult? Function(UnknownException value)? unknown, + }) { + return locationChangeRequired?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SessionRefreshRequiredException value)? + sessionRefreshRequired, + TResult Function(BadRequestException value)? badRequest, + TResult Function(UnauthorizedException value)? unauthorized, + TResult Function(FlowExpiredException value)? flowExpired, + TResult Function(TwoFactorAuthRequiredException value)? + twoFactorAuthRequired, + TResult Function(LocationChangeRequiredException value)? + locationChangeRequired, + TResult Function(settingsRedirectRequired value)? + settingsRedirectRequired, + TResult Function(UnknownException value)? unknown, + required TResult orElse(), + }) { + if (locationChangeRequired != null) { + return locationChangeRequired(this); + } + return orElse(); + } +} + +abstract class LocationChangeRequiredException extends CustomException { + const factory LocationChangeRequiredException({required final String url}) = + _$LocationChangeRequiredExceptionImpl; + const LocationChangeRequiredException._() : super._(); + + String get url; + @JsonKey(ignore: true) + _$$LocationChangeRequiredExceptionImplCopyWith> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$settingsRedirectRequiredImplCopyWith { + factory _$$settingsRedirectRequiredImplCopyWith( + _$settingsRedirectRequiredImpl value, + $Res Function(_$settingsRedirectRequiredImpl) then) = + __$$settingsRedirectRequiredImplCopyWithImpl; + @useResult + $Res call({String? settingsFlowId}); +} + +/// @nodoc +class __$$settingsRedirectRequiredImplCopyWithImpl + extends _$CustomExceptionCopyWithImpl> + implements _$$settingsRedirectRequiredImplCopyWith { + __$$settingsRedirectRequiredImplCopyWithImpl( + _$settingsRedirectRequiredImpl _value, + $Res Function(_$settingsRedirectRequiredImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? settingsFlowId = freezed, + }) { + return _then(_$settingsRedirectRequiredImpl( + settingsFlowId: freezed == settingsFlowId + ? _value.settingsFlowId + : settingsFlowId // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc + +class _$settingsRedirectRequiredImpl extends settingsRedirectRequired + with DiagnosticableTreeMixin { + const _$settingsRedirectRequiredImpl({this.settingsFlowId}) : super._(); + + @override + final String? settingsFlowId; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { + return 'CustomException<$T>.settingsRedirectRequired(settingsFlowId: $settingsFlowId)'; + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty( + 'type', 'CustomException<$T>.settingsRedirectRequired')) + ..add(DiagnosticsProperty('settingsFlowId', settingsFlowId)); + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$settingsRedirectRequiredImpl && + (identical(other.settingsFlowId, settingsFlowId) || + other.settingsFlowId == settingsFlowId)); + } + + @override + int get hashCode => Object.hash(runtimeType, settingsFlowId); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$settingsRedirectRequiredImplCopyWith> + get copyWith => __$$settingsRedirectRequiredImplCopyWithImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String? message) sessionRefreshRequired, + required TResult Function(T flow) badRequest, + required TResult Function() unauthorized, + required TResult Function(String flowId, String? message) flowExpired, + required TResult Function(Session? session) twoFactorAuthRequired, + required TResult Function(String url) locationChangeRequired, + required TResult Function(String? settingsFlowId) settingsRedirectRequired, + required TResult Function(String message) unknown, + }) { + return settingsRedirectRequired(settingsFlowId); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String? message)? sessionRefreshRequired, + TResult? Function(T flow)? badRequest, + TResult? Function()? unauthorized, + TResult? Function(String flowId, String? message)? flowExpired, + TResult? Function(Session? session)? twoFactorAuthRequired, + TResult? Function(String url)? locationChangeRequired, + TResult? Function(String? settingsFlowId)? settingsRedirectRequired, + TResult? Function(String message)? unknown, + }) { + return settingsRedirectRequired?.call(settingsFlowId); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String? message)? sessionRefreshRequired, + TResult Function(T flow)? badRequest, + TResult Function()? unauthorized, + TResult Function(String flowId, String? message)? flowExpired, + TResult Function(Session? session)? twoFactorAuthRequired, + TResult Function(String url)? locationChangeRequired, + TResult Function(String? settingsFlowId)? settingsRedirectRequired, + TResult Function(String message)? unknown, + required TResult orElse(), + }) { + if (settingsRedirectRequired != null) { + return settingsRedirectRequired(settingsFlowId); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SessionRefreshRequiredException value) + sessionRefreshRequired, + required TResult Function(BadRequestException value) badRequest, + required TResult Function(UnauthorizedException value) unauthorized, + required TResult Function(FlowExpiredException value) flowExpired, + required TResult Function(TwoFactorAuthRequiredException value) + twoFactorAuthRequired, + required TResult Function(LocationChangeRequiredException value) + locationChangeRequired, + required TResult Function(settingsRedirectRequired value) + settingsRedirectRequired, + required TResult Function(UnknownException value) unknown, + }) { + return settingsRedirectRequired(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SessionRefreshRequiredException value)? + sessionRefreshRequired, + TResult? Function(BadRequestException value)? badRequest, + TResult? Function(UnauthorizedException value)? unauthorized, + TResult? Function(FlowExpiredException value)? flowExpired, + TResult? Function(TwoFactorAuthRequiredException value)? + twoFactorAuthRequired, + TResult? Function(LocationChangeRequiredException value)? + locationChangeRequired, + TResult? Function(settingsRedirectRequired value)? + settingsRedirectRequired, + TResult? Function(UnknownException value)? unknown, + }) { + return settingsRedirectRequired?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SessionRefreshRequiredException value)? + sessionRefreshRequired, + TResult Function(BadRequestException value)? badRequest, + TResult Function(UnauthorizedException value)? unauthorized, + TResult Function(FlowExpiredException value)? flowExpired, + TResult Function(TwoFactorAuthRequiredException value)? + twoFactorAuthRequired, + TResult Function(LocationChangeRequiredException value)? + locationChangeRequired, + TResult Function(settingsRedirectRequired value)? + settingsRedirectRequired, + TResult Function(UnknownException value)? unknown, + required TResult orElse(), + }) { + if (settingsRedirectRequired != null) { + return settingsRedirectRequired(this); + } + return orElse(); + } +} + +abstract class settingsRedirectRequired extends CustomException { + const factory settingsRedirectRequired({final String? settingsFlowId}) = + _$settingsRedirectRequiredImpl; + const settingsRedirectRequired._() : super._(); + + String? get settingsFlowId; + @JsonKey(ignore: true) + _$$settingsRedirectRequiredImplCopyWith> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$UnknownExceptionImplCopyWith { + factory _$$UnknownExceptionImplCopyWith(_$UnknownExceptionImpl value, + $Res Function(_$UnknownExceptionImpl) then) = + __$$UnknownExceptionImplCopyWithImpl; + @useResult + $Res call({String message}); +} + +/// @nodoc +class __$$UnknownExceptionImplCopyWithImpl + extends _$CustomExceptionCopyWithImpl> + implements _$$UnknownExceptionImplCopyWith { + __$$UnknownExceptionImplCopyWithImpl(_$UnknownExceptionImpl _value, + $Res Function(_$UnknownExceptionImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = null, + }) { + return _then(_$UnknownExceptionImpl( + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$UnknownExceptionImpl extends UnknownException + with DiagnosticableTreeMixin { + const _$UnknownExceptionImpl( + {this.message = 'An error occured. Please try again later.'}) + : super._(); + + @override + @JsonKey() + final String message; + + @override + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { + return 'CustomException<$T>.unknown(message: $message)'; + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty('type', 'CustomException<$T>.unknown')) + ..add(DiagnosticsProperty('message', message)); + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$UnknownExceptionImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$UnknownExceptionImplCopyWith> get copyWith => + __$$UnknownExceptionImplCopyWithImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String? message) sessionRefreshRequired, + required TResult Function(T flow) badRequest, + required TResult Function() unauthorized, + required TResult Function(String flowId, String? message) flowExpired, + required TResult Function(Session? session) twoFactorAuthRequired, + required TResult Function(String url) locationChangeRequired, + required TResult Function(String? settingsFlowId) settingsRedirectRequired, + required TResult Function(String message) unknown, + }) { + return unknown(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String? message)? sessionRefreshRequired, + TResult? Function(T flow)? badRequest, + TResult? Function()? unauthorized, + TResult? Function(String flowId, String? message)? flowExpired, + TResult? Function(Session? session)? twoFactorAuthRequired, + TResult? Function(String url)? locationChangeRequired, + TResult? Function(String? settingsFlowId)? settingsRedirectRequired, + TResult? Function(String message)? unknown, + }) { + return unknown?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String? message)? sessionRefreshRequired, + TResult Function(T flow)? badRequest, + TResult Function()? unauthorized, + TResult Function(String flowId, String? message)? flowExpired, + TResult Function(Session? session)? twoFactorAuthRequired, + TResult Function(String url)? locationChangeRequired, + TResult Function(String? settingsFlowId)? settingsRedirectRequired, + TResult Function(String message)? unknown, + required TResult orElse(), + }) { + if (unknown != null) { + return unknown(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(SessionRefreshRequiredException value) + sessionRefreshRequired, + required TResult Function(BadRequestException value) badRequest, + required TResult Function(UnauthorizedException value) unauthorized, + required TResult Function(FlowExpiredException value) flowExpired, + required TResult Function(TwoFactorAuthRequiredException value) + twoFactorAuthRequired, + required TResult Function(LocationChangeRequiredException value) + locationChangeRequired, + required TResult Function(settingsRedirectRequired value) + settingsRedirectRequired, + required TResult Function(UnknownException value) unknown, + }) { + return unknown(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(SessionRefreshRequiredException value)? + sessionRefreshRequired, + TResult? Function(BadRequestException value)? badRequest, + TResult? Function(UnauthorizedException value)? unauthorized, + TResult? Function(FlowExpiredException value)? flowExpired, + TResult? Function(TwoFactorAuthRequiredException value)? + twoFactorAuthRequired, + TResult? Function(LocationChangeRequiredException value)? + locationChangeRequired, + TResult? Function(settingsRedirectRequired value)? + settingsRedirectRequired, + TResult? Function(UnknownException value)? unknown, + }) { + return unknown?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(SessionRefreshRequiredException value)? + sessionRefreshRequired, + TResult Function(BadRequestException value)? badRequest, + TResult Function(UnauthorizedException value)? unauthorized, + TResult Function(FlowExpiredException value)? flowExpired, + TResult Function(TwoFactorAuthRequiredException value)? + twoFactorAuthRequired, + TResult Function(LocationChangeRequiredException value)? + locationChangeRequired, + TResult Function(settingsRedirectRequired value)? + settingsRedirectRequired, + TResult Function(UnknownException value)? unknown, + required TResult orElse(), + }) { + if (unknown != null) { + return unknown(this); + } + return orElse(); + } +} + +abstract class UnknownException extends CustomException { + const factory UnknownException({final String message}) = + _$UnknownExceptionImpl; + const UnknownException._() : super._(); + + String get message; + @JsonKey(ignore: true) + _$$UnknownExceptionImplCopyWith> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/flutter-ory-network/lib/services/storage.dart b/flutter-ory-network/lib/services/storage.dart new file mode 100644 index 00000000..bb4693b5 --- /dev/null +++ b/flutter-ory-network/lib/services/storage.dart @@ -0,0 +1,37 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; + +class SecureStorage { + static SecureStorage? _instance; + + factory SecureStorage() => + _instance ?? SecureStorage._(const FlutterSecureStorage()); + + SecureStorage._(this._storage); + + final FlutterSecureStorage _storage; + static const _tokenKey = 'TOKEN'; + + Future persistToken(String token) async { + await _storage.write(key: _tokenKey, value: token); + } + + Future hasToken() async { + var value = await _storage.read(key: _tokenKey); + return value != null; + } + + Future deleteToken() async { + return _storage.delete(key: _tokenKey); + } + + Future getToken() async { + return _storage.read(key: _tokenKey); + } + + Future deleteAll() async { + return _storage.deleteAll(); + } +} diff --git a/flutter-ory-network/lib/widgets/helpers.dart b/flutter-ory-network/lib/widgets/helpers.dart new file mode 100644 index 00000000..9bdbdc43 --- /dev/null +++ b/flutter-ory-network/lib/widgets/helpers.dart @@ -0,0 +1,174 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'dart:io'; + +import 'package:bloc/bloc.dart'; +import 'package:built_collection/built_collection.dart'; +import 'package:collection/collection.dart'; +import 'package:flutter/material.dart'; +import 'package:ory_client/ory_client.dart'; + +import '../blocs/auth/auth_bloc.dart'; +import 'nodes/image.dart'; +import 'nodes/input.dart'; +import 'nodes/input_submit.dart'; +import 'nodes/text.dart'; + +/// Returns color of a message depending on its [type] +getMessageColor(UiTextTypeEnum type) { + switch (type) { + case UiTextTypeEnum.success: + return Colors.green; + case UiTextTypeEnum.error: + return Colors.red; + case UiTextTypeEnum.info: + return Colors.grey; + } +} + +/// Returns error widget with corresponding [message] +buildFlowNotCreated(BuildContext context, String? message) { + if (message != null) { + return Center( + child: Text( + message, + style: const TextStyle(color: Colors.red), + )); + } else { + return const Center(child: CircularProgressIndicator()); + } +} + +/// Returns a form for a specific [group] containing multiple [nodes]. +/// Node changes and submits are handled by +/// [onInputChange] and [onInputSubmit], respectively +buildGroup( + BuildContext context, + UiNodeGroupEnum group, + List nodes, + void Function(BuildContext, String, String) onInputChange, + void Function(BuildContext, UiNodeGroupEnum, String, String) + onInputSubmit) { + final formKey = GlobalKey(); + return Padding( + padding: const EdgeInsets.only(bottom: 0), + child: Form( + key: formKey, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ListView.builder( + physics: const NeverScrollableScrollPhysics(), + padding: const EdgeInsets.only(bottom: 0), + shrinkWrap: true, + itemBuilder: ((BuildContext context, index) { + final attributes = nodes[index].attributes.oneOf; + if (attributes.isType(UiNodeInputAttributes)) { + return buildInputNode(context, formKey, nodes[index], + onInputChange, onInputSubmit); + } else if (attributes.isType(UiNodeTextAttributes)) { + return TextNode(node: nodes[index]); + } else if (attributes.isType(UiNodeImageAttributes)) { + return ImageNode(node: nodes[index]); + } else { + return Container(); + } + }), + itemCount: nodes.length), + ], + ), + ), + ); +} + +/// Returns input node for [node] from a form associated with [formKey]. +/// Node changes and submits are handled by +/// [onInputChange] and [onInputSubmit], respectively. +buildInputNode( + BuildContext context, + GlobalKey formKey, + UiNode node, + void Function(BuildContext, String, String) onInputChange, + void Function(BuildContext, UiNodeGroupEnum, String, String) + onInputSubmit) { + final attributes = asInputAttributes(node); + switch (attributes.type) { + case UiNodeInputAttributesTypeEnum.submit: + return InputSubmitNode( + node: node, + formKey: formKey, + onChange: onInputChange, + onSubmit: onInputSubmit); + case UiNodeInputAttributesTypeEnum.button: + return InputSubmitNode( + node: node, + formKey: formKey, + onChange: onInputChange, + onSubmit: onInputSubmit); + default: + return InputNode(node: node, onChange: onInputChange); + } +} + +/// Returns nodes with a type of [group] from all available [nodes] +List getNodesOfGroup(UiNodeGroupEnum group, BuiltList nodes) { + return nodes.where((node) { + if (node.group == group) { + if (group == UiNodeGroupEnum.oidc) { + if (isInputNode(node)) { + final attributes = asInputAttributes(node); + return Platform.isAndroid + ? !getInputNodeValue(attributes).contains('ios') + : getInputNodeValue(attributes).contains('ios'); + } + } else { + if (isInputNode(node)) { + final attributes = asInputAttributes(node); + if (attributes.type == UiNodeInputAttributesTypeEnum.hidden) { + return false; + } else { + return true; + } + } else { + return true; + } + } + } + return false; + }).toList(); +} + +/// Returns true if [node] is of type UiNodeInputAttributes. +/// Otherwise, returns false +bool isInputNode(UiNode node) { + return node.attributes.oneOf.isType(UiNodeInputAttributes); +} + +/// Returns string value of [attributes] +String getInputNodeValue(UiNodeInputAttributes attributes) { + return attributes.value?.asString ?? ''; +} + +/// Returns input attributes of a [node]. +/// Attributes must be of type UiNodeInputAttributes +UiNodeInputAttributes asInputAttributes(UiNode node) { + if (isInputNode(node)) { + return node.attributes.oneOf.value as UiNodeInputAttributes; + } else { + throw ArgumentError( + 'attributes of this node are not of type UiNodeInputAttributes'); + } +} + +bool isSessionRefreshRequired(List conditions) { + final sessionRefreshCondition = conditions + .firstWhereOrNull((element) => element is SessionRefreshRequested); + return sessionRefreshCondition != null; +} + +bool isRecoveryRequired(List conditions) { + final recoveryCondition = + conditions.firstWhereOrNull((element) => element is RecoveryRequested); + return recoveryCondition != null; +} diff --git a/flutter-ory-network/lib/widgets/nodes/image.dart b/flutter-ory-network/lib/widgets/nodes/image.dart new file mode 100644 index 00000000..b2e0756d --- /dev/null +++ b/flutter-ory-network/lib/widgets/nodes/image.dart @@ -0,0 +1,30 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'dart:convert'; +import 'dart:typed_data'; + +import 'package:flutter/material.dart'; +import 'package:ory_client/ory_client.dart'; + +class ImageNode extends StatelessWidget { + final UiNode node; + + const ImageNode({super.key, required this.node}); + + @override + Widget build(BuildContext context) { + final imageNode = node.attributes.oneOf.value as UiNodeImageAttributes; + // convert base64 string to bytes + Uint8List bytes = base64.decode(imageNode.src.split(',').last); + return Padding( + padding: const EdgeInsets.only(bottom: 20.0), + child: Center( + child: SizedBox( + width: imageNode.width.toDouble(), + height: imageNode.height.toDouble(), + child: Image.memory(bytes)), + ), + ); + } +} diff --git a/flutter-ory-network/lib/widgets/nodes/input.dart b/flutter-ory-network/lib/widgets/nodes/input.dart new file mode 100644 index 00000000..6111da92 --- /dev/null +++ b/flutter-ory-network/lib/widgets/nodes/input.dart @@ -0,0 +1,173 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:collection/collection.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:ory_client/ory_client.dart'; +import 'package:ory_network_flutter/blocs/bloc/recovery_bloc.dart'; +import 'package:ory_network_flutter/blocs/login/login_bloc.dart'; +import 'package:ory_network_flutter/blocs/registration/registration_bloc.dart'; + +import '../../blocs/settings/settings_bloc.dart'; +import '../helpers.dart'; + +class InputNode extends StatefulWidget { + final UiNode node; + final void Function(BuildContext, String, String) onChange; + + const InputNode({super.key, required this.node, required this.onChange}); + @override + State createState() => _InputNodeState(); +} + +class _InputNodeState extends State { + TextEditingController textEditingController = TextEditingController(); + bool? isPasswordHidden; + + @override + void initState() { + super.initState(); + final attributes = asInputAttributes(widget.node); + // if this is a password field, hide the text + if (attributes.name == 'password') { + setState(() { + isPasswordHidden = true; + }); + } + final fieldValue = attributes.value; + // assign node value to text controller on init + textEditingController.text = fieldValue != null ? fieldValue.asString : ''; + } + +// get text input type of a specific node + _getTextInputType(UiNodeInputAttributesTypeEnum type) { + switch (type) { + case UiNodeInputAttributesTypeEnum.datetimeLocal: + return TextInputType.datetime; + case UiNodeInputAttributesTypeEnum.email: + return TextInputType.emailAddress; + case UiNodeInputAttributesTypeEnum.hidden: + return TextInputType.none; + case UiNodeInputAttributesTypeEnum.number: + return TextInputType.number; + case UiNodeInputAttributesTypeEnum.password: + return TextInputType.text; + case UiNodeInputAttributesTypeEnum.tel: + return TextInputType.phone; + case UiNodeInputAttributesTypeEnum.text: + return TextInputType.text; + case UiNodeInputAttributesTypeEnum.url: + return TextInputType.url; + default: + return null; + } + } + + @override + Widget build(BuildContext context) { + final attributes = asInputAttributes(widget.node); + + return BlocListener( + bloc: (context).read(), + listener: (context, state) { + UiNode? node; + // find current node in updated state + if (state is LoginState) { + node = state.loginFlow?.ui.nodes.firstWhereOrNull((element) { + if (isInputNode(element)) { + return asInputAttributes(element).name == attributes.name; + } else { + return false; + } + }); + } else if (state is RegistrationState) { + node = state.registrationFlow?.ui.nodes.firstWhereOrNull((element) { + if (isInputNode(element)) { + return asInputAttributes(element).name == attributes.name; + } else { + return false; + } + }); + } else if (state is SettingsState) { + node = state.settingsFlow?.ui.nodes.firstWhereOrNull((element) { + if (element.attributes.oneOf.isType(UiNodeInputAttributes)) { + return (element.attributes.oneOf.value as UiNodeInputAttributes) + .name == + attributes.name; + } else { + return false; + } + }); + } else if (state is RecoveryState) { + node = state.recoveryFlow?.ui.nodes.firstWhereOrNull((element) { + if (element.attributes.oneOf.isType(UiNodeInputAttributes)) { + return (element.attributes.oneOf.value as UiNodeInputAttributes) + .name == + attributes.name; + } else { + return false; + } + }); + } + + // assign new value of node to text controller + if (node != null && isInputNode(node)) { + final attributes = asInputAttributes(node); + textEditingController.text = getInputNodeValue(attributes); + } + }, + child: Padding( + padding: const EdgeInsets.only(bottom: 20.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (widget.node.meta.label?.text != null) + Text( + widget.node.meta.label!.text, + style: const TextStyle(fontWeight: FontWeight.w600), + ), + const SizedBox( + height: 4, + ), + TextFormField( + controller: textEditingController, + enabled: !attributes.disabled, + keyboardType: _getTextInputType(attributes.type), + onChanged: (String value) { + widget.onChange(context, value, attributes.name); + }, + obscureText: isPasswordHidden ?? false, + decoration: isPasswordHidden == null + ? null + : InputDecoration( + suffixIcon: GestureDetector( + onTap: () => setState(() { + isPasswordHidden = !isPasswordHidden!; + }), + child: ImageIcon(isPasswordHidden! + ? const AssetImage('assets/icons/eye.png') + : const AssetImage('assets/icons/eye-off.png')), + )), + validator: (value) { + if (attributes.required_ != null) { + if (attributes.required_! && + (value == null || value.isEmpty)) { + return 'Property is required'; + } + } + return null; + }, + ), + for (var message in widget.node.messages) + Padding( + padding: const EdgeInsets.only(top: 20), + child: Text(message.text, + style: TextStyle(color: getMessageColor(message.type))), + ), + ], + ), + ), + ); + } +} diff --git a/flutter-ory-network/lib/widgets/nodes/input_submit.dart b/flutter-ory-network/lib/widgets/nodes/input_submit.dart new file mode 100644 index 00000000..f52e3423 --- /dev/null +++ b/flutter-ory-network/lib/widgets/nodes/input_submit.dart @@ -0,0 +1,74 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:flutter/material.dart'; +import 'package:ory_client/ory_client.dart'; +import 'package:ory_network_flutter/widgets/helpers.dart'; + +class InputSubmitNode extends StatelessWidget { + final GlobalKey formKey; + final UiNode node; + final void Function(BuildContext, String, String) onChange; + final void Function(BuildContext, UiNodeGroupEnum, String, String) onSubmit; + + const InputSubmitNode( + {super.key, + required this.formKey, + required this.node, + required this.onChange, + required this.onSubmit}); + + @override + Widget build(BuildContext context) { + final attributes = asInputAttributes(node); + final value = getInputNodeValue(attributes); + final provider = _getProviderName(value); + return SizedBox( + width: double.infinity, + child: node.group == UiNodeGroupEnum.oidc + ? OutlinedButton.icon( + icon: Image.asset( + 'assets/images/flows-auth-buttons-social-$provider.png'), + label: Text(node.meta.label?.text ?? ''), + onPressed: () => onPressed(context), + ) + : FilledButton( + // validate input fields that belong to this buttons group + onPressed: () => onPressed(context), + child: Text(node.meta.label?.text ?? ''), + ), + ); + } + + _getProviderName(String? value) { + if (value == null) { + return ''; + } else if (value.contains('google')) { + return 'google'; + } else if (value.contains('apple')) { + return 'apple'; + } else { + return ''; + } + } + + onPressed(BuildContext context) { + final attributes = asInputAttributes(node); + + // if attribute is method, validate the form + if ((attributes.name == 'method' && formKey.currentState!.validate()) || + attributes.name != 'method') { + final type = attributes.type; + // if attribute type is a button with value 'false', set its value to true on submit + if (type == UiNodeInputAttributesTypeEnum.button || + type == UiNodeInputAttributesTypeEnum.submit && + attributes.value?.value == 'false') { + final nodeName = attributes.name; + + onChange(context, 'true', nodeName); + } + onSubmit(context, node.group, attributes.name, + attributes.value!.isString ? attributes.value!.asString : ''); + } + } +} diff --git a/flutter-ory-network/lib/widgets/nodes/text.dart b/flutter-ory-network/lib/widgets/nodes/text.dart new file mode 100644 index 00000000..18bf9eba --- /dev/null +++ b/flutter-ory-network/lib/widgets/nodes/text.dart @@ -0,0 +1,28 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:flutter/material.dart'; +import 'package:ory_client/ory_client.dart'; + +class TextNode extends StatelessWidget { + final UiNode node; + + const TextNode({super.key, required this.node}); + @override + Widget build(BuildContext context) { + final attributes = node.attributes.oneOf.value as UiNodeTextAttributes; + return Padding( + padding: const EdgeInsets.only(bottom: 20.0), + child: Column( + children: [ + // show label test if it is available + if (node.meta.label?.text != null) Text(node.meta.label!.text), + const SizedBox( + height: 10, + ), + Text(attributes.text.text), + ], + ), + ); + } +} diff --git a/flutter-ory-network/lib/widgets/ory_theme.dart b/flutter-ory-network/lib/widgets/ory_theme.dart new file mode 100644 index 00000000..4cb3ae74 --- /dev/null +++ b/flutter-ory-network/lib/widgets/ory_theme.dart @@ -0,0 +1,94 @@ +// Copyright © 2025 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +class OryTheme { + OryTheme._(); + + static const Color primaryColor = Color(0xFF1E293B); + static const Color linkColor = Color(0xFF4F46E5); + static const Color errorColor = Color(0xFFEF4444); + static const Color formDefaultColor = Color(0xFF64748B); + static const Color formBorderColor = Color(0xFFE2E8F0); + static const Color formBorderFocusColor = Color(0xFF0F172A); + + static MaterialColor primaryColorSwatch = MaterialColor( + primaryColor.value, + const { + 50: Color(0xFF1E293B), + 100: Color(0xFF1E293B), + 200: Color(0xFF1E293B), + 300: Color(0xFF1E293B), + 400: Color(0xFF1E293B), + 500: Color(0xFF1E293B), + 600: Color(0xFF1E293B), + 700: Color(0xFF1E293B), + 800: Color(0xFF1E293B), + 900: Color(0xFF1E293B), + }, + ); + + static const InputDecorationTheme textFieldTheme = InputDecorationTheme( + contentPadding: EdgeInsets.symmetric(vertical: 10, horizontal: 12), + hintStyle: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w400, + height: 1.25, + color: formDefaultColor), + errorStyle: TextStyle(color: errorColor), + suffixIconColor: formDefaultColor, + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(width: 1, color: formBorderFocusColor)), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(width: 1, color: formBorderColor), + ), + errorBorder: OutlineInputBorder( + borderSide: BorderSide(width: 1, color: errorColor)), + focusedErrorBorder: OutlineInputBorder( + borderSide: BorderSide(width: 1, color: errorColor))); + +// buttons + static final TextButtonThemeData textButtonThemeData = TextButtonThemeData( + style: ButtonStyle( + visualDensity: VisualDensity.compact, + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + padding: MaterialStateProperty.all( + EdgeInsets.zero, + ), + foregroundColor: MaterialStateProperty.all(linkColor), + textStyle: MaterialStateProperty.all(const TextStyle( + fontSize: 14, fontWeight: FontWeight.w500, height: 1.5)), + )); + + static final FilledButtonThemeData filledButtonThemeData = + FilledButtonThemeData( + style: ButtonStyle( + padding: MaterialStateProperty.all( + const EdgeInsets.symmetric(vertical: 12, horizontal: 16)), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4.0))))); + + static final OutlinedButtonThemeData outlinedButtonThemeData = + OutlinedButtonThemeData( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all(Colors.white), + padding: MaterialStateProperty.all( + const EdgeInsets.symmetric(vertical: 12, horizontal: 16)), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4.0))))); + + static final ThemeData defaultTheme = ThemeData( + primarySwatch: primaryColorSwatch, + fontFamily: GoogleFonts.getFont('Inter').fontFamily, + textButtonTheme: textButtonThemeData, + appBarTheme: + const AppBarTheme(iconTheme: IconThemeData(color: primaryColor)), + filledButtonTheme: filledButtonThemeData, + outlinedButtonTheme: outlinedButtonThemeData, + inputDecorationTheme: textFieldTheme, + ); +} diff --git a/flutter-ory-network/pubspec.lock b/flutter-ory-network/pubspec.lock new file mode 100644 index 00000000..8d141116 --- /dev/null +++ b/flutter-ory-network/pubspec.lock @@ -0,0 +1,922 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: c209688d9f5a5f26b2fb47a188131a6fb9e876ae9e47af3737c0b4f58a93470d + url: "https://pub.dev" + source: hosted + version: "91.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: f51c8499b35f9b26820cfe914828a6a98a94efd5cc78b37bb7d03debae3a1d08 + url: "https://pub.dev" + source: hosted + version: "8.4.1" + args: + dependency: transitive + description: + name: args + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 + url: "https://pub.dev" + source: hosted + version: "2.7.0" + async: + dependency: transitive + description: + name: async + sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + url: "https://pub.dev" + source: hosted + version: "2.13.0" + bloc: + dependency: "direct main" + description: + name: bloc + sha256: a2cebb899f91d36eeeaa55c7b20b5915db5a9df1b8fd4a3c9c825e22e474537d + url: "https://pub.dev" + source: hosted + version: "9.1.0" + bloc_concurrency: + dependency: "direct main" + description: + name: bloc_concurrency + sha256: "86b7b17a0a78f77fca0d7c030632b59b593b22acea2d96972588f40d4ef53a94" + url: "https://pub.dev" + source: hosted + version: "0.3.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + build: + dependency: transitive + description: + name: build + sha256: c1668065e9ba04752570ad7e038288559d1e2ca5c6d0131c0f5f55e39e777413 + url: "https://pub.dev" + source: hosted + version: "4.0.3" + build_config: + dependency: transitive + description: + name: build_config + sha256: "4f64382b97504dc2fcdf487d5aae33418e08b4703fc21249e4db6d804a4d0187" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: bf05f6e12cfea92d3c09308d7bcdab1906cd8a179b023269eed00c071004b957 + url: "https://pub.dev" + source: hosted + version: "4.1.1" + build_runner: + dependency: "direct dev" + description: + name: build_runner + sha256: "110c56ef29b5eb367b4d17fc79375fa8c18a6cd7acd92c05bb3986c17a079057" + url: "https://pub.dev" + source: hosted + version: "2.10.4" + built_collection: + dependency: "direct main" + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: "direct main" + description: + name: built_value + sha256: "426cf75afdb23aa74bd4e471704de3f9393f3c7b04c1e2d9c6f1073ae0b8b139" + url: "https://pub.dev" + source: hosted + version: "8.12.1" + characters: + dependency: transitive + description: + name: characters + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: "959525d3162f249993882720d52b7e0c833978df229be20702b33d48d91de70f" + url: "https://pub.dev" + source: hosted + version: "2.0.4" + clock: + dependency: transitive + description: + name: clock + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" + source: hosted + version: "1.1.2" + code_builder: + dependency: transitive + description: + name: code_builder + sha256: "11654819532ba94c34de52ff5feb52bd81cba1de00ef2ed622fd50295f9d4243" + url: "https://pub.dev" + source: hosted + version: "4.11.0" + collection: + dependency: "direct main" + description: + name: collection + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" + source: hosted + version: "1.19.1" + convert: + dependency: transitive + description: + name: convert + sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68 + url: "https://pub.dev" + source: hosted + version: "3.1.2" + crypto: + dependency: "direct main" + description: + name: crypto + sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf + url: "https://pub.dev" + source: hosted + version: "3.0.7" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: a9c30492da18ff84efe2422ba2d319a89942d93e58eb0b73d32abe822ef54b7b + url: "https://pub.dev" + source: hosted + version: "3.1.3" + deep_collection: + dependency: "direct main" + description: + name: deep_collection + sha256: "59abffbfd9add6d47e04d623c50c3e2bcf3ed6a1606513dbe3325a738f77cb0c" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + dio: + dependency: "direct main" + description: + name: dio + sha256: d90ee57923d1828ac14e492ca49440f65477f4bb1263575900be731a3dac66a9 + url: "https://pub.dev" + source: hosted + version: "5.9.0" + dio_web_adapter: + dependency: transitive + description: + name: dio_web_adapter + sha256: "7586e476d70caecaf1686d21eee7247ea43ef5c345eab9e0cc3583ff13378d78" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + dotenv: + dependency: "direct main" + description: + name: dotenv + sha256: "379e64b6fc82d3df29461d349a1796ecd2c436c480d4653f3af6872eccbc90e1" + url: "https://pub.dev" + source: hosted + version: "4.2.0" + effective_dart: + dependency: transitive + description: + name: effective_dart + sha256: "6a69783c808344084b65667e87ff600823531e95810a8a15882cb542fe22de80" + url: "https://pub.dev" + source: hosted + version: "1.3.2" + equatable: + dependency: "direct main" + description: + name: equatable + sha256: "567c64b3cb4cf82397aac55f4f0cbd3ca20d77c6c03bedbc4ceaddc08904aef7" + url: "https://pub.dev" + source: hosted + version: "2.0.7" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + url: "https://pub.dev" + source: hosted + version: "1.3.3" + ffi: + dependency: transitive + description: + name: ffi + sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + file: + dependency: transitive + description: + name: file + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 + url: "https://pub.dev" + source: hosted + version: "7.0.1" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.dev" + source: hosted + version: "1.1.1" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_bloc: + dependency: "direct main" + description: + name: flutter_bloc + sha256: cf51747952201a455a1c840f8171d273be009b932c75093020f9af64f2123e38 + url: "https://pub.dev" + source: hosted + version: "9.1.1" + flutter_dotenv: + dependency: "direct main" + description: + name: flutter_dotenv + sha256: d4130c4a43e0b13fefc593bc3961f2cb46e30cb79e253d4a526b1b5d24ae1ce4 + url: "https://pub.dev" + source: hosted + version: "6.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "3105dc8492f6183fb076ccf1f351ac3d60564bff92e20bfc4af9cc1651f4e7e1" + url: "https://pub.dev" + source: hosted + version: "6.0.0" + flutter_secure_storage: + dependency: "direct main" + description: + name: flutter_secure_storage + sha256: "9cad52d75ebc511adfae3d447d5d13da15a55a92c9410e50f67335b6d21d16ea" + url: "https://pub.dev" + source: hosted + version: "9.2.4" + flutter_secure_storage_linux: + dependency: transitive + description: + name: flutter_secure_storage_linux + sha256: be76c1d24a97d0b98f8b54bce6b481a380a6590df992d0098f868ad54dc8f688 + url: "https://pub.dev" + source: hosted + version: "1.2.3" + flutter_secure_storage_macos: + dependency: transitive + description: + name: flutter_secure_storage_macos + sha256: "6c0a2795a2d1de26ae202a0d78527d163f4acbb11cde4c75c670f3a0fc064247" + url: "https://pub.dev" + source: hosted + version: "3.1.3" + flutter_secure_storage_platform_interface: + dependency: transitive + description: + name: flutter_secure_storage_platform_interface + sha256: cf91ad32ce5adef6fba4d736a542baca9daf3beac4db2d04be350b87f69ac4a8 + url: "https://pub.dev" + source: hosted + version: "1.1.2" + flutter_secure_storage_web: + dependency: transitive + description: + name: flutter_secure_storage_web + sha256: f4ebff989b4f07b2656fb16b47852c0aab9fed9b4ec1c70103368337bc1886a9 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + flutter_secure_storage_windows: + dependency: transitive + description: + name: flutter_secure_storage_windows + sha256: b20b07cb5ed4ed74fc567b78a72936203f587eba460af1df11281c9326cd3709 + url: "https://pub.dev" + source: hosted + version: "3.1.2" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_web_auth: + dependency: "direct main" + description: + name: flutter_web_auth + sha256: "95e4856e24fb6ac1678f5ff334743b63f782d839ab324543d29ccbd295176209" + url: "https://pub.dev" + source: hosted + version: "0.6.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + freezed: + dependency: "direct dev" + description: + name: freezed + sha256: "13065f10e135263a4f5a4391b79a8efc5fb8106f8dd555a9e49b750b45393d77" + url: "https://pub.dev" + source: hosted + version: "3.2.3" + freezed_annotation: + dependency: "direct main" + description: + name: freezed_annotation + sha256: "7294967ff0a6d98638e7acb774aac3af2550777accd8149c90af5b014e6d44d8" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + glob: + dependency: transitive + description: + name: glob + sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de + url: "https://pub.dev" + source: hosted + version: "2.1.3" + google_fonts: + dependency: "direct main" + description: + name: google_fonts + sha256: "517b20870220c48752eafa0ba1a797a092fb22df0d89535fd9991e86ee2cdd9c" + url: "https://pub.dev" + source: hosted + version: "6.3.2" + google_identity_services_web: + dependency: transitive + description: + name: google_identity_services_web + sha256: "5d187c46dc59e02646e10fe82665fc3884a9b71bc1c90c2b8b749316d33ee454" + url: "https://pub.dev" + source: hosted + version: "0.3.3+1" + google_sign_in: + dependency: "direct main" + description: + name: google_sign_in + sha256: "521031b65853b4409b8213c0387d57edaad7e2a949ce6dea0d8b2afc9cb29763" + url: "https://pub.dev" + source: hosted + version: "7.2.0" + google_sign_in_android: + dependency: transitive + description: + name: google_sign_in_android + sha256: "13759dc6dbff7501452830995d1a4446e4af172050e16a0091f98fcf607fa2c7" + url: "https://pub.dev" + source: hosted + version: "7.2.6" + google_sign_in_ios: + dependency: transitive + description: + name: google_sign_in_ios + sha256: aee8bb29484611a37607849175a2009d423de6bd7c129326c69fd7068f0b6ed7 + url: "https://pub.dev" + source: hosted + version: "6.2.4" + google_sign_in_platform_interface: + dependency: transitive + description: + name: google_sign_in_platform_interface + sha256: "7f59208c42b415a3cca203571128d6f84f885fead2d5b53eb65a9e27f2965bb5" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + google_sign_in_web: + dependency: transitive + description: + name: google_sign_in_web + sha256: "2fc1f941e6443b2d6984f4056a727a3eaeab15d8ee99ba7125d79029be75a1da" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + graphs: + dependency: transitive + description: + name: graphs + sha256: "741bbf84165310a68ff28fe9e727332eef1407342fca52759cb21ad8177bb8d0" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + http: + dependency: transitive + description: + name: http + sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412" + url: "https://pub.dev" + source: hosted + version: "1.6.0" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: aa6199f908078bb1c5efb8d8638d4ae191aac11b311132c3ef48ce352fb52ef8 + url: "https://pub.dev" + source: hosted + version: "3.2.2" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.dev" + source: hosted + version: "4.1.2" + io: + dependency: transitive + description: + name: io + sha256: dfd5a80599cf0165756e3181807ed3e77daf6dd4137caaad72d0b7931597650b + url: "https://pub.dev" + source: hosted + version: "1.0.5" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" + json_annotation: + dependency: "direct main" + description: + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" + source: hosted + version: "4.9.0" + json_serializable: + dependency: "direct dev" + description: + name: json_serializable + sha256: c5b2ee75210a0f263c6c7b9eeea80553dbae96ea1bf57f02484e806a3ffdffa3 + url: "https://pub.dev" + source: hosted + version: "6.11.2" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" + url: "https://pub.dev" + source: hosted + version: "11.0.2" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" + url: "https://pub.dev" + source: hosted + version: "3.0.10" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + lints: + dependency: transitive + description: + name: lints + sha256: a5e2b223cb7c9c8efdc663ef484fdd95bb243bff242ef5b13e26883547fce9a0 + url: "https://pub.dev" + source: hosted + version: "6.0.0" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + url: "https://pub.dev" + source: hosted + version: "0.12.17" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" + source: hosted + version: "0.11.1" + meta: + dependency: transitive + description: + name: meta + sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" + url: "https://pub.dev" + source: hosted + version: "1.17.0" + mime: + dependency: transitive + description: + name: mime + sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + objective_c: + dependency: transitive + description: + name: objective_c + sha256: "1f81ed9e41909d44162d7ec8663b2c647c202317cc0b56d3d56f6a13146a0b64" + url: "https://pub.dev" + source: hosted + version: "9.1.0" + one_of: + dependency: "direct main" + description: + name: one_of + sha256: "25fe0fcf181e761c6fcd604caf9d5fdf952321be17584ba81c72c06bdaa511f0" + url: "https://pub.dev" + source: hosted + version: "1.5.0" + one_of_serializer: + dependency: transitive + description: + name: one_of_serializer + sha256: "3f3dfb5c1578ba3afef1cb47fcc49e585e797af3f2b6c2cc7ed90aad0c5e7b83" + url: "https://pub.dev" + source: hosted + version: "1.5.0" + ory_client: + dependency: "direct main" + description: + name: ory_client + sha256: e32b65c00ec4171a0d369a8a9f90695888f0356b576ce8c2930b21d2163050b9 + url: "https://pub.dev" + source: hosted + version: "1.22.11" + package_config: + dependency: transitive + description: + name: package_config + sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc + url: "https://pub.dev" + source: hosted + version: "2.2.0" + path: + dependency: transitive + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + path_provider: + dependency: transitive + description: + name: path_provider + sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" + url: "https://pub.dev" + source: hosted + version: "2.1.5" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: f2c65e21139ce2c3dad46922be8272bb5963516045659e71bb16e151c93b580e + url: "https://pub.dev" + source: hosted + version: "2.2.22" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "6192e477f34018ef1ea790c56fffc7302e3bc3efede9e798b934c252c8c105ba" + url: "https://pub.dev" + source: hosted + version: "2.5.0" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" + source: hosted + version: "2.2.1" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 + url: "https://pub.dev" + source: hosted + version: "2.3.0" + platform: + dependency: transitive + description: + name: platform + sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" + url: "https://pub.dev" + source: hosted + version: "3.1.6" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + pool: + dependency: transitive + description: + name: pool + sha256: "978783255c543aa3586a1b3c21f6e9d720eb315376a915872c61ef8b5c20177d" + url: "https://pub.dev" + source: hosted + version: "1.5.2" + provider: + dependency: transitive + description: + name: provider + sha256: "4e82183fa20e5ca25703ead7e05de9e4cceed1fbd1eadc1ac3cb6f565a09f272" + url: "https://pub.dev" + source: hosted + version: "6.1.5+1" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082" + url: "https://pub.dev" + source: hosted + version: "1.5.0" + quiver: + dependency: transitive + description: + name: quiver + sha256: ea0b925899e64ecdfbf9c7becb60d5b50e706ade44a85b2363be2a22d88117d2 + url: "https://pub.dev" + source: hosted + version: "3.2.2" + shelf: + dependency: transitive + description: + name: shelf + sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12 + url: "https://pub.dev" + source: hosted + version: "1.4.2" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "3632775c8e90d6c9712f883e633716432a27758216dfb61bd86a8321c0580925" + url: "https://pub.dev" + source: hosted + version: "3.0.0" + sign_in_with_apple: + dependency: "direct main" + description: + name: sign_in_with_apple + sha256: "8bd875c8e8748272749eb6d25b896f768e7e9d60988446d543fe85a37a2392b8" + url: "https://pub.dev" + source: hosted + version: "7.0.1" + sign_in_with_apple_platform_interface: + dependency: transitive + description: + name: sign_in_with_apple_platform_interface + sha256: "981bca52cf3bb9c3ad7ef44aace2d543e5c468bb713fd8dda4275ff76dfa6659" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + sign_in_with_apple_web: + dependency: transitive + description: + name: sign_in_with_apple_web + sha256: f316400827f52cafcf50d00e1a2e8a0abc534ca1264e856a81c5f06bd5b10fed + url: "https://pub.dev" + source: hosted + version: "3.0.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + source_gen: + dependency: transitive + description: + name: source_gen + sha256: "07b277b67e0096c45196cbddddf2d8c6ffc49342e88bf31d460ce04605ddac75" + url: "https://pub.dev" + source: hosted + version: "4.1.1" + source_helper: + dependency: transitive + description: + name: source_helper + sha256: "6a3c6cc82073a8797f8c4dc4572146114a39652851c157db37e964d9c7038723" + url: "https://pub.dev" + source: hosted + version: "1.3.8" + source_span: + dependency: transitive + description: + name: source_span + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" + url: "https://pub.dev" + source: hosted + version: "1.10.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" + source: hosted + version: "1.12.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: ad47125e588cfd37a9a7f86c7d6356dde8dfe89d071d293f80ca9e9273a33871 + url: "https://pub.dev" + source: hosted + version: "2.1.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.dev" + source: hosted + version: "1.4.1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.dev" + source: hosted + version: "1.2.2" + test_api: + dependency: transitive + description: + name: test_api + sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 + url: "https://pub.dev" + source: hosted + version: "0.7.7" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + url: "https://pub.dev" + source: hosted + version: "2.2.0" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60" + url: "https://pub.dev" + source: hosted + version: "15.0.2" + watcher: + dependency: transitive + description: + name: watcher + sha256: "592ab6e2892f67760543fb712ff0177f4ec76c031f02f5b4ff8d3fc5eb9fb61a" + url: "https://pub.dev" + source: hosted + version: "1.1.4" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + web_socket: + dependency: transitive + description: + name: web_socket + sha256: "34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d645757fb0f4773d602444000a8131ff5d48c9e47adfe9772652dd1a4f2d45c8 + url: "https://pub.dev" + source: hosted + version: "3.0.3" + win32: + dependency: transitive + description: + name: win32 + sha256: d7cb55e04cd34096cd3a79b3330245f54cb96a370a1c27adb3c84b917de8b08e + url: "https://pub.dev" + source: hosted + version: "5.15.0" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.dev" + source: hosted + version: "3.1.3" +sdks: + dart: ">=3.9.0 <4.0.0" + flutter: ">=3.35.0" diff --git a/flutter-ory-network/pubspec.yaml b/flutter-ory-network/pubspec.yaml new file mode 100644 index 00000000..0f26a7a9 --- /dev/null +++ b/flutter-ory-network/pubspec.yaml @@ -0,0 +1,118 @@ +name: ory_network_flutter +description: A new Flutter project. +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: "none" # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +# In Windows, build-name is used as the major, minor, and patch parts +# of the product and file versions while build-number is used as the build suffix. +version: 1.0.0+1 + +environment: + sdk: ">=3.0.6 <4.0.0" + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + + bloc: ^9.1.0 + flutter_bloc: ^9.1.1 + dio: ^5.3.2 + ory_client: ^1.4.2 + flutter_dotenv: ^6.0.0 + freezed_annotation: ^3.1.0 + json_annotation: ^4.8.1 + equatable: ^2.0.5 + one_of: ^1.5.0 + flutter_secure_storage: ^9.2.4 + dotenv: ^4.1.0 + google_fonts: ^6.3.2 + built_value: ^8.6.2 + collection: ^1.17.2 + bloc_concurrency: ^0.3.0 + deep_collection: ^1.0.2 + built_collection: ^5.1.1 + google_sign_in: ^7.2.0 + sign_in_with_apple: ^7.0.1 + crypto: ^3.0.3 + flutter_web_auth: ^0.6.0 + +dev_dependencies: + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^6.0.0 + build_runner: ^2.4.6 + freezed: ^3.2.3 + json_serializable: ^6.7.1 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + assets: + - .env + - assets/images/ + - assets/images/1.5x/ + - assets/images/2.0x/ + - assets/images/3.0x/ + - assets/images/4.0x/ + - assets/icons/ + - assets/icons/1.5x/ + - assets/icons/2.0x/ + - assets/icons/3.0x/ + - assets/icons/4.0x/ + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages