diff --git a/.flutter-plugins b/.flutter-plugins deleted file mode 100644 index 268fb611..00000000 --- a/.flutter-plugins +++ /dev/null @@ -1 +0,0 @@ -flutter_webview_plugin=C:\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\flutter_webview_plugin-0.3.0+2\\ diff --git a/CHANGELOG.md b/CHANGELOG.md index ba89a94b..a8934e6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,9 @@ ## [0.2.0] - 20201007 -- Add additional config options https://github.com/Earlybyte/aad_oauth/pull/66 -- Throw Exception on return https://github.com/Earlybyte/aad_oauth/pull/55 -- Fix Example App https://github.com/Earlybyte/aad_oauth/pull/65 +- Add additional config options #66 +- Throw Exception on return #55 +- Fix Example App #65 +- Comply Pub Dev Requirements #67 ## [0.1.9] - 20200529 diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 00000000..909283be --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,54 @@ +# Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file +# for details. All rights reserved. Use of this source code is governed by a +# BSD-style license that can be found in the LICENSE file. +# +# Google internally enforced rules. See README.md for more information, +# including a list of lints that are intentionally _not_ enforced. + +linter: + rules: + - always_declare_return_types + - always_require_non_null_named_parameters + - annotate_overrides + - avoid_empty_else + - avoid_init_to_null + - avoid_null_checks_in_equality_operators + - avoid_relative_lib_imports + - avoid_return_types_on_setters + - avoid_shadowing_type_parameters + - avoid_types_as_parameter_names + - camel_case_extensions + - curly_braces_in_flow_control_structures + - empty_catches + - empty_constructor_bodies + - library_names + - library_prefixes + - no_duplicate_case_values + - null_closures + - omit_local_variable_types + - prefer_adjacent_string_concatenation + - prefer_collection_literals + - prefer_conditional_assignment + - prefer_contains + - prefer_equal_for_default_values + - prefer_final_fields + - prefer_for_elements_to_map_fromIterable + - prefer_generic_function_type_aliases + - prefer_if_null_operators + - prefer_is_empty + - prefer_is_not_empty + - prefer_iterable_whereType + - prefer_single_quotes + - prefer_spread_collections + - recursive_getters + - slash_for_doc_comments + - type_init_formals + - unawaited_futures + - unnecessary_const + - unnecessary_new + - unnecessary_null_in_if_null_operators + - unnecessary_this + - unrelated_type_equality_checks + - use_function_type_syntax_for_parameters + - use_rethrow_when_possible + - valid_regexps diff --git a/android/local.properties b/android/local.properties index 4dce9d45..3cc215c8 100644 --- a/android/local.properties +++ b/android/local.properties @@ -1,2 +1,2 @@ -sdk.dir=C:\\Users\\tobias.meier.eb\\AppData\\Local\\Android\\sdk -flutter.sdk=C:\\flutter \ No newline at end of file +sdk.dir=/Users/philipp/Library/Android/sdk +flutter.sdk=/Users/philipp/development/flutter \ No newline at end of file diff --git a/examples/example/.gitignore b/example/.gitignore similarity index 100% rename from examples/example/.gitignore rename to example/.gitignore diff --git a/examples/example/.metadata b/example/.metadata similarity index 100% rename from examples/example/.metadata rename to example/.metadata diff --git a/examples/example/README.md b/example/README.md similarity index 100% rename from examples/example/README.md rename to example/README.md diff --git a/examples/example/android/.gitignore b/example/android/.gitignore similarity index 100% rename from examples/example/android/.gitignore rename to example/android/.gitignore diff --git a/examples/example/android/app/build.gradle b/example/android/app/build.gradle similarity index 100% rename from examples/example/android/app/build.gradle rename to example/android/app/build.gradle diff --git a/examples/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml similarity index 100% rename from examples/example/android/app/src/debug/AndroidManifest.xml rename to example/android/app/src/debug/AndroidManifest.xml diff --git a/examples/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml similarity index 100% rename from examples/example/android/app/src/main/AndroidManifest.xml rename to example/android/app/src/main/AndroidManifest.xml diff --git a/examples/example/android/app/src/main/kotlin/com/example/example_oauth/MainActivity.kt b/example/android/app/src/main/kotlin/com/example/example_oauth/MainActivity.kt similarity index 100% rename from examples/example/android/app/src/main/kotlin/com/example/example_oauth/MainActivity.kt rename to example/android/app/src/main/kotlin/com/example/example_oauth/MainActivity.kt diff --git a/examples/example/android/app/src/main/res/drawable/launch_background.xml b/example/android/app/src/main/res/drawable/launch_background.xml similarity index 100% rename from examples/example/android/app/src/main/res/drawable/launch_background.xml rename to example/android/app/src/main/res/drawable/launch_background.xml diff --git a/examples/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from examples/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png rename to example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/examples/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from examples/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png rename to example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/examples/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from examples/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/examples/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from examples/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/examples/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from examples/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/examples/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml similarity index 100% rename from examples/example/android/app/src/main/res/values/styles.xml rename to example/android/app/src/main/res/values/styles.xml diff --git a/examples/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml similarity index 100% rename from examples/example/android/app/src/profile/AndroidManifest.xml rename to example/android/app/src/profile/AndroidManifest.xml diff --git a/examples/example/android/build.gradle b/example/android/build.gradle similarity index 100% rename from examples/example/android/build.gradle rename to example/android/build.gradle diff --git a/examples/example/android/gradle.properties b/example/android/gradle.properties similarity index 100% rename from examples/example/android/gradle.properties rename to example/android/gradle.properties diff --git a/examples/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from examples/example/android/gradle/wrapper/gradle-wrapper.properties rename to example/android/gradle/wrapper/gradle-wrapper.properties diff --git a/examples/example/android/settings.gradle b/example/android/settings.gradle similarity index 100% rename from examples/example/android/settings.gradle rename to example/android/settings.gradle diff --git a/examples/example/ios/.gitignore b/example/ios/.gitignore similarity index 100% rename from examples/example/ios/.gitignore rename to example/ios/.gitignore diff --git a/examples/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist similarity index 100% rename from examples/example/ios/Flutter/AppFrameworkInfo.plist rename to example/ios/Flutter/AppFrameworkInfo.plist diff --git a/examples/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig similarity index 100% rename from examples/example/ios/Flutter/Debug.xcconfig rename to example/ios/Flutter/Debug.xcconfig diff --git a/examples/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig similarity index 100% rename from examples/example/ios/Flutter/Release.xcconfig rename to example/ios/Flutter/Release.xcconfig diff --git a/examples/example/ios/Podfile b/example/ios/Podfile similarity index 100% rename from examples/example/ios/Podfile rename to example/ios/Podfile diff --git a/examples/example/ios/Podfile.lock b/example/ios/Podfile.lock similarity index 100% rename from examples/example/ios/Podfile.lock rename to example/ios/Podfile.lock diff --git a/examples/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj similarity index 98% rename from examples/example/ios/Runner.xcodeproj/project.pbxproj rename to example/ios/Runner.xcodeproj/project.pbxproj index 08d89a10..550dd4ab 100644 --- a/examples/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -316,7 +316,6 @@ /* Begin XCBuildConfiguration section */ 249021D3217E4FDB00AE95B9 /* Profile */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -393,7 +392,6 @@ }; 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -449,7 +447,6 @@ }; 97C147041CF9000F007C117D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; diff --git a/examples/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 100% rename from examples/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/examples/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from examples/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/examples/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings similarity index 100% rename from examples/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings rename to example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings diff --git a/examples/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme similarity index 100% rename from examples/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme rename to example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme diff --git a/examples/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcworkspace/contents.xcworkspacedata similarity index 100% rename from examples/example/ios/Runner.xcworkspace/contents.xcworkspacedata rename to example/ios/Runner.xcworkspace/contents.xcworkspacedata diff --git a/examples/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from examples/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/examples/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings similarity index 100% rename from examples/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings rename to example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings diff --git a/examples/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift similarity index 100% rename from examples/example/ios/Runner/AppDelegate.swift rename to example/ios/Runner/AppDelegate.swift diff --git a/examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png diff --git a/examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png diff --git a/examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png diff --git a/examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png diff --git a/examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png diff --git a/examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png diff --git a/examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png diff --git a/examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png diff --git a/examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png diff --git a/examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png diff --git a/examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png diff --git a/examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png diff --git a/examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png diff --git a/examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png diff --git a/examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png diff --git a/examples/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json rename to example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json diff --git a/examples/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png rename to example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png diff --git a/examples/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png rename to example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png diff --git a/examples/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png rename to example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png diff --git a/examples/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md similarity index 100% rename from examples/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md rename to example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md diff --git a/examples/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/example/ios/Runner/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from examples/example/ios/Runner/Base.lproj/LaunchScreen.storyboard rename to example/ios/Runner/Base.lproj/LaunchScreen.storyboard diff --git a/examples/example/ios/Runner/Base.lproj/Main.storyboard b/example/ios/Runner/Base.lproj/Main.storyboard similarity index 100% rename from examples/example/ios/Runner/Base.lproj/Main.storyboard rename to example/ios/Runner/Base.lproj/Main.storyboard diff --git a/examples/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist similarity index 100% rename from examples/example/ios/Runner/Info.plist rename to example/ios/Runner/Info.plist diff --git a/examples/example/ios/Runner/Runner-Bridging-Header.h b/example/ios/Runner/Runner-Bridging-Header.h similarity index 100% rename from examples/example/ios/Runner/Runner-Bridging-Header.h rename to example/ios/Runner/Runner-Bridging-Header.h diff --git a/examples/example/lib/main.dart b/example/lib/main.dart similarity index 61% rename from examples/example/lib/main.dart rename to example/lib/main.dart index 7b8b1eab..103146c9 100644 --- a/examples/example/lib/main.dart +++ b/example/lib/main.dart @@ -2,27 +2,17 @@ import 'package:aad_oauth/aad_oauth.dart'; import 'package:aad_oauth/model/config.dart'; import 'package:flutter/material.dart'; -void main() => runApp(new MyApp()); - -class MyApp extends StatefulWidget { - @override - _MyAppState createState() => new _MyAppState(); -} - -class _MyAppState extends State { - @override - initState() { - super.initState(); - } +void main() => runApp(MyApp()); +class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return new MaterialApp( + return MaterialApp( title: 'AAD OAuth Demo', - theme: new ThemeData( + theme: ThemeData( primarySwatch: Colors.blue, ), - home: new MyHomePage(title: 'AAD OAuth Home'), + home: MyHomePage(title: 'AAD OAuth Home'), ); } } @@ -32,18 +22,19 @@ class MyHomePage extends StatefulWidget { final String title; @override - _MyHomePageState createState() => new _MyHomePageState(); + _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State { - static final Config config = new Config( - tenant: "YOUR_TENANT_ID", - clientId: "YOUR_CLIENT_ID", - scope: "openid profile offline_access", - redirectUri: "https://login.live.com/oauth20_desktop.srf", + static final Config config = Config( + tenant: 'YOUR_TENANT_ID', + clientId: 'YOUR_CLIENT_ID', + scope: 'openid profile offline_access', + redirectUri: 'https://login.live.com/oauth20_desktop.srf', ); final AadOAuth oauth = AadOAuth(config); + @override Widget build(BuildContext context) { // adjust window size for browser login var screenSize = MediaQuery.of(context).size; @@ -51,16 +42,16 @@ class _MyHomePageState extends State { Rect.fromLTWH(0.0, 25.0, screenSize.width, screenSize.height - 25); oauth.setWebViewScreenSize(rectSize); - return new Scaffold( - appBar: new AppBar( - title: new Text(widget.title), + return Scaffold( + appBar: AppBar( + title: Text(widget.title), ), body: ListView( children: [ ListTile( title: Text( - "AzureAD OAuth", - style: Theme.of(context).textTheme.headline, + 'AzureAD OAuth', + style: Theme.of(context).textTheme.headline5, ), ), ListTile( @@ -87,9 +78,9 @@ class _MyHomePageState extends State { } void showMessage(String text) { - var alert = new AlertDialog(content: new Text(text), actions: [ - new FlatButton( - child: const Text("Ok"), + var alert = AlertDialog(content: Text(text), actions: [ + FlatButton( + child: const Text('Ok'), onPressed: () { Navigator.pop(context); }) @@ -100,8 +91,8 @@ class _MyHomePageState extends State { void login() async { try { await oauth.login(); - String accessToken = await oauth.getAccessToken(); - showMessage("Logged in successfully, your access token: $accessToken"); + var accessToken = await oauth.getAccessToken(); + showMessage('Logged in successfully, your access token: $accessToken'); } catch (e) { showError(e); } @@ -109,6 +100,6 @@ class _MyHomePageState extends State { void logout() async { await oauth.logout(); - showMessage("Logged out"); + showMessage('Logged out'); } } diff --git a/examples/example/pubspec.lock b/example/pubspec.lock similarity index 84% rename from examples/example/pubspec.lock rename to example/pubspec.lock index 1817194c..63cfd16a 100644 --- a/examples/example/pubspec.lock +++ b/example/pubspec.lock @@ -4,66 +4,52 @@ packages: aad_oauth: dependency: "direct main" description: - path: "../.." + path: ".." relative: true source: path - version: "0.1.9" - archive: - dependency: transitive - description: - name: archive - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.13" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.0" + version: "0.2.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.5.0-nullsafety.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" - charcode: + version: "2.1.0-nullsafety.1" + characters: dependency: transitive description: - name: charcode + name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" - collection: + version: "1.1.0-nullsafety.3" + charcode: dependency: transitive description: - name: collection + name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.14.12" - convert: + version: "1.2.0-nullsafety.1" + clock: dependency: transitive description: - name: convert + name: clock url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" - crypto: + version: "1.1.0-nullsafety.1" + collection: dependency: transitive description: - name: crypto + name: collection url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "1.15.0-nullsafety.3" cupertino_icons: dependency: "direct main" description: @@ -71,6 +57,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.3" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0-nullsafety.1" ffi: dependency: transitive description: @@ -128,13 +121,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.4" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.12" intl: dependency: transitive description: @@ -148,21 +134,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.10-nullsafety.1" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0-nullsafety.3" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" + version: "1.8.0-nullsafety.1" path_provider_linux: dependency: transitive description: @@ -191,13 +177,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.9.0" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.0" platform: dependency: transitive description: @@ -219,13 +198,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.0.13" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" shared_preferences: dependency: transitive description: @@ -279,56 +251,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0-nullsafety.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0-nullsafety.1" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0-nullsafety.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.15" + version: "0.2.19-nullsafety.2" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0-nullsafety.3" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0-nullsafety.3" win32: dependency: transitive description: @@ -343,13 +315,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.0" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "3.6.1" sdks: - dart: ">=2.7.0 <3.0.0" + dart: ">=2.10.0-110 <2.11.0" flutter: ">=1.12.13+hotfix.5 <2.0.0" diff --git a/examples/example/pubspec.yaml b/example/pubspec.yaml similarity index 91% rename from examples/example/pubspec.yaml rename to example/pubspec.yaml index a985d498..9dafd1e5 100644 --- a/examples/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -7,12 +7,11 @@ environment: sdk: ">=2.7.0 <3.0.0" dependencies: - aad_oauth: - path: ../../ + aad_oauth: + path: ../ flutter: sdk: flutter - cupertino_icons: ^0.1.2 dev_dependencies: diff --git a/examples/example_b2c/.gitignore b/example_b2c/.gitignore similarity index 100% rename from examples/example_b2c/.gitignore rename to example_b2c/.gitignore diff --git a/examples/example_b2c/.metadata b/example_b2c/.metadata similarity index 100% rename from examples/example_b2c/.metadata rename to example_b2c/.metadata diff --git a/examples/example_b2c/README.md b/example_b2c/README.md similarity index 100% rename from examples/example_b2c/README.md rename to example_b2c/README.md diff --git a/examples/example_b2c/android/.gitignore b/example_b2c/android/.gitignore similarity index 100% rename from examples/example_b2c/android/.gitignore rename to example_b2c/android/.gitignore diff --git a/examples/example_b2c/android/app/build.gradle b/example_b2c/android/app/build.gradle similarity index 100% rename from examples/example_b2c/android/app/build.gradle rename to example_b2c/android/app/build.gradle diff --git a/examples/example_b2c/android/app/src/debug/AndroidManifest.xml b/example_b2c/android/app/src/debug/AndroidManifest.xml similarity index 100% rename from examples/example_b2c/android/app/src/debug/AndroidManifest.xml rename to example_b2c/android/app/src/debug/AndroidManifest.xml diff --git a/examples/example_b2c/android/app/src/main/AndroidManifest.xml b/example_b2c/android/app/src/main/AndroidManifest.xml similarity index 100% rename from examples/example_b2c/android/app/src/main/AndroidManifest.xml rename to example_b2c/android/app/src/main/AndroidManifest.xml diff --git a/examples/example_b2c/android/app/src/main/kotlin/com/erickdaros/example_b2c/MainActivity.kt b/example_b2c/android/app/src/main/kotlin/com/erickdaros/example_b2c/MainActivity.kt similarity index 100% rename from examples/example_b2c/android/app/src/main/kotlin/com/erickdaros/example_b2c/MainActivity.kt rename to example_b2c/android/app/src/main/kotlin/com/erickdaros/example_b2c/MainActivity.kt diff --git a/examples/example_b2c/android/app/src/main/res/drawable/launch_background.xml b/example_b2c/android/app/src/main/res/drawable/launch_background.xml similarity index 100% rename from examples/example_b2c/android/app/src/main/res/drawable/launch_background.xml rename to example_b2c/android/app/src/main/res/drawable/launch_background.xml diff --git a/examples/example_b2c/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/example_b2c/android/app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from examples/example_b2c/android/app/src/main/res/mipmap-hdpi/ic_launcher.png rename to example_b2c/android/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/examples/example_b2c/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/example_b2c/android/app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from examples/example_b2c/android/app/src/main/res/mipmap-mdpi/ic_launcher.png rename to example_b2c/android/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/examples/example_b2c/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/example_b2c/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from examples/example_b2c/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to example_b2c/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/examples/example_b2c/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/example_b2c/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from examples/example_b2c/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to example_b2c/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/examples/example_b2c/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/example_b2c/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from examples/example_b2c/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to example_b2c/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/examples/example_b2c/android/app/src/main/res/values/styles.xml b/example_b2c/android/app/src/main/res/values/styles.xml similarity index 100% rename from examples/example_b2c/android/app/src/main/res/values/styles.xml rename to example_b2c/android/app/src/main/res/values/styles.xml diff --git a/examples/example_b2c/android/app/src/profile/AndroidManifest.xml b/example_b2c/android/app/src/profile/AndroidManifest.xml similarity index 100% rename from examples/example_b2c/android/app/src/profile/AndroidManifest.xml rename to example_b2c/android/app/src/profile/AndroidManifest.xml diff --git a/examples/example_b2c/android/build.gradle b/example_b2c/android/build.gradle similarity index 100% rename from examples/example_b2c/android/build.gradle rename to example_b2c/android/build.gradle diff --git a/examples/example_b2c/android/gradle.properties b/example_b2c/android/gradle.properties similarity index 100% rename from examples/example_b2c/android/gradle.properties rename to example_b2c/android/gradle.properties diff --git a/examples/example_b2c/android/gradle/wrapper/gradle-wrapper.properties b/example_b2c/android/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from examples/example_b2c/android/gradle/wrapper/gradle-wrapper.properties rename to example_b2c/android/gradle/wrapper/gradle-wrapper.properties diff --git a/examples/example_b2c/android/settings.gradle b/example_b2c/android/settings.gradle similarity index 100% rename from examples/example_b2c/android/settings.gradle rename to example_b2c/android/settings.gradle diff --git a/examples/example_b2c/ios/.gitignore b/example_b2c/ios/.gitignore similarity index 100% rename from examples/example_b2c/ios/.gitignore rename to example_b2c/ios/.gitignore diff --git a/examples/example_b2c/ios/Flutter/AppFrameworkInfo.plist b/example_b2c/ios/Flutter/AppFrameworkInfo.plist similarity index 100% rename from examples/example_b2c/ios/Flutter/AppFrameworkInfo.plist rename to example_b2c/ios/Flutter/AppFrameworkInfo.plist diff --git a/examples/example_b2c/ios/Flutter/Debug.xcconfig b/example_b2c/ios/Flutter/Debug.xcconfig similarity index 100% rename from examples/example_b2c/ios/Flutter/Debug.xcconfig rename to example_b2c/ios/Flutter/Debug.xcconfig diff --git a/examples/example_b2c/ios/Flutter/Release.xcconfig b/example_b2c/ios/Flutter/Release.xcconfig similarity index 100% rename from examples/example_b2c/ios/Flutter/Release.xcconfig rename to example_b2c/ios/Flutter/Release.xcconfig diff --git a/examples/example_b2c/ios/Podfile b/example_b2c/ios/Podfile similarity index 100% rename from examples/example_b2c/ios/Podfile rename to example_b2c/ios/Podfile diff --git a/examples/example_b2c/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example_b2c/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 100% rename from examples/example_b2c/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to example_b2c/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/examples/example_b2c/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example_b2c/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme similarity index 100% rename from examples/example_b2c/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme rename to example_b2c/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme diff --git a/examples/example_b2c/ios/Runner.xcworkspace/contents.xcworkspacedata b/example_b2c/ios/Runner.xcworkspace/contents.xcworkspacedata similarity index 100% rename from examples/example_b2c/ios/Runner.xcworkspace/contents.xcworkspacedata rename to example_b2c/ios/Runner.xcworkspace/contents.xcworkspacedata diff --git a/examples/example_b2c/ios/Runner/AppDelegate.swift b/example_b2c/ios/Runner/AppDelegate.swift similarity index 100% rename from examples/example_b2c/ios/Runner/AppDelegate.swift rename to example_b2c/ios/Runner/AppDelegate.swift diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json rename to example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png rename to example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png rename to example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png rename to example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png rename to example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png rename to example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png rename to example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png rename to example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png rename to example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png rename to example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png rename to example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png rename to example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png rename to example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png rename to example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png rename to example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png rename to example_b2c/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json rename to example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png rename to example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png rename to example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png rename to example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png diff --git a/examples/example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md similarity index 100% rename from examples/example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md rename to example_b2c/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md diff --git a/examples/example_b2c/ios/Runner/Base.lproj/LaunchScreen.storyboard b/example_b2c/ios/Runner/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from examples/example_b2c/ios/Runner/Base.lproj/LaunchScreen.storyboard rename to example_b2c/ios/Runner/Base.lproj/LaunchScreen.storyboard diff --git a/examples/example_b2c/ios/Runner/Base.lproj/Main.storyboard b/example_b2c/ios/Runner/Base.lproj/Main.storyboard similarity index 100% rename from examples/example_b2c/ios/Runner/Base.lproj/Main.storyboard rename to example_b2c/ios/Runner/Base.lproj/Main.storyboard diff --git a/examples/example_b2c/ios/Runner/Info.plist b/example_b2c/ios/Runner/Info.plist similarity index 100% rename from examples/example_b2c/ios/Runner/Info.plist rename to example_b2c/ios/Runner/Info.plist diff --git a/examples/example_b2c/ios/Runner/Runner-Bridging-Header.h b/example_b2c/ios/Runner/Runner-Bridging-Header.h similarity index 100% rename from examples/example_b2c/ios/Runner/Runner-Bridging-Header.h rename to example_b2c/ios/Runner/Runner-Bridging-Header.h diff --git a/examples/example_b2c/lib/main.dart b/example_b2c/lib/main.dart similarity index 63% rename from examples/example_b2c/lib/main.dart rename to example_b2c/lib/main.dart index 8093ba97..2abc5368 100644 --- a/examples/example_b2c/lib/main.dart +++ b/example_b2c/lib/main.dart @@ -2,11 +2,11 @@ import 'package:aad_oauth/aad_oauth.dart'; import 'package:aad_oauth/model/config.dart'; import 'package:flutter/material.dart'; -void main() => runApp(new MyApp()); +void main() => runApp(MyApp()); class MyApp extends StatefulWidget { @override - _MyAppState createState() => new _MyAppState(); + _MyAppState createState() => _MyAppState(); } class _MyAppState extends State { @@ -17,12 +17,12 @@ class _MyAppState extends State { @override Widget build(BuildContext context) { - return new MaterialApp( + return MaterialApp( title: 'AAD B2C Demo', - theme: new ThemeData( + theme: ThemeData( primarySwatch: Colors.blue, ), - home: new MyHomePage(title: 'AAD B2C Home'), + home: MyHomePage(title: 'AAD B2C Home'), ); } } @@ -32,29 +32,29 @@ class MyHomePage extends StatefulWidget { final String title; @override - _MyHomePageState createState() => new _MyHomePageState(); + _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State { - static final Config configB2Ca = new Config( - tenant: "YOUR_TENANT_NAME", - clientId: "YOUR_CLIENT_ID", - scope: "YOUR_CLIENT_ID offline_access", - redirectUri: "https://login.live.com/oauth20_desktop.srf", - clientSecret: "YOUR_CLIENT_SECRET", + static final Config configB2Ca = Config( + tenant: 'YOUR_TENANT_NAME', + clientId: 'YOUR_CLIENT_ID', + scope: 'YOUR_CLIENT_ID offline_access', + redirectUri: 'https://login.live.com/oauth20_desktop.srf', + clientSecret: 'YOUR_CLIENT_SECRET', isB2C: true, - policy: "YOUR_USER_FLOW___USER_FLOW_A", - tokenIdentifier: "UNIQUE IDENTIFIER A"); - - static final Config configB2Cb = new Config( - tenant: "YOUR_TENANT_NAME", - clientId: "YOUR_CLIENT_ID", - scope: "YOUR_CLIENT_ID offline_access", - redirectUri: "https://login.live.com/oauth20_desktop.srf", - clientSecret: "YOUR_CLIENT_SECRET", + policy: 'YOUR_USER_FLOW___USER_FLOW_A', + tokenIdentifier: 'UNIQUE IDENTIFIER A'); + + static final Config configB2Cb = Config( + tenant: 'YOUR_TENANT_NAME', + clientId: 'YOUR_CLIENT_ID', + scope: 'YOUR_CLIENT_ID offline_access', + redirectUri: 'https://login.live.com/oauth20_desktop.srf', + clientSecret: 'YOUR_CLIENT_SECRET', isB2C: true, - policy: "YOUR_USER_FLOW___USER_FLOW_B", - tokenIdentifier: "UNIQUE IDENTIFIER B"); + policy: 'YOUR_USER_FLOW___USER_FLOW_B', + tokenIdentifier: 'UNIQUE IDENTIFIER B'); //You can have as many B2C flows as you want @@ -68,16 +68,16 @@ class _MyHomePageState extends State { Rect.fromLTWH(0.0, 25.0, screenSize.width, screenSize.height - 25); oauthB2Ca.setWebViewScreenSize(rectSize); - return new Scaffold( - appBar: new AppBar( - title: new Text(widget.title), + return Scaffold( + appBar: AppBar( + title: Text(widget.title), ), body: ListView( children: [ ListTile( title: Text( - "AzureAD B2C A", - style: Theme.of(context).textTheme.headline, + 'AzureAD B2C A', + style: Theme.of(context).textTheme.headline5, ), ), ListTile( @@ -97,8 +97,8 @@ class _MyHomePageState extends State { Divider(), ListTile( title: Text( - "AzureAD B2C B", - style: Theme.of(context).textTheme.headline, + 'AzureAD B2C B', + style: Theme.of(context).textTheme.headline5, ), ), ListTile( @@ -125,9 +125,9 @@ class _MyHomePageState extends State { } void showMessage(String text) { - var alert = new AlertDialog(content: new Text(text), actions: [ - new FlatButton( - child: const Text("Ok"), + var alert = AlertDialog(content: Text(text), actions: [ + FlatButton( + child: const Text('Ok'), onPressed: () { Navigator.pop(context); }) @@ -139,7 +139,7 @@ class _MyHomePageState extends State { try { await oAuth.login(); String accessToken = await oAuth.getAccessToken(); - showMessage("Logged in successfully, your access token: $accessToken"); + showMessage('Logged in successfully, your access token: $accessToken'); } catch (e) { showError(e); } @@ -147,6 +147,6 @@ class _MyHomePageState extends State { void logout(AadOAuth oAuth) async { await oAuth.logout(); - showMessage("Logged out"); + showMessage('Logged out'); } } diff --git a/examples/example_b2c/pubspec.lock b/example_b2c/pubspec.lock similarity index 78% rename from examples/example_b2c/pubspec.lock rename to example_b2c/pubspec.lock index 0ebd2b66..6d565cba 100644 --- a/examples/example_b2c/pubspec.lock +++ b/example_b2c/pubspec.lock @@ -4,66 +4,52 @@ packages: aad_oauth: dependency: "direct main" description: - path: "..\\.." + path: ".." relative: true source: path - version: "0.1.8" - archive: - dependency: transitive - description: - name: archive - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.11" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.5.2" + version: "0.2.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" + version: "2.5.0-nullsafety.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" - charcode: + version: "2.1.0-nullsafety.1" + characters: dependency: transitive description: - name: charcode + name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" - collection: + version: "1.1.0-nullsafety.3" + charcode: dependency: transitive description: - name: collection + name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" - convert: + version: "1.2.0-nullsafety.1" + clock: dependency: transitive description: - name: convert + name: clock url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" - crypto: + version: "1.1.0-nullsafety.1" + collection: dependency: transitive description: - name: crypto + name: collection url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "1.15.0-nullsafety.3" cupertino_icons: dependency: "direct main" description: @@ -71,6 +57,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.3" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0-nullsafety.1" flutter: dependency: "direct main" description: flutter @@ -114,55 +107,34 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.3" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.10-nullsafety.1" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0-nullsafety.3" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" + version: "1.8.0-nullsafety.1" pedantic: dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.8.0+1" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.0" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.5" + version: "1.9.2" shared_preferences: dependency: transitive description: @@ -202,63 +174,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.5.5" + version: "1.8.0-nullsafety.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0-nullsafety.1" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0-nullsafety.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.11" + version: "0.2.19-nullsafety.2" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0-nullsafety.3" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "3.5.0" + version: "2.1.0-nullsafety.3" sdks: - dart: ">=2.4.0 <3.0.0" + dart: ">=2.10.0-110 <2.11.0" flutter: ">=1.12.13+hotfix.4 <2.0.0" diff --git a/examples/example_b2c/pubspec.yaml b/example_b2c/pubspec.yaml similarity index 99% rename from examples/example_b2c/pubspec.yaml rename to example_b2c/pubspec.yaml index 2e75afdf..8a4d3239 100644 --- a/examples/example_b2c/pubspec.yaml +++ b/example_b2c/pubspec.yaml @@ -18,7 +18,7 @@ environment: dependencies: aad_oauth: - path: ../../ + path: ../ flutter: sdk: flutter @@ -30,13 +30,11 @@ dev_dependencies: flutter_test: sdk: flutter - # 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. 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. diff --git a/examples/example/test/widget_test.dart b/examples/example/test/widget_test.dart deleted file mode 100644 index 46ed7b8b..00000000 --- a/examples/example/test/widget_test.dart +++ /dev/null @@ -1,30 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility that Flutter provides. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import 'package:example_oauth/main.dart'; - -void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); - - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); -} diff --git a/examples/example_b2c/test/widget_test.dart b/examples/example_b2c/test/widget_test.dart deleted file mode 100644 index 27fd596e..00000000 --- a/examples/example_b2c/test/widget_test.dart +++ /dev/null @@ -1,29 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility that Flutter provides. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:aad_oauth_example_b2c/main.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); - - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); -} diff --git a/lib/aad_oauth.dart b/lib/aad_oauth.dart index d5151bf7..e0f8e363 100644 --- a/lib/aad_oauth.dart +++ b/lib/aad_oauth.dart @@ -18,9 +18,9 @@ class AadOAuth { AadOAuth(Config config) { _config = config; - _authStorage = new AuthStorage(tokenIdentifier: config.tokenIdentifier); - _requestCode = new RequestCode(_config); - _requestToken = new RequestToken(_config); + _authStorage = AuthStorage(tokenIdentifier: config.tokenIdentifier); + _requestCode = RequestCode(_config); + _requestToken = RequestToken(_config); } void setWebViewScreenSize(Rect screenSize) { @@ -29,20 +29,19 @@ class AadOAuth { Future login() async { await _removeOldTokenOnFirstLogin(); - if (!Token.tokenIsValid(_token) ) + if (!Token.tokenIsValid(_token)) { await _performAuthorization(); + } } Future getAccessToken() async { - if (!Token.tokenIsValid(_token) ) - await _performAuthorization(); + if (!Token.tokenIsValid(_token)) await _performAuthorization(); return _token.accessToken; } Future getIdToken() async { - if (!Token.tokenIsValid(_token) ) - await _performAuthorization(); + if (!Token.tokenIsValid(_token)) await _performAuthorization(); return _token.idToken; } @@ -62,12 +61,10 @@ class AadOAuth { // load token from cache _token = await _authStorage.loadTokenToCache(); - //still have refreh token / try to get new access token with refresh token - if (_token != null) + //still have refreh token / try to get access token with refresh token + if (_token != null) { await _performRefreshAuthFlow(); - - // if we have no refresh token try to perform full request code oauth flow - else { + } else { try { await _performFullAuthFlow(); } catch (e) { @@ -84,7 +81,7 @@ class AadOAuth { try { code = await _requestCode.requestCode(); if (code == null) { - throw new Exception("Access denied or authentation canceled."); + throw Exception('Access denied or authentation canceled.'); } _token = await _requestToken.requestToken(code); } catch (e) { @@ -103,10 +100,10 @@ class AadOAuth { } Future _removeOldTokenOnFirstLogin() async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - final _keyFreshInstall = "freshInstall"; + var prefs = await SharedPreferences.getInstance(); + final _keyFreshInstall = 'freshInstall'; if (!prefs.getKeys().contains(_keyFreshInstall)) { - logout(); + await logout(); await prefs.setBool(_keyFreshInstall, false); } } diff --git a/lib/helper/auth_storage.dart b/lib/helper/auth_storage.dart index 306230fd..523a6b61 100644 --- a/lib/helper/auth_storage.dart +++ b/lib/helper/auth_storage.dart @@ -1,20 +1,20 @@ import 'dart:async'; import 'package:aad_oauth/model/token.dart'; -import "dart:convert" as Convert; +import 'dart:convert' show jsonEncode, jsonDecode; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; class AuthStorage { - static AuthStorage shared = new AuthStorage(); - FlutterSecureStorage _secureStorage = FlutterSecureStorage(); + static AuthStorage shared = AuthStorage(); + final FlutterSecureStorage _secureStorage = FlutterSecureStorage(); String _tokenIdentifier; - AuthStorage({String tokenIdentifier = "Token"}) { + AuthStorage({String tokenIdentifier = 'Token'}) { _tokenIdentifier = tokenIdentifier; } Future saveTokenToCache(Token token) async { var data = Token.toJsonMap(token); - var json = Convert.jsonEncode(data); + var json = jsonEncode(data); await _secureStorage.write(key: _tokenIdentifier, value: json); } @@ -22,7 +22,7 @@ class AuthStorage { var json = await _secureStorage.read(key: _tokenIdentifier); if (json == null) return null; try { - var data = Convert.jsonDecode(json); + var data = jsonDecode(json); return _getTokenFromMap(data); } catch (exception) { print(exception); @@ -34,6 +34,6 @@ class AuthStorage { Token.fromJson(data); Future clear() async { - _secureStorage.delete(key: _tokenIdentifier); + await _secureStorage.delete(key: _tokenIdentifier); } } diff --git a/lib/model/config.dart b/lib/model/config.dart index 0d1d4747..15237448 100644 --- a/lib/model/config.dart +++ b/lib/model/config.dart @@ -41,7 +41,7 @@ class Config { {@required this.tenant, this.policy, @required this.clientId, - this.responseType = "code", + this.responseType = 'code', @required this.redirectUri, @required this.scope, this.responseMode, @@ -49,20 +49,20 @@ class Config { this.prompt, this.codeChallenge, this.codeChallengeMethod, - this.nonce = "12345", + this.nonce = '12345', this.tokenIdentifier, this.clientSecret, - this.contentType = "application/x-www-form-urlencoded", + this.contentType = 'application/x-www-form-urlencoded', this.resource, this.isB2C = false, this.loginHint, this.domainHint, this.codeVerifier}) { - this.authorizationUrl = isB2C - ? "https://$tenant.b2clogin.com/$tenant.onmicrosoft.com/$policy/oauth2/v2.0/authorize" - : "https://login.microsoftonline.com/$tenant/oauth2/v2.0/authorize"; - this.tokenUrl = isB2C - ? "https://$tenant.b2clogin.com/$tenant.onmicrosoft.com/$policy/oauth2/v2.0/token" - : "https://login.microsoftonline.com/$tenant/oauth2/v2.0/token"; + authorizationUrl = isB2C + ? 'https://$tenant.b2clogin.com/$tenant.onmicrosoft.com/$policy/oauth2/v2.0/authorize' + : 'https://login.microsoftonline.com/$tenant/oauth2/v2.0/authorize'; + tokenUrl = isB2C + ? 'https://$tenant.b2clogin.com/$tenant.onmicrosoft.com/$policy/oauth2/v2.0/token' + : 'https://login.microsoftonline.com/$tenant/oauth2/v2.0/token'; } } diff --git a/lib/model/token.dart b/lib/model/token.dart index 8bc26e7f..3f3dd076 100644 --- a/lib/model/token.dart +++ b/lib/model/token.dart @@ -20,57 +20,58 @@ class Token { String toString() => Token.toJsonMap(this).toString(); static Map toJsonMap(Token model) { - Map ret = new Map(); + var ret = {}; if (model != null) { if (model.accessToken != null) { - ret["access_token"] = model.accessToken; + ret['access_token'] = model.accessToken; } if (model.tokenType != null) { - ret["token_type"] = model.tokenType; + ret['token_type'] = model.tokenType; } if (model.refreshToken != null) { - ret["refresh_token"] = model.refreshToken; + ret['refresh_token'] = model.refreshToken; } if (model.expiresIn != null) { - ret["expires_in"] = model.expiresIn; + ret['expires_in'] = model.expiresIn; } if (model.expireTimeStamp != null) { - ret["expire_timestamp"] = model.expireTimeStamp.millisecondsSinceEpoch; + ret['expire_timestamp'] = model.expireTimeStamp.millisecondsSinceEpoch; } if (model.idToken != null) { - ret["id_token"] = model.idToken; + ret['id_token'] = model.idToken; } } return ret; } static Token fromMap(Map map) { - if (map == null) throw new Exception("No token from received"); + if (map == null) throw Exception('No token from received'); //error handling as described in https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow#error-response-1 - if (map["error"] != null) - throw new Exception("Error during token request: " + - map["error"] + - ": " + - map["error_description"]); + if (map['error'] != null) { + throw Exception('Error during token request: ' + + map['error'] + + ': ' + + map['error_description']); + } - Token model = new Token(); - model.accessToken = map["access_token"]; - model.tokenType = map["token_type"]; - model.expiresIn = map["expires_in"] is int - ? map["expires_in"] - : int.tryParse(map["expires_in"].toString()) ?? 60; - model.refreshToken = map["refresh_token"]; - model.idToken = map.containsKey("id_token") ? map["id_token"] : ''; - model.issueTimeStamp = new DateTime.now().toUtc(); - model.expireTimeStamp = map.containsKey("expire_timestamp") - ? DateTime.fromMillisecondsSinceEpoch(map["expire_timestamp"]) + var model = Token(); + model.accessToken = map['access_token']; + model.tokenType = map['token_type']; + model.expiresIn = map['expires_in'] is int + ? map['expires_in'] + : int.tryParse(map['expires_in'].toString()) ?? 60; + model.refreshToken = map['refresh_token']; + model.idToken = map.containsKey('id_token') ? map['id_token'] : ''; + model.issueTimeStamp = DateTime.now().toUtc(); + model.expireTimeStamp = map.containsKey('expire_timestamp') + ? DateTime.fromMillisecondsSinceEpoch(map['expire_timestamp']) : model.issueTimeStamp - .add(new Duration(seconds: model.expiresIn - model.expireOffSet)); + .add(Duration(seconds: model.expiresIn - model.expireOffSet)); return model; } static bool isExpired(Token token) { - return token.expireTimeStamp.isBefore(new DateTime.now().toUtc()); + return token.expireTimeStamp.isBefore(DateTime.now().toUtc()); } static bool tokenIsValid(Token token) { diff --git a/lib/request/authorization_request.dart b/lib/request/authorization_request.dart index 0d40e44d..f6d65639 100644 --- a/lib/request/authorization_request.dart +++ b/lib/request/authorization_request.dart @@ -9,42 +9,49 @@ class AuthorizationRequest { bool clearCookies; AuthorizationRequest(Config config, - {bool fullScreen: true, bool clearCookies: false}) { + {bool fullScreen = true, bool clearCookies = false}) { url = config.authorizationUrl; redirectUrl = config.redirectUri; parameters = { - "client_id": config.clientId, - "response_type": config.responseType, - "redirect_uri": config.redirectUri, - "scope": config.scope, - "state": config.state, + 'client_id': config.clientId, + 'response_type': config.responseType, + 'redirect_uri': config.redirectUri, + 'scope': config.scope, + 'state': config.state, }; - if (config.responseMode != null) - parameters.putIfAbsent("response_mode", () => config.responseMode); + if (config.responseMode != null) { + parameters.putIfAbsent('response_mode', () => config.responseMode); + } - if (config.prompt != null) - parameters.putIfAbsent("prompt", () => config.prompt); + if (config.prompt != null) { + parameters.putIfAbsent('prompt', () => config.prompt); + } - if (config.loginHint != null) - parameters.putIfAbsent("login_hint", () => config.loginHint); + if (config.loginHint != null) { + parameters.putIfAbsent('login_hint', () => config.loginHint); + } - if (config.domainHint != null) - parameters.putIfAbsent("domain_hint", () => config.domainHint); + if (config.domainHint != null) { + parameters.putIfAbsent('domain_hint', () => config.domainHint); + } - if (config.codeVerifier != null) - parameters.putIfAbsent("code_verifier", () => config.codeVerifier); + if (config.codeVerifier != null) { + parameters.putIfAbsent('code_verifier', () => config.codeVerifier); + } - if (config.codeChallenge != null) - parameters.putIfAbsent("code_challenge", () => config.codeChallenge); + if (config.codeChallenge != null) { + parameters.putIfAbsent('code_challenge', () => config.codeChallenge); + } - if (config.codeChallengeMethod != null) + if (config.codeChallengeMethod != null) { parameters.putIfAbsent( - "code_challenge_method", () => config.codeChallengeMethod); + 'code_challenge_method', () => config.codeChallengeMethod); + } if (config.isB2C) { parameters.addAll({ - "nonce": config.nonce, + 'nonce': config.nonce, }); } diff --git a/lib/request/token_refresh_request.dart b/lib/request/token_refresh_request.dart index 4ee51279..6b8bf32f 100644 --- a/lib/request/token_refresh_request.dart +++ b/lib/request/token_refresh_request.dart @@ -6,20 +6,21 @@ class TokenRefreshRequestDetails { Map headers; TokenRefreshRequestDetails(Config config, String refreshToken) { - this.url = config.tokenUrl; - this.params = { - "client_id": config.clientId, - "scope": config.scope, - "redirect_uri": config.redirectUri, - "grant_type": "refresh_token", - "refresh_token": refreshToken + url = config.tokenUrl; + params = { + 'client_id': config.clientId, + 'scope': config.scope, + 'redirect_uri': config.redirectUri, + 'grant_type': 'refresh_token', + 'refresh_token': refreshToken }; - if (config.clientSecret != null) - params.putIfAbsent("client_secret", () => config.clientSecret); + if (config.clientSecret != null) { + params.putIfAbsent('client_secret', () => config.clientSecret); + } - this.headers = { - "Accept": "application/json", - "Content-Type": config.contentType + headers = { + 'Accept': 'application/json', + 'Content-Type': config.contentType }; } } diff --git a/lib/request/token_request.dart b/lib/request/token_request.dart index ed63ebf7..ad5a951d 100644 --- a/lib/request/token_request.dart +++ b/lib/request/token_request.dart @@ -6,27 +6,30 @@ class TokenRequestDetails { Map headers; TokenRequestDetails(Config config, String code) { - this.url = config.tokenUrl; - this.params = { - "client_id": config.clientId, - "grant_type": "authorization_code", - "scope": config.scope, - "code": code, - "redirect_uri": config.redirectUri, + url = config.tokenUrl; + params = { + 'client_id': config.clientId, + 'grant_type': 'authorization_code', + 'scope': config.scope, + 'code': code, + 'redirect_uri': config.redirectUri, }; - if (config.resource != null) - params.putIfAbsent("resource", () => config.resource); + if (config.resource != null) { + params.putIfAbsent('resource', () => config.resource); + } - if (config.clientSecret != null) - params.putIfAbsent("client_secret", () => config.clientSecret); + if (config.clientSecret != null) { + params.putIfAbsent('client_secret', () => config.clientSecret); + } - if (config.codeVerifier != null) - params.putIfAbsent("code_verifier", () => config.codeVerifier); + if (config.codeVerifier != null) { + params.putIfAbsent('code_verifier', () => config.codeVerifier); + } - this.headers = { - "Accept": "application/json", - "Content-Type": config.contentType + headers = { + 'Accept': 'application/json', + 'Content-Type': config.contentType }; } } diff --git a/lib/request_code.dart b/lib/request_code.dart index 582b473e..5bcdcb5f 100644 --- a/lib/request_code.dart +++ b/lib/request_code.dart @@ -1,45 +1,42 @@ import 'dart:async'; -import 'dart:ui'; -import 'package:flutter/widgets.dart'; import 'request/authorization_request.dart'; import 'model/config.dart'; import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; class RequestCode { - final StreamController _onCodeListener = new StreamController(); - final FlutterWebviewPlugin _webView = new FlutterWebviewPlugin(); + final StreamController _onCodeListener = StreamController(); + final FlutterWebviewPlugin _webView = FlutterWebviewPlugin(); final Config _config; AuthorizationRequest _authorizationRequest; var _onCodeStream; - + RequestCode(Config config) : _config = config { - _authorizationRequest = new AuthorizationRequest(config); + _authorizationRequest = AuthorizationRequest(config); } Future requestCode() async { String code; - final String urlParams = _constructUrlParams(); - + final urlParams = _constructUrlParams(); + await _webView.launch( - Uri.encodeFull("${_authorizationRequest.url}?$urlParams"), - clearCookies: _authorizationRequest.clearCookies, - hidden: false, - rect: _config.screenSize - ); + Uri.encodeFull('${_authorizationRequest.url}?$urlParams'), + clearCookies: _authorizationRequest.clearCookies, + hidden: false, + rect: _config.screenSize); _webView.onUrlChanged.listen((String url) { - Uri uri = Uri.parse(url); + var uri = Uri.parse(url); - if(uri.queryParameters["error"] != null) { + if (uri.queryParameters['error'] != null) { _webView.close(); _onCodeListener.add(null); } - - if (uri.queryParameters["code"] != null) { + + if (uri.queryParameters['code'] != null) { _webView.close(); - _onCodeListener.add(uri.queryParameters["code"]); - } + _onCodeListener.add(uri.queryParameters['code']); + } }); code = await _onCode.first; @@ -47,19 +44,20 @@ class RequestCode { } Future clearCookies() async { - await _webView.launch("", hidden: true, clearCookies: true); + await _webView.launch('', hidden: true, clearCookies: true); await _webView.close(); } Stream get _onCode => _onCodeStream ??= _onCodeListener.stream.asBroadcastStream(); - String _constructUrlParams() => _mapToQueryParams(_authorizationRequest.parameters); + String _constructUrlParams() => + _mapToQueryParams(_authorizationRequest.parameters); String _mapToQueryParams(Map params) { final queryParams = []; params - .forEach((String key, String value) => queryParams.add("$key=$value")); - return queryParams.join("&"); + .forEach((String key, String value) => queryParams.add('$key=$value')); + return queryParams.join('&'); } } diff --git a/lib/request_token.dart b/lib/request_token.dart index 27fd3337..a326070b 100644 --- a/lib/request_token.dart +++ b/lib/request_token.dart @@ -15,28 +15,29 @@ class RequestToken { Future requestToken(String code) async { _generateTokenRequest(code); - return await _sendTokenRequest(_tokenRequest.url, _tokenRequest.params, _tokenRequest.headers); + return await _sendTokenRequest( + _tokenRequest.url, _tokenRequest.params, _tokenRequest.headers); } - Future requestRefreshToken(String refreshToken) async { + Future requestRefreshToken(String refreshToken) async { _generateTokenRefreshRequest(refreshToken); - return await _sendTokenRequest(_tokenRefreshRequest.url, _tokenRefreshRequest.params, _tokenRefreshRequest.headers); + return await _sendTokenRequest(_tokenRefreshRequest.url, + _tokenRefreshRequest.params, _tokenRefreshRequest.headers); } - Future _sendTokenRequest(String url, Map params, Map headers) async { - Response response = await post(url, - body: params, - headers: headers); + Future _sendTokenRequest(String url, Map params, + Map headers) async { + var response = await post(url, body: params, headers: headers); Map tokenJson = json.decode(response.body); - Token token = new Token.fromJson(tokenJson); + var token = Token.fromJson(tokenJson); return token; } void _generateTokenRequest(String code) { - _tokenRequest = new TokenRequestDetails(config, code); + _tokenRequest = TokenRequestDetails(config, code); } void _generateTokenRefreshRequest(String refreshToken) { - _tokenRefreshRequest = new TokenRefreshRequestDetails(config, refreshToken); - } -} \ No newline at end of file + _tokenRefreshRequest = TokenRefreshRequestDetails(config, refreshToken); + } +} diff --git a/pubspec.lock b/pubspec.lock index 3a24f3ef..a24a41e9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,62 +1,55 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - archive: - dependency: transitive - description: - name: archive - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.13" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.5.0-nullsafety.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0-nullsafety.3" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" - collection: + version: "1.2.0-nullsafety.1" + clock: dependency: transitive description: - name: collection + name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.14.12" - convert: + version: "1.1.0-nullsafety.1" + collection: dependency: transitive description: - name: convert + name: collection url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" - crypto: + version: "1.15.0-nullsafety.3" + fake_async: dependency: transitive description: - name: crypto + name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "1.2.0-nullsafety.1" flutter: dependency: "direct main" description: flutter @@ -95,48 +88,34 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.3" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.12" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.10-nullsafety.1" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0-nullsafety.3" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.0" - quiver: - dependency: transitive + version: "1.8.0-nullsafety.1" + pedantic: + dependency: "direct main" description: - name: quiver + name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "1.9.2" shared_preferences: dependency: "direct main" description: @@ -155,63 +134,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0-nullsafety.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0-nullsafety.1" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0-nullsafety.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.15" + version: "0.2.19-nullsafety.2" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0-nullsafety.3" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "3.6.1" + version: "2.1.0-nullsafety.3" sdks: - dart: ">=2.6.0 <3.0.0" + dart: ">=2.10.0-110 <2.11.0" flutter: ">=1.5.0 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index ffec8736..9a247a16 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,6 +13,7 @@ dependencies: shared_preferences: ^0.5.2 flutter: sdk: flutter + pedantic: ^1.9.0 dev_dependencies: flutter_test: diff --git a/test/aad_oauth_test.dart b/test/aad_oauth_test.dart deleted file mode 100644 index a9ce4cce..00000000 --- a/test/aad_oauth_test.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; - -import 'package:aad_oauth/aad_oauth.dart'; -import 'package:aad_oauth/model/config.dart'; - -void main() { - test('adds one to input values', () { - final Config config = new Config( - "YOUR TENANT ID", - "YOUR CLIENT ID", - "openid profile offline_access"); - final AadOAuth oauth = new AadOAuth(config); - - //TODO testing - - }); -}