├── .gitignore ├── .metadata ├── LICENSE ├── README.md ├── android ├── .gitignore ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── settings.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── kotlin │ └── com │ └── pycampers │ └── flutter_cognito_plugin │ ├── Cognito.kt │ ├── FlutterCognitoPlugin.kt │ └── serializer.kt ├── example ├── .gitignore ├── .metadata ├── README.md ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── pycampers │ │ │ │ │ └── flutter_cognito_plugin_example │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── Podfile.lock │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h ├── lib │ └── main.dart ├── pubspec.lock └── pubspec.yaml ├── flutter_cognito_plugin.iml ├── ios ├── .gitignore ├── Assets │ └── .gitkeep ├── Classes │ ├── Cognito.swift │ ├── FlutterCognitoPlugin.h │ ├── FlutterCognitoPlugin.m │ ├── SwiftFlutterCognitoPlugin.swift │ └── serializer.swift └── flutter_cognito_plugin.podspec ├── lib ├── exception_serializer.dart ├── exceptions.dart ├── flutter_cognito_plugin.dart └── models.dart ├── pubspec.lock └── pubspec.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .dart_tool/ 3 | 4 | .packages 5 | .pub/ 6 | 7 | build/ 8 | 9 | **/awsconfiguration.json 10 | .idea/ 11 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 0b8abb4724aa590dd0f429683339b1e045a1594d 8 | channel: stable 9 | 10 | project_type: plugin 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Sponsor](https://img.shields.io/badge/Sponsor-jaaga_labs-red.svg?style=for-the-badge)](https://www.jaaga.in/labs) 2 | [![pub package](https://img.shields.io/pub/v/flutter_cognito_plugin.svg?style=for-the-badge)](https://pub.dartlang.org/packages/flutter_cognito_plugin) 3 | 4 | # Flutter Cognito Plugin 5 | 6 | An AWS Cognito plugin for flutter. Supports both iOS and Android. 7 | 8 | ## Installation 9 | 10 | First follow the regular flutter plugin installation on [Dart Pub](https://pub.dartlang.org/packages/flutter_cognito_plugin#-installing-tab-). 11 | 12 | _Make sure you have built the app once for both Android/iOS before continuing._ 13 | 14 | --- 15 | 16 | Since this plugin uses the native AWS sdk, the installation is a little more involved. 17 | 18 | ### Android 19 | 20 | Add an `awsconfiguration.json` file to `android/app/src/main/res/raw/awsconfiguration.json`. 21 | 22 | This is what one should look like :- 23 | 24 | ```json 25 | { 26 | "IdentityManager": { 27 | "Default": {} 28 | }, 29 | "CredentialsProvider": { 30 | "CognitoIdentity": { 31 | "Default": { 32 | "PoolId": "XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab", 33 | "Region": "XX-XXXX-X" 34 | } 35 | } 36 | }, 37 | "CognitoUserPool": { 38 | "Default": { 39 | "PoolId": "XX-XXXX-X_abcd1234", 40 | "AppClientId": "XXXXXXXX", 41 | "AppClientSecret": "XXXXXXXXX", 42 | "Region": "XX-XXXX-X" 43 | } 44 | } 45 | } 46 | ``` 47 | 48 | This plugin supports the amplify SDK for android and iOS, 49 | and the the amplify cli can be used to generate the `awsconfiguration.json` file. 50 | 51 | Just do `$ amplify init` from the `android` & `ios` folder of your app. 52 | 53 | ### iOS 54 | 55 | Run `$ pod init` from the `ios` folder of your app. 56 | 57 | Now, open `ios/Podfile`. Ensure ios version is set to a minimum of `9.0`. 58 | 59 | ```podspec 60 | platform :ios, '9.0' 61 | ``` 62 | 63 | To add the `awsconfiguration.json` file to iOS module, you will unfortunately, 64 | need to open up your project in XCode. 65 | 66 | 1. Start Xcode 67 | 2. Click on ‘File > Open’ 68 | 3. Select the `ios/Runner.xcworkspace` file. 69 | 70 | Now just drag-drop the `awsconfiguration.json` file, from `android/app/src/main/res/raw/awsconfiguration.json` to XCode Runner (Right next to `AppDelegate.swift`). 71 | 72 | [Here](https://i.imgur.com/tAXQuQ3.mp4) is a video. 73 | 74 | That should create a symlink to the file in the ios module, and bundle it into the final ios app. 75 | 76 | This way you won't need to maintain 2 config files. 77 | 78 | ## Hosted UI 79 | 80 | The [Hosted UI](https://docs.amplify.aws/sdk/auth/hosted-ui/q/platform/android) feature is needed for using Social login. 81 | Unfortunately, this requires you to modify native code in your app. 82 | 83 | First, add the following section to `android/app/src/main/res/raw/awsconfiguration.json` - 84 | 85 | (`"myapp://callback"` and `"myapp://signout"` are custom urls you can provide in the "App client settings" section of Cognito User Pools) 86 | 87 | ``` 88 | { 89 | ... 90 | 91 | "Auth": { 92 | "Default": { 93 | "OAuth": { 94 | "WebDomain": "XXX.auth.ap-south-1.amazoncognito.com", 95 | "AppClientId": "XXXXXXXX", 96 | "AppClientSecret": "XXXXX" 97 | "SignInRedirectURI": "myapp://callback", 98 | "SignOutRedirectURI": "myapp://signout", 99 | "Scopes": ["email, "openid"] 100 | } 101 | } 102 | } 103 | } 104 | ``` 105 | 106 | ### Android 107 | 108 | 1. Open your app's [`andorid/app/src/main/com/kotlin/.../MainActivity.kt`](example/android/app/src/main/kotlin/com/pycampers/flutter_cognito_plugin_example/MainActivity.kt) 109 | and replace `FlutterActivity()` by `CognitoPluginActivity("")`. 110 | 111 | Here's what it should look like - 112 | 113 | ```kotlin 114 | package ... 115 | 116 | import androidx.annotation.NonNull 117 | import com.pycampers.flutter_cognito_plugin.CognitoPluginActivity 118 | import io.flutter.embedding.engine.FlutterEngine 119 | import io.flutter.plugins.GeneratedPluginRegistrant 120 | 121 | class MainActivity : CognitoPluginActivity("myapp") { 122 | override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { 123 | GeneratedPluginRegistrant.registerWith(flutterEngine); 124 | } 125 | } 126 | ``` 127 | 128 | 2. Add the following to [`android/app/src/main/AndroidManifest.xml`](example/android/app/src/main/AndroidManifest.xml) - 129 | 130 | ```xml 131 | 132 | 133 | ... 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | ``` 148 | 149 | ### iOS 150 | 151 | 1. Open you apps's [`ios/Runner/AppDelegate.swift`](example/ios/Runner/AppDelegate.swift), 152 | and replace `FlutterAppDelegate` with `CognitoPluginAppDelegate`. 153 | 154 | Here's what it should look like - 155 | 156 | ```swift 157 | import Flutter 158 | import flutter_cognito_plugin 159 | import UIKit 160 | 161 | @UIApplicationMain 162 | @objc class AppDelegate: CognitoPluginAppDelegate { 163 | override func application( 164 | _ application: UIApplication, 165 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 166 | ) -> Bool { 167 | GeneratedPluginRegistrant.register(with: self) 168 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 169 | } 170 | } 171 | ``` 172 | 173 | 2. Add the following to [`ios/Runner/Info.plist`](example/ios/Runner/Info.plist) 174 | 175 | ``` 176 | 177 | 178 | 179 | 180 | 181 | 182 | CFBundleURLTypes 183 | 184 | 185 | CFBundleURLSchemes 186 | 187 | myapp 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | ``` 197 | 198 | ### Dart 199 | 200 | Once the native setup is complete, you can use the following in your flutter app to launch the Hosted UI - 201 | 202 | ```dart 203 | Cognito.showSignIn( 204 | identityProvider: "Cognito", 205 | scopes: ["email", "openid"], 206 | ); 207 | ``` 208 | 209 | ## Usage 210 | 211 | The plugin comes with a showcase app that will let you try all features -- 212 | given that you setup the `awsconfiguration.json` correctly. 213 | 214 | 215 | 216 | It's present in the usual [`example`](https://github.com/scientifichackers/flutter_cognito_plugin/blob/master/example/lib/main.dart) directory 217 | 218 | ``` 219 | $ git clone https://github.com/pycampers/flutter_cognito_plugin.git 220 | $ cd flutter_cognito_plugin/example 221 | $ flutter run 222 | ``` 223 | 224 | ## AppSync 225 | 226 | You can use AWS AppSync GraphQL API using this plugin easily. Just pass in the query as a String, and the query variables! 227 | 228 | ```dart 229 | import 'dart:convert'; 230 | import 'dart:io'; 231 | 232 | import 'package:flutter_cognito_plugin/flutter_cognito_plugin.dart'; 233 | import 'package:http/http.dart' as http; 234 | 235 | 236 | static Future query( 237 | String query, 238 | Map variables, 239 | ) async { 240 | final tokens = await Cognito.getTokens(); 241 | 242 | final response = await http.post( 243 | graphQLEndpoint, 244 | headers: { 245 | HttpHeaders.authorizationHeader: tokens.accessToken, 246 | HttpHeaders.contentTypeHeader: ContentType.json.mimeType, 247 | }, 248 | body: jsonEncode({ 249 | "query": query, 250 | "variables": variables, 251 | }), 252 | ); 253 | 254 | if (response.statusCode == HttpStatus.ok) { 255 | return jsonDecode(response.body); 256 | } 257 | 258 | print( 259 | "http request failed! { statusCode: ${response.statusCode}, body: ${response.body} }", 260 | ); 261 | return null; 262 | } 263 | ``` 264 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | group 'com.pycampers.flutter_cognito_plugin' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.3.50' 6 | repositories { 7 | google() 8 | jcenter() 9 | } 10 | 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:3.5.0' 13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 14 | } 15 | } 16 | 17 | rootProject.allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | } 22 | } 23 | 24 | apply plugin: 'com.android.library' 25 | apply plugin: 'kotlin-android' 26 | 27 | android { 28 | compileSdkVersion 28 29 | 30 | sourceSets { 31 | main.java.srcDirs += 'src/main/kotlin' 32 | } 33 | defaultConfig { 34 | minSdkVersion 16 35 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 36 | } 37 | lintOptions { 38 | disable 'InvalidPackage' 39 | } 40 | } 41 | 42 | dependencies { 43 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 44 | implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.18.0' 45 | implementation 'com.amazonaws:aws-android-sdk-cognitoauth:2.18.0' 46 | } 47 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip 6 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'flutter_cognito_plugin' 2 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/pycampers/flutter_cognito_plugin/Cognito.kt: -------------------------------------------------------------------------------- 1 | package com.pycampers.flutter_cognito_plugin 2 | 3 | import android.app.Activity 4 | import android.content.Context 5 | import com.amazonaws.auth.CognitoCachingCredentialsProvider 6 | import com.amazonaws.mobile.client.AWSMobileClient 7 | import com.amazonaws.mobile.client.Callback 8 | import com.amazonaws.mobile.client.HostedUIOptions 9 | import com.amazonaws.mobile.client.SignInUIOptions 10 | import com.amazonaws.mobile.client.SignOutOptions 11 | import com.amazonaws.mobile.client.UserStateDetails 12 | import com.amazonaws.mobile.client.results.ForgotPasswordResult 13 | import com.amazonaws.mobile.client.results.SignInResult 14 | import com.amazonaws.mobile.client.results.SignUpResult 15 | import com.amazonaws.mobile.client.results.Tokens 16 | import com.amazonaws.mobile.client.results.UserCodeDeliveryDetails 17 | import com.pycampers.plugin_scaffold.sendThrowable 18 | import com.pycampers.plugin_scaffold.trySend 19 | import io.flutter.plugin.common.MethodCall 20 | import io.flutter.plugin.common.MethodChannel.Result 21 | 22 | class Cognito(val context: Context) { 23 | var activity: Activity? = null 24 | val awsClient = AWSMobileClient.getInstance()!! 25 | 26 | fun initialize(call: MethodCall, result: Result) { 27 | awsClient.initialize(context, object : Callback { 28 | override fun onResult(u: UserStateDetails) { 29 | trySend(result) { dumpUserState(u) } 30 | } 31 | 32 | override fun onError(e: Exception) { 33 | sendThrowable(result, e) 34 | } 35 | }) 36 | } 37 | 38 | fun signUp(call: MethodCall, result: Result) { 39 | val username = call.argument("username") 40 | val password = call.argument("password") 41 | val userAttributes = call.argument>("userAttributes") 42 | 43 | awsClient.signUp(username, password, userAttributes, null, object : Callback { 44 | override fun onResult(s: SignUpResult) = trySend(result) { dumpSignUpResult(s) } 45 | override fun onError(e: Exception) = sendThrowable(result, e) 46 | }) 47 | } 48 | 49 | fun confirmSignUp(call: MethodCall, result: Result) { 50 | val username = call.argument("username") 51 | val confirmationCode = call.argument("confirmationCode") 52 | 53 | awsClient.confirmSignUp(username, confirmationCode, object : Callback { 54 | override fun onResult(s: SignUpResult) = trySend(result) { dumpSignUpResult(s) } 55 | override fun onError(e: Exception) = sendThrowable(result, e) 56 | }) 57 | } 58 | 59 | fun resendSignUp(call: MethodCall, result: Result) { 60 | val username = call.argument("username") 61 | 62 | awsClient.resendSignUp(username, object : Callback { 63 | override fun onResult(s: SignUpResult) = trySend(result) { dumpSignUpResult(s) } 64 | override fun onError(e: Exception) = sendThrowable(result, e) 65 | }) 66 | } 67 | 68 | fun signIn(call: MethodCall, result: Result) { 69 | val username = call.argument("username") 70 | val password = call.argument("password") 71 | 72 | awsClient.signIn(username, password, null, object : Callback { 73 | override fun onResult(s: SignInResult) = trySend(result) { dumpSignInResult(s) } 74 | override fun onError(e: Exception) = sendThrowable(result, e) 75 | }) 76 | } 77 | 78 | fun confirmSignIn(call: MethodCall, result: Result) { 79 | val confirmationCode = call.argument("confirmationCode") 80 | 81 | awsClient.confirmSignIn(confirmationCode, object : Callback { 82 | override fun onResult(s: SignInResult) = trySend(result) { dumpSignInResult(s) } 83 | override fun onError(e: Exception) = sendThrowable(result, e) 84 | }) 85 | } 86 | 87 | fun changePassword(call: MethodCall, result: Result) { 88 | val oldPassword = call.argument("oldPassword") 89 | val newPassword = call.argument("newPassword") 90 | 91 | awsClient.changePassword(oldPassword, newPassword, object : Callback { 92 | override fun onResult(u: Void?) = trySend(result) 93 | override fun onError(e: Exception) = sendThrowable(result, e) 94 | }) 95 | } 96 | 97 | fun forgotPassword(call: MethodCall, result: Result) { 98 | val username = call.argument("username") 99 | 100 | awsClient.forgotPassword(username, object : Callback { 101 | override fun onResult(f: ForgotPasswordResult) { 102 | trySend(result) { dumpForgotPasswordResult(f) } 103 | } 104 | 105 | override fun onError(e: Exception) = sendThrowable(result, e) 106 | }) 107 | } 108 | 109 | fun confirmForgotPassword(call: MethodCall, result: Result) { 110 | val newPassword = call.argument("newPassword") 111 | val confirmationCode = call.argument("confirmationCode") 112 | 113 | awsClient.confirmForgotPassword( 114 | newPassword, 115 | confirmationCode, 116 | object : Callback { 117 | override fun onResult(f: ForgotPasswordResult) = 118 | trySend(result) { dumpForgotPasswordResult(f) } 119 | 120 | override fun onError(e: Exception) = sendThrowable(result, e) 121 | }) 122 | } 123 | 124 | fun getUserAttributes(call: MethodCall, result: Result) { 125 | awsClient.getUserAttributes(object : Callback> { 126 | override fun onResult(attrs: Map?) = trySend(result) { attrs } 127 | override fun onError(e: Exception) = sendThrowable(result, e) 128 | }) 129 | } 130 | 131 | fun updateUserAttributes(call: MethodCall, result: Result) { 132 | val userAttributes = call.argument>("userAttributes")!! 133 | 134 | awsClient.updateUserAttributes( 135 | userAttributes, 136 | object : Callback> { 137 | override fun onResult(u: List) { 138 | trySend(result) { 139 | u.map { dumpUserCodeDeliveryDetails(it) } 140 | } 141 | } 142 | 143 | override fun onError(e: Exception) = sendThrowable(result, e) 144 | } 145 | ) 146 | } 147 | 148 | fun confirmUpdateUserAttribute(call: MethodCall, result: Result) { 149 | val attributeName = call.argument("attributeName")!! 150 | val confirmationCode = call.argument("confirmationCode")!! 151 | 152 | awsClient.confirmUpdateUserAttribute( 153 | attributeName, 154 | confirmationCode, 155 | object : Callback { 156 | override fun onResult(u: Void) = trySend(result) { u } 157 | override fun onError(e: Exception) = sendThrowable(result, e) 158 | }) 159 | } 160 | 161 | fun signOut(call: MethodCall, result: Result) { 162 | val invalidateTokens = call.argument("invalidateTokens")!! 163 | val signOutGlobally = call.argument("signOutGlobally")!! 164 | 165 | val options = SignOutOptions 166 | .builder() 167 | .invalidateTokens(invalidateTokens) 168 | .signOutGlobally(signOutGlobally) 169 | .build() 170 | 171 | awsClient.signOut( 172 | options, 173 | object : Callback { 174 | override fun onResult(v: Void?) = trySend(result) 175 | override fun onError(e: Exception) = sendThrowable(result, e) 176 | } 177 | ) 178 | } 179 | 180 | fun getUsername(call: MethodCall, result: Result) { 181 | result.success(awsClient.username) 182 | } 183 | 184 | fun isSignedIn(call: MethodCall, result: Result) { 185 | result.success(awsClient.isSignedIn) 186 | } 187 | 188 | fun getIdentityId(call: MethodCall, result: Result) { 189 | result.success(awsClient.identityId) 190 | } 191 | 192 | fun currentUserState(call: MethodCall, result: Result) { 193 | result.success(awsClient.currentUserState()?.userState?.ordinal) 194 | } 195 | 196 | fun getTokens(call: MethodCall, result: Result) { 197 | awsClient.getTokens(object : Callback { 198 | override fun onResult(t: Tokens?) = trySend(result) { t?.let { dumpTokens(it) } ?: t } 199 | override fun onError(e: Exception) = sendThrowable(result, e) 200 | }) 201 | } 202 | 203 | fun getCredentials(call: MethodCall, result: Result) { 204 | result.success( 205 | dumpCredentials( 206 | CognitoCachingCredentialsProvider( 207 | context, 208 | awsClient.configuration 209 | ) 210 | ) 211 | ) 212 | } 213 | 214 | fun federatedSignIn(call: MethodCall, result: Result) { 215 | val providerName = call.argument("providerName") 216 | val token = call.argument("token") 217 | 218 | awsClient.federatedSignIn(providerName, token, object : Callback { 219 | override fun onResult(u: UserStateDetails) = trySend(result) { dumpUserState(u) } 220 | override fun onError(e: Exception) = sendThrowable(result, e) 221 | }) 222 | } 223 | 224 | fun showSignIn(call: MethodCall, result: Result) { 225 | if (activity == null) { 226 | result.error( 227 | "ActivityNotAvailable", 228 | "This method cannot be called without an Activity.\n" + 229 | "Did you forget to replace `FlutterActivity` by `CognitoPluginActivity` in your app's MainActivity.kt?", 230 | null 231 | ) 232 | return 233 | } 234 | 235 | val scopes = call.argument>("scopes")!! 236 | val identityProvider = call.argument("identityProvider")!! 237 | 238 | val hostedUIOptions = HostedUIOptions.builder() 239 | .scopes(*scopes.toTypedArray()) 240 | .identityProvider(identityProvider) 241 | .build() 242 | val signInUIOptions = SignInUIOptions.builder() 243 | .hostedUIOptions(hostedUIOptions) 244 | .build() 245 | 246 | AWSMobileClient.getInstance().showSignIn( 247 | activity, 248 | signInUIOptions, 249 | object : Callback { 250 | override fun onResult(u: UserStateDetails) = trySend(result) { dumpUserState(u) } 251 | override fun onError(e: Exception) = sendThrowable(result, e) 252 | } 253 | ) 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/pycampers/flutter_cognito_plugin/FlutterCognitoPlugin.kt: -------------------------------------------------------------------------------- 1 | package com.pycampers.flutter_cognito_plugin 2 | 3 | import android.content.Intent 4 | import androidx.annotation.NonNull 5 | import com.amazonaws.mobile.client.AWSMobileClient 6 | import com.pycampers.plugin_scaffold.createPluginScaffold 7 | import com.pycampers.plugin_scaffold.handler 8 | import io.flutter.embedding.android.FlutterActivity 9 | import io.flutter.embedding.engine.plugins.FlutterPlugin 10 | import io.flutter.embedding.engine.plugins.activity.ActivityAware 11 | import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding 12 | import io.flutter.plugin.common.PluginRegistry.Registrar 13 | 14 | const val PKG_NAME = "com.pycampers.flutter_cognito_plugin" 15 | 16 | open class CognitoPluginActivity(val scheme: String) : FlutterActivity() { 17 | override fun onNewIntent(intent: Intent) { 18 | super.onNewIntent(intent) 19 | if (scheme == intent.data?.scheme) { 20 | AWSMobileClient.getInstance().handleAuthResponse(intent) 21 | } 22 | } 23 | } 24 | 25 | class FlutterCognitoPlugin : FlutterPlugin, ActivityAware { 26 | var plugin: Cognito? = null 27 | 28 | override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { 29 | plugin = Cognito(flutterPluginBinding.applicationContext) 30 | val channel = createPluginScaffold(flutterPluginBinding.binaryMessenger, PKG_NAME, plugin!!) 31 | plugin!!.awsClient.addUserStateListener { 32 | handler.post { 33 | channel.invokeMethod("userStateCallback", dumpUserState(it)) 34 | } 35 | } 36 | } 37 | 38 | // This static function is optional and equivalent to onAttachedToEngine. It supports the old 39 | // pre-Flutter-1.12 Android projects. You are encouraged to continue supporting 40 | // plugin registration via this function while apps migrate to use the new Android APIs 41 | // post-flutter-1.12 via https://flutter.dev/go/android-project-migration. 42 | // 43 | // It is encouraged to share logic between onAttachedToEngine and registerWith to keep 44 | // them functionally equivalent. Only one of onAttachedToEngine or registerWith will be called 45 | // depending on the user's project. onAttachedToEngine or registerWith must both be defined 46 | // in the same class. 47 | companion object { 48 | @JvmStatic 49 | fun registerWith(registrar: Registrar) { 50 | val plugin = Cognito(registrar.context()) 51 | plugin.activity = registrar.activity() 52 | 53 | val channel = createPluginScaffold(registrar.messenger(), PKG_NAME, plugin) 54 | plugin.awsClient.addUserStateListener { 55 | handler.post { 56 | channel.invokeMethod("userStateCallback", dumpUserState(it)) 57 | } 58 | } 59 | } 60 | } 61 | 62 | override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { 63 | plugin?.activity = binding.activity 64 | } 65 | 66 | override fun onAttachedToActivity(binding: ActivityPluginBinding) { 67 | plugin?.activity = binding.activity 68 | } 69 | 70 | override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {} 71 | override fun onDetachedFromActivity() {} 72 | override fun onDetachedFromActivityForConfigChanges() {} 73 | } 74 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/pycampers/flutter_cognito_plugin/serializer.kt: -------------------------------------------------------------------------------- 1 | package com.pycampers.flutter_cognito_plugin 2 | 3 | import com.amazonaws.auth.CognitoCachingCredentialsProvider 4 | import com.amazonaws.mobile.client.UserStateDetails 5 | import com.amazonaws.mobile.client.results.ForgotPasswordResult 6 | import com.amazonaws.mobile.client.results.SignInResult 7 | import com.amazonaws.mobile.client.results.SignUpResult 8 | import com.amazonaws.mobile.client.results.Tokens 9 | import com.amazonaws.mobile.client.results.UserCodeDeliveryDetails 10 | 11 | fun dumpUserCodeDeliveryDetails(u: UserCodeDeliveryDetails?): List { 12 | return if (u != null) { 13 | listOf(u.attributeName, u.destination, u.deliveryMedium) 14 | } else { 15 | listOf() 16 | } 17 | } 18 | 19 | fun dumpSignUpResult(signUpResult: SignUpResult): List<*> { 20 | return listOf( 21 | signUpResult.confirmationState 22 | ) + dumpUserCodeDeliveryDetails( 23 | signUpResult.userCodeDeliveryDetails 24 | ) 25 | } 26 | 27 | fun dumpSignInResult(signInResult: SignInResult): List<*> { 28 | return listOf( 29 | signInResult.signInState.ordinal, 30 | signInResult.parameters 31 | ) + dumpUserCodeDeliveryDetails( 32 | signInResult.codeDetails 33 | ) 34 | } 35 | 36 | fun dumpForgotPasswordResult(forgotPasswordResult: ForgotPasswordResult): List<*> { 37 | return listOf( 38 | forgotPasswordResult.state.ordinal 39 | ) + dumpUserCodeDeliveryDetails( 40 | forgotPasswordResult.parameters 41 | ) 42 | } 43 | 44 | fun dumpUserState(userStateDetails: UserStateDetails): Int { 45 | return userStateDetails.userState.ordinal 46 | } 47 | 48 | fun dumpTokens(tokens: Tokens): List<*> { 49 | return listOf( 50 | tokens.accessToken?.tokenString, 51 | tokens.idToken?.tokenString, 52 | tokens.refreshToken?.tokenString 53 | ) 54 | } 55 | 56 | fun dumpCredentials(credentialsProvider: CognitoCachingCredentialsProvider): List<*> { 57 | val credentials = credentialsProvider.credentials; 58 | return listOf( 59 | credentials.awsAccessKeyId, 60 | credentials.awsSecretKey, 61 | credentials.sessionToken, 62 | credentialsProvider.sessionCredentitalsExpiration.time 63 | ) 64 | } 65 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | /build/ 32 | 33 | # Web related 34 | lib/generated_plugin_registrant.dart 35 | 36 | # Exceptions to above rules. 37 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 38 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 0b8abb4724aa590dd0f429683339b1e045a1594d 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # flutter_cognito_plugin_example 2 | 3 | Demonstrates how to use the flutter_cognito_plugin plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 28 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | lintOptions { 36 | disable 'InvalidPackage' 37 | } 38 | 39 | defaultConfig { 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 41 | applicationId "com.pycampers.flutter_cognito_plugin_example" 42 | minSdkVersion 16 43 | targetSdkVersion 28 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 47 | } 48 | 49 | buildTypes { 50 | release { 51 | // TODO: Add your own signing config for the release build. 52 | // Signing with the debug keys for now, so `flutter run --release` works. 53 | signingConfig signingConfigs.debug 54 | 55 | shrinkResources false 56 | minifyEnabled false 57 | } 58 | } 59 | } 60 | 61 | flutter { 62 | source '../..' 63 | } 64 | 65 | dependencies { 66 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 67 | testImplementation 'junit:junit:4.12' 68 | androidTestImplementation 'androidx.test:runner:1.1.1' 69 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' 70 | } 71 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 8 | 12 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 37 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/pycampers/flutter_cognito_plugin_example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.pycampers.flutter_cognito_plugin_example 2 | 3 | import androidx.annotation.NonNull 4 | import com.pycampers.flutter_cognito_plugin.CognitoPluginActivity 5 | import io.flutter.embedding.engine.FlutterEngine 6 | import io.flutter.plugins.GeneratedPluginRegistrant 7 | 8 | class MainActivity : CognitoPluginActivity("myapp") { 9 | override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { 10 | GeneratedPluginRegistrant.registerWith(flutterEngine); 11 | } 12 | } -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.50' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.5.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip 7 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() 4 | 5 | def plugins = new Properties() 6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') 7 | if (pluginsFile.exists()) { 8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } 9 | } 10 | 11 | plugins.each { name, path -> 12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() 13 | include ":$name" 14 | project(":$name").projectDir = pluginDirectory 15 | } 16 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/app.flx 22 | Flutter/app.zip 23 | Flutter/flutter_assets/ 24 | Flutter/flutter_export_environment.sh 25 | ServiceDefinitions.json 26 | Runner/GeneratedPluginRegistrant.* 27 | 28 | # Exceptions to above rules. 29 | !default.mode1v3 30 | !default.mode2v3 31 | !default.pbxuser 32 | !default.perspectivev3 33 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AWSAuth (2.19.1): 3 | - AWSAuth/Core (= 2.19.1) 4 | - AWSAuth/FacebookSignIn (= 2.19.1) 5 | - AWSAuth/GoogleSignIn (= 2.19.1) 6 | - AWSAuth/UI (= 2.19.1) 7 | - AWSAuth/UserPoolsSignIn (= 2.19.1) 8 | - AWSAuth/Core (2.19.1): 9 | - AWSAuthCore (= 2.19.1) 10 | - AWSAuth/FacebookSignIn (2.19.1): 11 | - AWSFacebookSignIn (= 2.19.1) 12 | - AWSAuth/GoogleSignIn (2.19.1): 13 | - AWSGoogleSignIn (= 2.19.1) 14 | - AWSAuth/UI (2.19.1): 15 | - AWSAuthUI (= 2.19.1) 16 | - AWSAuth/UserPoolsSignIn (2.19.1): 17 | - AWSUserPoolsSignIn (= 2.19.1) 18 | - AWSAuthCore (2.19.1): 19 | - AWSCore (= 2.19.1) 20 | - AWSAuthUI (2.19.1): 21 | - AWSAuthCore (= 2.19.1) 22 | - AWSCore (= 2.19.1) 23 | - AWSCognito (2.19.1): 24 | - AWSCore (= 2.19.1) 25 | - AWSCognitoIdentityProvider (2.19.1): 26 | - AWSCognitoIdentityProviderASF (= 2.19.1) 27 | - AWSCore (= 2.19.1) 28 | - AWSCognitoIdentityProviderASF (2.19.1) 29 | - AWSCore (2.19.1) 30 | - AWSFacebookSignIn (2.19.1): 31 | - AWSAuthCore (= 2.19.1) 32 | - AWSCore (= 2.19.1) 33 | - FBSDKCoreKit (= 8.0) 34 | - FBSDKLoginKit (= 8.0) 35 | - AWSGoogleSignIn (2.19.1): 36 | - AWSAuthCore (= 2.19.1) 37 | - AWSCore (= 2.19.1) 38 | - AWSMobileClient (2.19.1): 39 | - AWSAuthCore (= 2.19.1) 40 | - AWSCognitoIdentityProvider (= 2.19.1) 41 | - AWSCognitoIdentityProviderASF (= 2.19.1) 42 | - AWSCore (= 2.19.1) 43 | - AWSUserPoolsSignIn (2.19.1): 44 | - AWSAuthCore (= 2.19.1) 45 | - AWSCognitoIdentityProvider (= 2.19.1) 46 | - AWSCore (= 2.19.1) 47 | - FBSDKCoreKit (8.0.0): 48 | - FBSDKCoreKit/Basics (= 8.0.0) 49 | - FBSDKCoreKit/Core (= 8.0.0) 50 | - FBSDKCoreKit/Basics (8.0.0) 51 | - FBSDKCoreKit/Core (8.0.0): 52 | - FBSDKCoreKit/Basics 53 | - FBSDKLoginKit (8.0.0): 54 | - FBSDKLoginKit/Login (= 8.0.0) 55 | - FBSDKLoginKit/Login (8.0.0): 56 | - FBSDKCoreKit (~> 8.0.0) 57 | - Flutter (1.0.0) 58 | - flutter_cognito_plugin (0.0.1): 59 | - AWSAuth (~> 2.19.1) 60 | - AWSAuthUI (~> 2.19.1) 61 | - AWSCognito (~> 2.19.1) 62 | - AWSMobileClient (~> 2.19.1) 63 | - AWSUserPoolsSignIn (~> 2.19.1) 64 | - Flutter 65 | - plugin_scaffold 66 | - plugin_scaffold (0.0.1): 67 | - Flutter 68 | 69 | DEPENDENCIES: 70 | - Flutter (from `Flutter`) 71 | - flutter_cognito_plugin (from `.symlinks/plugins/flutter_cognito_plugin/ios`) 72 | - plugin_scaffold (from `.symlinks/plugins/plugin_scaffold/ios`) 73 | 74 | SPEC REPOS: 75 | trunk: 76 | - AWSAuth 77 | - AWSAuthCore 78 | - AWSAuthUI 79 | - AWSCognito 80 | - AWSCognitoIdentityProvider 81 | - AWSCognitoIdentityProviderASF 82 | - AWSCore 83 | - AWSFacebookSignIn 84 | - AWSGoogleSignIn 85 | - AWSMobileClient 86 | - AWSUserPoolsSignIn 87 | - FBSDKCoreKit 88 | - FBSDKLoginKit 89 | 90 | EXTERNAL SOURCES: 91 | Flutter: 92 | :path: Flutter 93 | flutter_cognito_plugin: 94 | :path: ".symlinks/plugins/flutter_cognito_plugin/ios" 95 | plugin_scaffold: 96 | :path: ".symlinks/plugins/plugin_scaffold/ios" 97 | 98 | SPEC CHECKSUMS: 99 | AWSAuth: e4eafe922c06dc714177393edfb9734565173c55 100 | AWSAuthCore: 387c5e3482edbbb0fe754fa110a2a0203c783432 101 | AWSAuthUI: fd6da797f59ef205d94cad9d486296982f146414 102 | AWSCognito: f50de600804941d083af37a7568905f31a774727 103 | AWSCognitoIdentityProvider: e6932c709d3e0b234128aeb5f2052c9bf1032d8d 104 | AWSCognitoIdentityProviderASF: 749f58b75e69f7f0144b9d38539525562b843d34 105 | AWSCore: 55c154ae27efc5c98bdc30a0eeea5a35d10a2ab5 106 | AWSFacebookSignIn: b47186149d5d279441dc8d13144d53f2e09e3c5c 107 | AWSGoogleSignIn: 73d99ea646ddaa26bbc44556b7bfb07bf23bacec 108 | AWSMobileClient: b908cada3c35da9cfe5b4ff9947fcf70142495e7 109 | AWSUserPoolsSignIn: cc80a0050c9f1282812b7d3f52f240f05201739f 110 | FBSDKCoreKit: 9d27fe97a2fa2abe5eeefea8240e837623ab88e0 111 | FBSDKLoginKit: 2cbaf5405379731b22f2ebc224f7c30f62378171 112 | Flutter: 0e3d915762c693b495b44d77113d4970485de6ec 113 | flutter_cognito_plugin: b0c935f555bd2e6c631086f51b1cf8c57628bc33 114 | plugin_scaffold: f83b8103defd141436d8ee29ba4a3e1b5230fea1 115 | 116 | PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c 117 | 118 | COCOAPODS: 1.10.0 119 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 080A505833469F4B5F0312A1 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CA4E62E491A25CC2D59C34C6 /* Pods_Runner.framework */; }; 11 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 12 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 13 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 14 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 15 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 16 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 17 | D7E1A0E22458B89E002E12B9 /* awsconfiguration.json in Resources */ = {isa = PBXBuildFile; fileRef = D7E1A0E12458B89D002E12B9 /* awsconfiguration.json */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXCopyFilesBuildPhase section */ 21 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 22 | isa = PBXCopyFilesBuildPhase; 23 | buildActionMask = 2147483647; 24 | dstPath = ""; 25 | dstSubfolderSpec = 10; 26 | files = ( 27 | ); 28 | name = "Embed Frameworks"; 29 | runOnlyForDeploymentPostprocessing = 0; 30 | }; 31 | /* End PBXCopyFilesBuildPhase section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 35 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 36 | 2CEA242F9DDD39A36692C8E6 /* 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 = ""; }; 37 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 38 | 68127FBC3A106D9253DC2971 /* 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 = ""; }; 39 | 70586D98D91E9BF92A42C6A6 /* 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 = ""; }; 40 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 41 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 42 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 43 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 44 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 45 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 46 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 47 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 48 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 49 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50 | CA4E62E491A25CC2D59C34C6 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | D7E1A0E12458B89D002E12B9 /* awsconfiguration.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = awsconfiguration.json; path = ../../android/app/src/main/res/raw/awsconfiguration.json; sourceTree = ""; }; 52 | /* End PBXFileReference section */ 53 | 54 | /* Begin PBXFrameworksBuildPhase section */ 55 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 56 | isa = PBXFrameworksBuildPhase; 57 | buildActionMask = 2147483647; 58 | files = ( 59 | 080A505833469F4B5F0312A1 /* Pods_Runner.framework in Frameworks */, 60 | ); 61 | runOnlyForDeploymentPostprocessing = 0; 62 | }; 63 | /* End PBXFrameworksBuildPhase section */ 64 | 65 | /* Begin PBXGroup section */ 66 | 4EFB2421D368FD7394AFF7C5 /* Pods */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | 68127FBC3A106D9253DC2971 /* Pods-Runner.debug.xcconfig */, 70 | 70586D98D91E9BF92A42C6A6 /* Pods-Runner.release.xcconfig */, 71 | 2CEA242F9DDD39A36692C8E6 /* Pods-Runner.profile.xcconfig */, 72 | ); 73 | path = Pods; 74 | sourceTree = ""; 75 | }; 76 | 86365B13A31251BB01311E6B /* Frameworks */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | CA4E62E491A25CC2D59C34C6 /* Pods_Runner.framework */, 80 | ); 81 | name = Frameworks; 82 | sourceTree = ""; 83 | }; 84 | 9740EEB11CF90186004384FC /* Flutter */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 88 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 89 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 90 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 91 | ); 92 | name = Flutter; 93 | sourceTree = ""; 94 | }; 95 | 97C146E51CF9000F007C117D = { 96 | isa = PBXGroup; 97 | children = ( 98 | 9740EEB11CF90186004384FC /* Flutter */, 99 | 97C146F01CF9000F007C117D /* Runner */, 100 | 97C146EF1CF9000F007C117D /* Products */, 101 | 4EFB2421D368FD7394AFF7C5 /* Pods */, 102 | 86365B13A31251BB01311E6B /* Frameworks */, 103 | ); 104 | sourceTree = ""; 105 | }; 106 | 97C146EF1CF9000F007C117D /* Products */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 97C146EE1CF9000F007C117D /* Runner.app */, 110 | ); 111 | name = Products; 112 | sourceTree = ""; 113 | }; 114 | 97C146F01CF9000F007C117D /* Runner */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 118 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 119 | D7E1A0E12458B89D002E12B9 /* awsconfiguration.json */, 120 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 121 | 97C147021CF9000F007C117D /* Info.plist */, 122 | 97C146F11CF9000F007C117D /* Supporting Files */, 123 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 124 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 125 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 126 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 127 | ); 128 | path = Runner; 129 | sourceTree = ""; 130 | }; 131 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | ); 135 | name = "Supporting Files"; 136 | sourceTree = ""; 137 | }; 138 | /* End PBXGroup section */ 139 | 140 | /* Begin PBXNativeTarget section */ 141 | 97C146ED1CF9000F007C117D /* Runner */ = { 142 | isa = PBXNativeTarget; 143 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 144 | buildPhases = ( 145 | 4C93D8B202ED79673205BE14 /* [CP] Check Pods Manifest.lock */, 146 | 9740EEB61CF901F6004384FC /* Run Script */, 147 | 97C146EA1CF9000F007C117D /* Sources */, 148 | 97C146EB1CF9000F007C117D /* Frameworks */, 149 | 97C146EC1CF9000F007C117D /* Resources */, 150 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 151 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 152 | D999441EE81E00DB741F85D6 /* [CP] Embed Pods Frameworks */, 153 | ); 154 | buildRules = ( 155 | ); 156 | dependencies = ( 157 | ); 158 | name = Runner; 159 | productName = Runner; 160 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 161 | productType = "com.apple.product-type.application"; 162 | }; 163 | /* End PBXNativeTarget section */ 164 | 165 | /* Begin PBXProject section */ 166 | 97C146E61CF9000F007C117D /* Project object */ = { 167 | isa = PBXProject; 168 | attributes = { 169 | LastUpgradeCheck = 1020; 170 | ORGANIZATIONNAME = "The Chromium Authors"; 171 | TargetAttributes = { 172 | 97C146ED1CF9000F007C117D = { 173 | CreatedOnToolsVersion = 7.3.1; 174 | LastSwiftMigration = 1100; 175 | }; 176 | }; 177 | }; 178 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 179 | compatibilityVersion = "Xcode 3.2"; 180 | developmentRegion = en; 181 | hasScannedForEncodings = 0; 182 | knownRegions = ( 183 | en, 184 | Base, 185 | ); 186 | mainGroup = 97C146E51CF9000F007C117D; 187 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 188 | projectDirPath = ""; 189 | projectRoot = ""; 190 | targets = ( 191 | 97C146ED1CF9000F007C117D /* Runner */, 192 | ); 193 | }; 194 | /* End PBXProject section */ 195 | 196 | /* Begin PBXResourcesBuildPhase section */ 197 | 97C146EC1CF9000F007C117D /* Resources */ = { 198 | isa = PBXResourcesBuildPhase; 199 | buildActionMask = 2147483647; 200 | files = ( 201 | D7E1A0E22458B89E002E12B9 /* awsconfiguration.json in Resources */, 202 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 203 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 204 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 205 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 206 | ); 207 | runOnlyForDeploymentPostprocessing = 0; 208 | }; 209 | /* End PBXResourcesBuildPhase section */ 210 | 211 | /* Begin PBXShellScriptBuildPhase section */ 212 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 213 | isa = PBXShellScriptBuildPhase; 214 | buildActionMask = 2147483647; 215 | files = ( 216 | ); 217 | inputPaths = ( 218 | ); 219 | name = "Thin Binary"; 220 | outputPaths = ( 221 | ); 222 | runOnlyForDeploymentPostprocessing = 0; 223 | shellPath = /bin/sh; 224 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; 225 | }; 226 | 4C93D8B202ED79673205BE14 /* [CP] Check Pods Manifest.lock */ = { 227 | isa = PBXShellScriptBuildPhase; 228 | buildActionMask = 2147483647; 229 | files = ( 230 | ); 231 | inputFileListPaths = ( 232 | ); 233 | inputPaths = ( 234 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 235 | "${PODS_ROOT}/Manifest.lock", 236 | ); 237 | name = "[CP] Check Pods Manifest.lock"; 238 | outputFileListPaths = ( 239 | ); 240 | outputPaths = ( 241 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", 242 | ); 243 | runOnlyForDeploymentPostprocessing = 0; 244 | shellPath = /bin/sh; 245 | 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"; 246 | showEnvVarsInLog = 0; 247 | }; 248 | 9740EEB61CF901F6004384FC /* Run Script */ = { 249 | isa = PBXShellScriptBuildPhase; 250 | buildActionMask = 2147483647; 251 | files = ( 252 | ); 253 | inputPaths = ( 254 | ); 255 | name = "Run Script"; 256 | outputPaths = ( 257 | ); 258 | runOnlyForDeploymentPostprocessing = 0; 259 | shellPath = /bin/sh; 260 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 261 | }; 262 | D999441EE81E00DB741F85D6 /* [CP] Embed Pods Frameworks */ = { 263 | isa = PBXShellScriptBuildPhase; 264 | buildActionMask = 2147483647; 265 | files = ( 266 | ); 267 | inputPaths = ( 268 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", 269 | "${BUILT_PRODUCTS_DIR}/AWSAuthCore/AWSAuthCore.framework", 270 | "${BUILT_PRODUCTS_DIR}/AWSAuthUI/AWSAuthUI.framework", 271 | "${BUILT_PRODUCTS_DIR}/AWSCognito/AWSCognito.framework", 272 | "${BUILT_PRODUCTS_DIR}/AWSCognitoIdentityProvider/AWSCognitoIdentityProvider.framework", 273 | "${BUILT_PRODUCTS_DIR}/AWSCognitoIdentityProviderASF/AWSCognitoIdentityProviderASF.framework", 274 | "${BUILT_PRODUCTS_DIR}/AWSCore/AWSCore.framework", 275 | "${BUILT_PRODUCTS_DIR}/AWSFacebookSignIn/AWSFacebookSignIn.framework", 276 | "${BUILT_PRODUCTS_DIR}/AWSGoogleSignIn/AWSGoogleSignIn.framework", 277 | "${BUILT_PRODUCTS_DIR}/AWSMobileClient/AWSMobileClient.framework", 278 | "${BUILT_PRODUCTS_DIR}/AWSUserPoolsSignIn/AWSUserPoolsSignIn.framework", 279 | "${BUILT_PRODUCTS_DIR}/FBSDKCoreKit/FBSDKCoreKit.framework", 280 | "${BUILT_PRODUCTS_DIR}/FBSDKLoginKit/FBSDKLoginKit.framework", 281 | "${PODS_ROOT}/../Flutter/Flutter.framework", 282 | "${BUILT_PRODUCTS_DIR}/flutter_cognito_plugin/flutter_cognito_plugin.framework", 283 | "${BUILT_PRODUCTS_DIR}/plugin_scaffold/plugin_scaffold.framework", 284 | ); 285 | name = "[CP] Embed Pods Frameworks"; 286 | outputPaths = ( 287 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSAuthCore.framework", 288 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSAuthUI.framework", 289 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSCognito.framework", 290 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSCognitoIdentityProvider.framework", 291 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSCognitoIdentityProviderASF.framework", 292 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSCore.framework", 293 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSFacebookSignIn.framework", 294 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSGoogleSignIn.framework", 295 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSMobileClient.framework", 296 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSUserPoolsSignIn.framework", 297 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBSDKCoreKit.framework", 298 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBSDKLoginKit.framework", 299 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", 300 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_cognito_plugin.framework", 301 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/plugin_scaffold.framework", 302 | ); 303 | runOnlyForDeploymentPostprocessing = 0; 304 | shellPath = /bin/sh; 305 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; 306 | showEnvVarsInLog = 0; 307 | }; 308 | /* End PBXShellScriptBuildPhase section */ 309 | 310 | /* Begin PBXSourcesBuildPhase section */ 311 | 97C146EA1CF9000F007C117D /* Sources */ = { 312 | isa = PBXSourcesBuildPhase; 313 | buildActionMask = 2147483647; 314 | files = ( 315 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 316 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 317 | ); 318 | runOnlyForDeploymentPostprocessing = 0; 319 | }; 320 | /* End PBXSourcesBuildPhase section */ 321 | 322 | /* Begin PBXVariantGroup section */ 323 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 324 | isa = PBXVariantGroup; 325 | children = ( 326 | 97C146FB1CF9000F007C117D /* Base */, 327 | ); 328 | name = Main.storyboard; 329 | sourceTree = ""; 330 | }; 331 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 332 | isa = PBXVariantGroup; 333 | children = ( 334 | 97C147001CF9000F007C117D /* Base */, 335 | ); 336 | name = LaunchScreen.storyboard; 337 | sourceTree = ""; 338 | }; 339 | /* End PBXVariantGroup section */ 340 | 341 | /* Begin XCBuildConfiguration section */ 342 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 343 | isa = XCBuildConfiguration; 344 | buildSettings = { 345 | ALWAYS_SEARCH_USER_PATHS = NO; 346 | CLANG_ANALYZER_NONNULL = YES; 347 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 348 | CLANG_CXX_LIBRARY = "libc++"; 349 | CLANG_ENABLE_MODULES = YES; 350 | CLANG_ENABLE_OBJC_ARC = YES; 351 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 352 | CLANG_WARN_BOOL_CONVERSION = YES; 353 | CLANG_WARN_COMMA = YES; 354 | CLANG_WARN_CONSTANT_CONVERSION = YES; 355 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 356 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 357 | CLANG_WARN_EMPTY_BODY = YES; 358 | CLANG_WARN_ENUM_CONVERSION = YES; 359 | CLANG_WARN_INFINITE_RECURSION = YES; 360 | CLANG_WARN_INT_CONVERSION = YES; 361 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 362 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 363 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 364 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 365 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 366 | CLANG_WARN_STRICT_PROTOTYPES = YES; 367 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 368 | CLANG_WARN_UNREACHABLE_CODE = YES; 369 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 370 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 371 | COPY_PHASE_STRIP = NO; 372 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 373 | ENABLE_NS_ASSERTIONS = NO; 374 | ENABLE_STRICT_OBJC_MSGSEND = YES; 375 | GCC_C_LANGUAGE_STANDARD = gnu99; 376 | GCC_NO_COMMON_BLOCKS = YES; 377 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 378 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 379 | GCC_WARN_UNDECLARED_SELECTOR = YES; 380 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 381 | GCC_WARN_UNUSED_FUNCTION = YES; 382 | GCC_WARN_UNUSED_VARIABLE = YES; 383 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 384 | MTL_ENABLE_DEBUG_INFO = NO; 385 | SDKROOT = iphoneos; 386 | SUPPORTED_PLATFORMS = iphoneos; 387 | TARGETED_DEVICE_FAMILY = "1,2"; 388 | VALIDATE_PRODUCT = YES; 389 | }; 390 | name = Profile; 391 | }; 392 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 393 | isa = XCBuildConfiguration; 394 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 395 | buildSettings = { 396 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 397 | CLANG_ENABLE_MODULES = YES; 398 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 399 | DEVELOPMENT_TEAM = ""; 400 | ENABLE_BITCODE = NO; 401 | FRAMEWORK_SEARCH_PATHS = ( 402 | "$(inherited)", 403 | "$(PROJECT_DIR)/Flutter", 404 | ); 405 | INFOPLIST_FILE = Runner/Info.plist; 406 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 407 | LIBRARY_SEARCH_PATHS = ( 408 | "$(inherited)", 409 | "$(PROJECT_DIR)/Flutter", 410 | ); 411 | PRODUCT_BUNDLE_IDENTIFIER = com.pycampers.flutterCognitoPluginExample; 412 | PRODUCT_NAME = "$(TARGET_NAME)"; 413 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 414 | SWIFT_VERSION = 5.0; 415 | VERSIONING_SYSTEM = "apple-generic"; 416 | }; 417 | name = Profile; 418 | }; 419 | 97C147031CF9000F007C117D /* Debug */ = { 420 | isa = XCBuildConfiguration; 421 | buildSettings = { 422 | ALWAYS_SEARCH_USER_PATHS = NO; 423 | CLANG_ANALYZER_NONNULL = YES; 424 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 425 | CLANG_CXX_LIBRARY = "libc++"; 426 | CLANG_ENABLE_MODULES = YES; 427 | CLANG_ENABLE_OBJC_ARC = YES; 428 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 429 | CLANG_WARN_BOOL_CONVERSION = YES; 430 | CLANG_WARN_COMMA = YES; 431 | CLANG_WARN_CONSTANT_CONVERSION = YES; 432 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 433 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 434 | CLANG_WARN_EMPTY_BODY = YES; 435 | CLANG_WARN_ENUM_CONVERSION = YES; 436 | CLANG_WARN_INFINITE_RECURSION = YES; 437 | CLANG_WARN_INT_CONVERSION = YES; 438 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 439 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 440 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 441 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 442 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 443 | CLANG_WARN_STRICT_PROTOTYPES = YES; 444 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 445 | CLANG_WARN_UNREACHABLE_CODE = YES; 446 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 447 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 448 | COPY_PHASE_STRIP = NO; 449 | DEBUG_INFORMATION_FORMAT = dwarf; 450 | ENABLE_STRICT_OBJC_MSGSEND = YES; 451 | ENABLE_TESTABILITY = YES; 452 | GCC_C_LANGUAGE_STANDARD = gnu99; 453 | GCC_DYNAMIC_NO_PIC = NO; 454 | GCC_NO_COMMON_BLOCKS = YES; 455 | GCC_OPTIMIZATION_LEVEL = 0; 456 | GCC_PREPROCESSOR_DEFINITIONS = ( 457 | "DEBUG=1", 458 | "$(inherited)", 459 | ); 460 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 461 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 462 | GCC_WARN_UNDECLARED_SELECTOR = YES; 463 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 464 | GCC_WARN_UNUSED_FUNCTION = YES; 465 | GCC_WARN_UNUSED_VARIABLE = YES; 466 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 467 | MTL_ENABLE_DEBUG_INFO = YES; 468 | ONLY_ACTIVE_ARCH = YES; 469 | SDKROOT = iphoneos; 470 | TARGETED_DEVICE_FAMILY = "1,2"; 471 | }; 472 | name = Debug; 473 | }; 474 | 97C147041CF9000F007C117D /* Release */ = { 475 | isa = XCBuildConfiguration; 476 | buildSettings = { 477 | ALWAYS_SEARCH_USER_PATHS = NO; 478 | CLANG_ANALYZER_NONNULL = YES; 479 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 480 | CLANG_CXX_LIBRARY = "libc++"; 481 | CLANG_ENABLE_MODULES = YES; 482 | CLANG_ENABLE_OBJC_ARC = YES; 483 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 484 | CLANG_WARN_BOOL_CONVERSION = YES; 485 | CLANG_WARN_COMMA = YES; 486 | CLANG_WARN_CONSTANT_CONVERSION = YES; 487 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 488 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 489 | CLANG_WARN_EMPTY_BODY = YES; 490 | CLANG_WARN_ENUM_CONVERSION = YES; 491 | CLANG_WARN_INFINITE_RECURSION = YES; 492 | CLANG_WARN_INT_CONVERSION = YES; 493 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 494 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 495 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 496 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 497 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 498 | CLANG_WARN_STRICT_PROTOTYPES = YES; 499 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 500 | CLANG_WARN_UNREACHABLE_CODE = YES; 501 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 502 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 503 | COPY_PHASE_STRIP = NO; 504 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 505 | ENABLE_NS_ASSERTIONS = NO; 506 | ENABLE_STRICT_OBJC_MSGSEND = YES; 507 | GCC_C_LANGUAGE_STANDARD = gnu99; 508 | GCC_NO_COMMON_BLOCKS = YES; 509 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 510 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 511 | GCC_WARN_UNDECLARED_SELECTOR = YES; 512 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 513 | GCC_WARN_UNUSED_FUNCTION = YES; 514 | GCC_WARN_UNUSED_VARIABLE = YES; 515 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 516 | MTL_ENABLE_DEBUG_INFO = NO; 517 | SDKROOT = iphoneos; 518 | SUPPORTED_PLATFORMS = iphoneos; 519 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 520 | TARGETED_DEVICE_FAMILY = "1,2"; 521 | VALIDATE_PRODUCT = YES; 522 | }; 523 | name = Release; 524 | }; 525 | 97C147061CF9000F007C117D /* Debug */ = { 526 | isa = XCBuildConfiguration; 527 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 528 | buildSettings = { 529 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 530 | CLANG_ENABLE_MODULES = YES; 531 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 532 | DEVELOPMENT_TEAM = ""; 533 | ENABLE_BITCODE = NO; 534 | FRAMEWORK_SEARCH_PATHS = ( 535 | "$(inherited)", 536 | "$(PROJECT_DIR)/Flutter", 537 | ); 538 | INFOPLIST_FILE = Runner/Info.plist; 539 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 540 | LIBRARY_SEARCH_PATHS = ( 541 | "$(inherited)", 542 | "$(PROJECT_DIR)/Flutter", 543 | ); 544 | PRODUCT_BUNDLE_IDENTIFIER = com.pycampers.flutterCognitoPluginExample; 545 | PRODUCT_NAME = "$(TARGET_NAME)"; 546 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 547 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 548 | SWIFT_VERSION = 5.0; 549 | VERSIONING_SYSTEM = "apple-generic"; 550 | }; 551 | name = Debug; 552 | }; 553 | 97C147071CF9000F007C117D /* Release */ = { 554 | isa = XCBuildConfiguration; 555 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 556 | buildSettings = { 557 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 558 | CLANG_ENABLE_MODULES = YES; 559 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 560 | DEVELOPMENT_TEAM = ""; 561 | ENABLE_BITCODE = NO; 562 | FRAMEWORK_SEARCH_PATHS = ( 563 | "$(inherited)", 564 | "$(PROJECT_DIR)/Flutter", 565 | ); 566 | INFOPLIST_FILE = Runner/Info.plist; 567 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 568 | LIBRARY_SEARCH_PATHS = ( 569 | "$(inherited)", 570 | "$(PROJECT_DIR)/Flutter", 571 | ); 572 | PRODUCT_BUNDLE_IDENTIFIER = com.pycampers.flutterCognitoPluginExample; 573 | PRODUCT_NAME = "$(TARGET_NAME)"; 574 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 575 | SWIFT_VERSION = 5.0; 576 | VERSIONING_SYSTEM = "apple-generic"; 577 | }; 578 | name = Release; 579 | }; 580 | /* End XCBuildConfiguration section */ 581 | 582 | /* Begin XCConfigurationList section */ 583 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 584 | isa = XCConfigurationList; 585 | buildConfigurations = ( 586 | 97C147031CF9000F007C117D /* Debug */, 587 | 97C147041CF9000F007C117D /* Release */, 588 | 249021D3217E4FDB00AE95B9 /* Profile */, 589 | ); 590 | defaultConfigurationIsVisible = 0; 591 | defaultConfigurationName = Release; 592 | }; 593 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 594 | isa = XCConfigurationList; 595 | buildConfigurations = ( 596 | 97C147061CF9000F007C117D /* Debug */, 597 | 97C147071CF9000F007C117D /* Release */, 598 | 249021D4217E4FDB00AE95B9 /* Profile */, 599 | ); 600 | defaultConfigurationIsVisible = 0; 601 | defaultConfigurationName = Release; 602 | }; 603 | /* End XCConfigurationList section */ 604 | }; 605 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 606 | } 607 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import flutter_cognito_plugin 3 | import UIKit 4 | 5 | @UIApplicationMain 6 | @objc class AppDelegate: CognitoPluginAppDelegate { 7 | override func application( 8 | _ application: UIApplication, 9 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 10 | ) -> Bool { 11 | GeneratedPluginRegistrant.register(with: self) 12 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | flutter_cognito_plugin_example 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | CFBundleURLTypes 47 | 48 | 49 | CFBundleURLSchemes 50 | 51 | myapp 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter/services.dart'; 5 | import 'package:flutter_cognito_plugin/flutter_cognito_plugin.dart'; 6 | 7 | void main() { 8 | runApp(Main()); 9 | } 10 | 11 | class Main extends StatelessWidget { 12 | @override 13 | Widget build(BuildContext context) { 14 | return MaterialApp( 15 | theme: ThemeData(fontFamily: 'Courier'), 16 | home: Scaffold( 17 | appBar: AppBar(title: const Text('AWS Cognito Sdk')), 18 | body: MyApp(), 19 | ), 20 | ); 21 | } 22 | } 23 | 24 | class MyApp extends StatefulWidget { 25 | const MyApp({Key key}) : super(key: key); 26 | 27 | @override 28 | MyAppState createState() => MyAppState(); 29 | } 30 | 31 | class MyAppState extends State { 32 | var returnValue; 33 | UserState userState; 34 | double progress; 35 | final usernameController = TextEditingController(); 36 | final passwordController = TextEditingController(); 37 | final attrsController = TextEditingController(); 38 | final newPasswordController = TextEditingController(); 39 | final confirmationCodeController = TextEditingController(); 40 | 41 | Future doLoad() async { 42 | var value; 43 | try { 44 | value = await Cognito.initialize(); 45 | } catch (e, trace) { 46 | print(e); 47 | print(trace); 48 | 49 | if (!mounted) return; 50 | setState(() { 51 | returnValue = e; 52 | progress = -1; 53 | }); 54 | 55 | return; 56 | } 57 | 58 | if (!mounted) return; 59 | setState(() { 60 | progress = -1; 61 | userState = value; 62 | }); 63 | } 64 | 65 | @override 66 | void initState() { 67 | super.initState(); 68 | doLoad(); 69 | Cognito.registerCallback((value) { 70 | if (!mounted) return; 71 | setState(() { 72 | userState = value; 73 | }); 74 | }); 75 | } 76 | 77 | @override 78 | void dispose() { 79 | Cognito.registerCallback(null); 80 | super.dispose(); 81 | } 82 | 83 | List buildReturnValue() { 84 | return [ 85 | SelectableText( 86 | userState?.toString() ?? "UserState will appear here", 87 | style: TextStyle(fontStyle: FontStyle.italic), 88 | ), 89 | Divider(), 90 | SingleChildScrollView( 91 | scrollDirection: Axis.horizontal, 92 | child: SelectableText( 93 | returnValue?.toString() ?? "return values will appear here.", 94 | style: TextStyle(fontStyle: FontStyle.italic), 95 | ), 96 | ) 97 | ]; 98 | } 99 | 100 | // wraps a function from the auth library with some scaffold code. 101 | onPressWrapper(fn) { 102 | wrapper() async { 103 | setState(() { 104 | progress = null; 105 | }); 106 | 107 | String value; 108 | try { 109 | value = (await fn()).toString(); 110 | } catch (e, stacktrace) { 111 | print(e); 112 | print(stacktrace); 113 | setState(() => value = e.toString()); 114 | } finally { 115 | setState(() { 116 | progress = -1; 117 | }); 118 | } 119 | 120 | setState(() => returnValue = value); 121 | } 122 | 123 | return wrapper; 124 | } 125 | 126 | textFields() { 127 | return [ 128 | [ 129 | TextField( 130 | decoration: InputDecoration(labelText: 'username'), 131 | controller: usernameController, 132 | ), 133 | TextField( 134 | decoration: InputDecoration(labelText: 'password'), 135 | controller: passwordController, 136 | ), 137 | TextField( 138 | decoration: InputDecoration(labelText: 'userAttributes'), 139 | controller: attrsController, 140 | ) 141 | ], 142 | [ 143 | TextField( 144 | decoration: InputDecoration(labelText: 'confirmationCode'), 145 | controller: confirmationCodeController, 146 | ), 147 | ], 148 | [ 149 | TextField( 150 | decoration: InputDecoration(labelText: 'newPassword'), 151 | controller: newPasswordController, 152 | ), 153 | ], 154 | ]; 155 | } 156 | 157 | signUp() { 158 | return [ 159 | RaisedButton( 160 | child: Text("signUp(username, password)"), 161 | onPressed: onPressWrapper(() { 162 | final attrs = attrsController.text; 163 | return Cognito.signUp( 164 | usernameController.text, 165 | passwordController.text, 166 | attrs.isEmpty ? null : Map.from(jsonDecode(attrs)), 167 | ); 168 | }), 169 | ), 170 | RaisedButton( 171 | child: Text("confirmSignUp(username, confirmationCode)"), 172 | onPressed: onPressWrapper(() { 173 | return Cognito.confirmSignUp( 174 | usernameController.text, 175 | confirmationCodeController.text, 176 | ); 177 | }), 178 | ), 179 | RaisedButton( 180 | child: Text("resendSignUp(username)"), 181 | onPressed: onPressWrapper(() { 182 | return Cognito.resendSignUp(usernameController.text); 183 | }), 184 | ) 185 | ]; 186 | } 187 | 188 | signIn() { 189 | return [ 190 | RaisedButton( 191 | child: Text("signIn(username, password)"), 192 | onPressed: onPressWrapper(() { 193 | return Cognito.signIn( 194 | usernameController.text, 195 | passwordController.text, 196 | ); 197 | }), 198 | ), 199 | RaisedButton( 200 | child: Text("confirmSignIn(confirmationCode)"), 201 | onPressed: onPressWrapper(() { 202 | return Cognito.confirmSignIn(confirmationCodeController.text); 203 | }), 204 | ), 205 | RaisedButton( 206 | child: Text("signOut()"), 207 | onPressed: onPressWrapper(() { 208 | return Cognito.signOut(); 209 | }), 210 | ), 211 | RaisedButton( 212 | child: Text("showSignIn()"), 213 | onPressed: onPressWrapper(() { 214 | return Cognito.showSignIn( 215 | identityProvider: "Cognito", 216 | scopes: ["email", "openid"], 217 | ); 218 | }), 219 | ), 220 | ]; 221 | } 222 | 223 | forgotPassword() { 224 | return [ 225 | RaisedButton( 226 | child: Text("forgotPassword(username)"), 227 | onPressed: onPressWrapper(() { 228 | return Cognito.forgotPassword(usernameController.text); 229 | }), 230 | ), 231 | RaisedButton( 232 | child: Text( 233 | "confirmForgotPassword(username, newPassword, confirmationCode)", 234 | ), 235 | onPressed: onPressWrapper(() { 236 | return Cognito.confirmForgotPassword( 237 | usernameController.text, 238 | newPasswordController.text, 239 | confirmationCodeController.text, 240 | ); 241 | }), 242 | ) 243 | ]; 244 | } 245 | 246 | utils() { 247 | return [ 248 | RaisedButton( 249 | child: Text("getUsername()"), 250 | onPressed: onPressWrapper(() { 251 | return Cognito.getUsername(); 252 | }), 253 | ), 254 | RaisedButton( 255 | child: Text("isSignedIn()"), 256 | onPressed: onPressWrapper(() { 257 | return Cognito.isSignedIn(); 258 | }), 259 | ), 260 | RaisedButton( 261 | child: Text("getIdentityId()"), 262 | onPressed: onPressWrapper(() { 263 | return Cognito.getIdentityId(); 264 | }), 265 | ), 266 | RaisedButton( 267 | child: Text("getTokens()"), 268 | onPressed: onPressWrapper(() { 269 | return Cognito.getTokens(); 270 | }), 271 | ), 272 | RaisedButton( 273 | child: Text('getCredentials()'), 274 | onPressed: onPressWrapper(() { 275 | return Cognito.getCredentials(); 276 | }), 277 | ), 278 | RaisedButton( 279 | child: Text("copy access token"), 280 | onPressed: onPressWrapper(() async { 281 | var tokens = await Cognito.getTokens(); 282 | Clipboard.setData(ClipboardData(text: tokens.accessToken)); 283 | Scaffold.of(context).showSnackBar( 284 | SnackBar( 285 | content: Text('copied access token to clipboard'), 286 | ), 287 | ); 288 | return tokens.accessToken; 289 | }), 290 | ), 291 | ]; 292 | } 293 | 294 | @override 295 | Widget build(BuildContext context) { 296 | return Stack( 297 | children: [ 298 | Center( 299 | child: buildChildren( 300 | >[ 301 | buildReturnValue(), 302 | ...textFields(), 303 | signUp(), 304 | signIn(), 305 | forgotPassword(), 306 | utils(), 307 | ], 308 | ), 309 | ), 310 | if (progress == null || progress > 0) 311 | Column( 312 | children: [ 313 | LinearProgressIndicator(value: progress), 314 | ], 315 | ), 316 | ], 317 | ); 318 | } 319 | } 320 | 321 | Widget buildChildren(List> children) { 322 | List c = children.map((item) { 323 | return Wrap( 324 | children: item, 325 | spacing: 10, 326 | alignment: WrapAlignment.center, 327 | ); 328 | }).toList(); 329 | return ListView.separated( 330 | itemCount: children.length, 331 | itemBuilder: (context, index) { 332 | return Padding( 333 | padding: EdgeInsets.all(10), 334 | child: c[index], 335 | ); 336 | }, 337 | separatorBuilder: (context, index) { 338 | return Divider(); 339 | }, 340 | ); 341 | } 342 | -------------------------------------------------------------------------------- /example/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "2.5.0-nullsafety.1" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "2.1.0-nullsafety.1" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "1.1.0-nullsafety.3" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.2.0-nullsafety.1" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "1.1.0-nullsafety.1" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "1.15.0-nullsafety.3" 46 | fake_async: 47 | dependency: transitive 48 | description: 49 | name: fake_async 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "1.2.0-nullsafety.1" 53 | flutter: 54 | dependency: "direct main" 55 | description: flutter 56 | source: sdk 57 | version: "0.0.0" 58 | flutter_cognito_plugin: 59 | dependency: "direct main" 60 | description: 61 | path: ".." 62 | relative: true 63 | source: path 64 | version: "2.2.0" 65 | flutter_test: 66 | dependency: "direct dev" 67 | description: flutter 68 | source: sdk 69 | version: "0.0.0" 70 | logging: 71 | dependency: transitive 72 | description: 73 | name: logging 74 | url: "https://pub.dartlang.org" 75 | source: hosted 76 | version: "0.11.4" 77 | matcher: 78 | dependency: transitive 79 | description: 80 | name: matcher 81 | url: "https://pub.dartlang.org" 82 | source: hosted 83 | version: "0.12.10-nullsafety.1" 84 | meta: 85 | dependency: transitive 86 | description: 87 | name: meta 88 | url: "https://pub.dartlang.org" 89 | source: hosted 90 | version: "1.3.0-nullsafety.3" 91 | path: 92 | dependency: transitive 93 | description: 94 | name: path 95 | url: "https://pub.dartlang.org" 96 | source: hosted 97 | version: "1.8.0-nullsafety.1" 98 | plugin_scaffold: 99 | dependency: transitive 100 | description: 101 | name: plugin_scaffold 102 | url: "https://pub.dartlang.org" 103 | source: hosted 104 | version: "3.0.1" 105 | sky_engine: 106 | dependency: transitive 107 | description: flutter 108 | source: sdk 109 | version: "0.0.99" 110 | source_span: 111 | dependency: transitive 112 | description: 113 | name: source_span 114 | url: "https://pub.dartlang.org" 115 | source: hosted 116 | version: "1.8.0-nullsafety.2" 117 | stack_trace: 118 | dependency: transitive 119 | description: 120 | name: stack_trace 121 | url: "https://pub.dartlang.org" 122 | source: hosted 123 | version: "1.10.0-nullsafety.1" 124 | stream_channel: 125 | dependency: transitive 126 | description: 127 | name: stream_channel 128 | url: "https://pub.dartlang.org" 129 | source: hosted 130 | version: "2.1.0-nullsafety.1" 131 | string_scanner: 132 | dependency: transitive 133 | description: 134 | name: string_scanner 135 | url: "https://pub.dartlang.org" 136 | source: hosted 137 | version: "1.1.0-nullsafety.1" 138 | term_glyph: 139 | dependency: transitive 140 | description: 141 | name: term_glyph 142 | url: "https://pub.dartlang.org" 143 | source: hosted 144 | version: "1.2.0-nullsafety.1" 145 | test_api: 146 | dependency: transitive 147 | description: 148 | name: test_api 149 | url: "https://pub.dartlang.org" 150 | source: hosted 151 | version: "0.2.19-nullsafety.2" 152 | typed_data: 153 | dependency: transitive 154 | description: 155 | name: typed_data 156 | url: "https://pub.dartlang.org" 157 | source: hosted 158 | version: "1.3.0-nullsafety.3" 159 | vector_math: 160 | dependency: transitive 161 | description: 162 | name: vector_math 163 | url: "https://pub.dartlang.org" 164 | source: hosted 165 | version: "2.1.0-nullsafety.3" 166 | sdks: 167 | dart: ">=2.10.0-110 <2.11.0" 168 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_cognito_plugin_example 2 | description: Demonstrates how to use the flutter_cognito_plugin plugin. 3 | publish_to: 'none' 4 | 5 | environment: 6 | sdk: ">=2.2.2 <3.0.0" 7 | 8 | dependencies: 9 | flutter: 10 | sdk: flutter 11 | 12 | flutter_cognito_plugin: 13 | path: ../ 14 | 15 | dev_dependencies: 16 | flutter_test: 17 | sdk: flutter 18 | 19 | # For information on the generic Dart part of this file, see the 20 | # following page: https://www.dartlang.org/tools/pub/pubspec 21 | 22 | # The following section is specific to Flutter. 23 | flutter: 24 | 25 | # The following line ensures that the Material Icons font is 26 | # included with your application, so that you can use the icons in 27 | # the material Icons class. 28 | uses-material-design: true 29 | 30 | # To add assets to your application, add an assets section, like this: 31 | # assets: 32 | # - images/a_dot_burr.jpeg 33 | # - images/a_dot_ham.jpeg 34 | 35 | # An image asset can refer to one or more resolution-specific "variants", see 36 | # https://flutter.io/assets-and-images/#resolution-aware. 37 | 38 | # For details regarding adding assets from package dependencies, see 39 | # https://flutter.io/assets-and-images/#from-packages 40 | 41 | # To add custom fonts to your application, add a fonts section here, 42 | # in this "flutter" section. Each entry in this list should have a 43 | # "family" key with the font family name, and a "fonts" key with a 44 | # list giving the asset and other descriptors for the font. For 45 | # example: 46 | # fonts: 47 | # - family: Schyler 48 | # fonts: 49 | # - asset: fonts/Schyler-Regular.ttf 50 | # - asset: fonts/Schyler-Italic.ttf 51 | # style: italic 52 | # - family: Trajan Pro 53 | # fonts: 54 | # - asset: fonts/TrajanPro.ttf 55 | # - asset: fonts/TrajanPro_Bold.ttf 56 | # weight: 700 57 | # 58 | # For details regarding fonts from package dependencies, 59 | # see https://flutter.io/custom-fonts/#from-packages 60 | -------------------------------------------------------------------------------- /flutter_cognito_plugin.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/Generated.xcconfig 37 | /Flutter/flutter_export_environment.sh -------------------------------------------------------------------------------- /ios/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scientifichackers/flutter_cognito_plugin/43a7ba31ff3fd687411bf68679d1ac10b27a03bd/ios/Assets/.gitkeep -------------------------------------------------------------------------------- /ios/Classes/Cognito.swift: -------------------------------------------------------------------------------- 1 | import AWSMobileClient 2 | import Flutter 3 | import plugin_scaffold 4 | 5 | typealias CompletionCallback = (T?, Error?) -> Void 6 | 7 | class Cognito { 8 | let awsClient = AWSMobileClient.default() 9 | 10 | func createErrorCallback(_ result: @escaping FlutterResult) -> (Error?) -> Void { 11 | return { error in 12 | if let error = error { 13 | trySendError(result, error) 14 | } else { 15 | trySend(result) { nil } 16 | } 17 | } 18 | } 19 | 20 | func createCallback(_ result: @escaping FlutterResult, _ serializer: ((T) -> Any)? = nil) -> (T?, Error?) -> Void { 21 | return { obj, error in 22 | if let obj = obj { 23 | trySend(result) { 24 | let value = serializer?(obj) ?? obj 25 | return value 26 | } 27 | } else if let error = error { 28 | trySendError(result, error) 29 | } 30 | } 31 | } 32 | 33 | func initialize(call: FlutterMethodCall, result: @escaping FlutterResult) { 34 | self.awsClient.initialize(self.createCallback(result, dumpUserState)) 35 | } 36 | 37 | func signUp(call: FlutterMethodCall, result: @escaping FlutterResult) { 38 | let args = call.arguments as! [String: Any?] 39 | let username = args["username"] as! String 40 | let password = args["password"] as! String 41 | let attrs = args["userAttributes"] as! [String: String] 42 | 43 | awsClient.signUp( 44 | username: username, 45 | password: password, 46 | userAttributes: attrs, 47 | validationData: [:], 48 | completionHandler: createCallback(result, dumpSignUpResult) 49 | ) 50 | } 51 | 52 | func confirmSignUp(call: FlutterMethodCall, result: @escaping FlutterResult) { 53 | let args = call.arguments as! [String: Any?] 54 | let username = args["username"] as! String 55 | let confirmationCode = args["confirmationCode"] as! String 56 | 57 | awsClient.confirmSignUp( 58 | username: username, 59 | confirmationCode: confirmationCode, 60 | completionHandler: createCallback(result, dumpSignUpResult) 61 | ) 62 | } 63 | 64 | func resendSignUp(call: FlutterMethodCall, result: @escaping FlutterResult) { 65 | let args = call.arguments as! [String: Any?] 66 | let username = args["username"] as! String 67 | 68 | awsClient.resendSignUpCode( 69 | username: username, 70 | completionHandler: createCallback(result, dumpSignUpResult) 71 | ) 72 | } 73 | 74 | func signIn(call: FlutterMethodCall, result: @escaping FlutterResult) { 75 | let args = call.arguments as! [String: Any?] 76 | let username = args["username"] as! String 77 | let password = args["password"] as! String 78 | 79 | awsClient.signIn( 80 | username: username, 81 | password: password, 82 | validationData: [:], 83 | completionHandler: createCallback(result, dumpSignInResult) 84 | ) 85 | } 86 | 87 | func confirmSignIn(call: FlutterMethodCall, result: @escaping FlutterResult) { 88 | let args = call.arguments as! [String: Any?] 89 | let confirmationCode = args["confirmationCode"] as! String 90 | 91 | awsClient.confirmSignIn( 92 | challengeResponse: confirmationCode, 93 | completionHandler: createCallback(result, dumpSignInResult) 94 | ) 95 | } 96 | 97 | func changePassword(call: FlutterMethodCall, result: @escaping FlutterResult) { 98 | let args = call.arguments as! [String: Any?] 99 | let oldPassword = args["oldPassword"] as! String 100 | let newPassword = args["newPassword"] as! String 101 | 102 | awsClient.changePassword( 103 | currentPassword: oldPassword, 104 | proposedPassword: newPassword, 105 | completionHandler: createErrorCallback(result) 106 | ) 107 | } 108 | 109 | func forgotPassword(call: FlutterMethodCall, result: @escaping FlutterResult) { 110 | let args = call.arguments as! [String: Any?] 111 | let username = args["username"] as! String 112 | 113 | awsClient.forgotPassword( 114 | username: username, 115 | completionHandler: createCallback(result, dumpForgotPasswordResult) 116 | ) 117 | } 118 | 119 | func confirmForgotPassword(call: FlutterMethodCall, result: @escaping FlutterResult) { 120 | let args = call.arguments as! [String: Any?] 121 | let username = args["username"] as! String 122 | let newPassword = args["newPassword"] as! String 123 | let confirmationCode = args["confirmationCode"] as! String 124 | 125 | awsClient.confirmForgotPassword( 126 | username: username, 127 | newPassword: newPassword, 128 | confirmationCode: confirmationCode, 129 | completionHandler: createCallback(result, dumpForgotPasswordResult) 130 | ) 131 | } 132 | 133 | func updateUserAttributes(call: FlutterMethodCall, result: @escaping FlutterResult) { 134 | let args = call.arguments as! [String: Any?] 135 | let userAttributes = args["userAttributes"] as! [String: String] 136 | 137 | awsClient.updateUserAttributes( 138 | attributeMap: userAttributes, 139 | completionHandler: createCallback(result) { 140 | $0.map { dumpUserCodeDeliveryDetails($0) } 141 | } 142 | ) 143 | } 144 | 145 | func getUserAttributes(call: FlutterMethodCall, result: @escaping FlutterResult) { 146 | self.awsClient.getUserAttributes(completionHandler: self.createCallback(result)) 147 | } 148 | 149 | func confirmUpdateUserAttribute(call: FlutterMethodCall, result: @escaping FlutterResult) { 150 | let args = call.arguments as! [String: Any?] 151 | let attributeName = args["attributeName"] as! String 152 | let confirmationCode = args["confirmationCode"] as! String 153 | 154 | awsClient.confirmUpdateUserAttributes( 155 | attributeName: attributeName, code: confirmationCode, 156 | completionHandler: createErrorCallback(result) 157 | ) 158 | } 159 | 160 | func signOut(call: FlutterMethodCall, result: @escaping FlutterResult) { 161 | self.awsClient.signOut() 162 | result(nil) 163 | } 164 | 165 | func getUsername(call: FlutterMethodCall, result: @escaping FlutterResult) { 166 | result(self.awsClient.username) 167 | } 168 | 169 | func isSignedIn(call: FlutterMethodCall, result: @escaping FlutterResult) { 170 | result(self.awsClient.isSignedIn) 171 | } 172 | 173 | func getIdentityId(call: FlutterMethodCall, result: @escaping FlutterResult) { 174 | result(self.awsClient.identityId) 175 | } 176 | 177 | func currentUserState(call: FlutterMethodCall, result: @escaping FlutterResult) { 178 | result(dumpUserState(self.awsClient.currentUserState)) 179 | } 180 | 181 | func getTokens(call: FlutterMethodCall, result: @escaping FlutterResult) { 182 | self.awsClient.getTokens(self.createCallback(result, dumpTokens)) 183 | } 184 | 185 | func getCredentials(call: FlutterMethodCall, result: @escaping FlutterResult) { 186 | self.awsClient.getAWSCredentials(self.createCallback(result, dumpCredentials)) 187 | } 188 | 189 | func federatedSignIn(call: FlutterMethodCall, result: @escaping FlutterResult) { 190 | let args = call.arguments as! [String: Any?] 191 | let providerName = args["providerName"] as! String 192 | let token = args["token"] as! String 193 | 194 | awsClient.federatedSignIn( 195 | providerName: providerName, 196 | token: token, 197 | completionHandler: createCallback(result, dumpUserState) 198 | ) 199 | } 200 | 201 | func showSignIn(call: FlutterMethodCall, result: @escaping FlutterResult) { 202 | let navigationController = CognitoPluginAppDelegate.navigationController 203 | if navigationController == nil { 204 | let error = FlutterError( 205 | code: "UINavigationControllerNotFound", 206 | message: "This method cannot be called without access to a UINavigationController.\n" + 207 | "Did you forget to replace `FlutterAppDelegate` with `CognitoPluginAppDelegate` in your app's AppDelegate.swift?", 208 | details: nil 209 | ) 210 | result(error) 211 | } else { 212 | let args = call.arguments as! [String: Any?] 213 | let identityProvider = args["identityProvider"] as! String 214 | let scopes = args["scopes"] as! [String] 215 | 216 | // Optionally override the scopes based on the usecase. 217 | let hostedUIOptions = HostedUIOptions(scopes: scopes, identityProvider: identityProvider) 218 | 219 | // Present the Hosted UI sign in. 220 | self.awsClient.showSignIn( 221 | navigationController: navigationController!, 222 | hostedUIOptions: hostedUIOptions, 223 | createCallback(result, dumpUserState) 224 | ) 225 | } 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /ios/Classes/FlutterCognitoPlugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface FlutterCognitoPlugin : NSObject 4 | @end 5 | -------------------------------------------------------------------------------- /ios/Classes/FlutterCognitoPlugin.m: -------------------------------------------------------------------------------- 1 | #import "FlutterCognitoPlugin.h" 2 | #if __has_include() 3 | #import 4 | #else 5 | // Support project import fallback if the generated compatibility header 6 | // is not copied when this plugin is created as a library. 7 | // https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 8 | #import "flutter_cognito_plugin-Swift.h" 9 | #endif 10 | 11 | @implementation FlutterCognitoPlugin 12 | + (void)registerWithRegistrar:(NSObject*)registrar { 13 | [SwiftFlutterCognitoPlugin registerWithRegistrar:registrar]; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /ios/Classes/SwiftFlutterCognitoPlugin.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import plugin_scaffold 3 | import UIKit 4 | import AWSMobileClient 5 | 6 | let pkgName = "com.pycampers.flutter_cognito_plugin" 7 | 8 | open class CognitoPluginAppDelegate: FlutterAppDelegate { 9 | public static var navigationController: UINavigationController? 10 | 11 | open override func application( 12 | _ application: UIApplication, 13 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 14 | ) -> Bool { 15 | let navigationController = UINavigationController(rootViewController: window.rootViewController!) 16 | navigationController.isNavigationBarHidden = true 17 | window.rootViewController = navigationController 18 | window.makeKeyAndVisible() 19 | 20 | CognitoPluginAppDelegate.navigationController = navigationController 21 | 22 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 23 | } 24 | 25 | open override func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool { 26 | AWSMobileClient.default().handleAuthResponse(application, open: url, sourceApplication: sourceApplication, annotation: annotation) 27 | return true 28 | } 29 | } 30 | 31 | public class SwiftFlutterCognitoPlugin: NSObject, FlutterPlugin { 32 | public static func register(with registrar: FlutterPluginRegistrar) { 33 | let plugin = Cognito() 34 | let channel = createPluginScaffold( 35 | messenger: registrar.messenger(), 36 | channelName: "com.pycampers.flutter_cognito_plugin", 37 | methodMap: [ 38 | "initialize": plugin.initialize, 39 | "signUp": plugin.signUp, 40 | "confirmSignUp": plugin.confirmSignUp, 41 | "resendSignUp": plugin.resendSignUp, 42 | "signIn": plugin.signIn, 43 | "confirmSignIn": plugin.confirmSignIn, 44 | "changePassword": plugin.changePassword, 45 | "forgotPassword": plugin.forgotPassword, 46 | "confirmForgotPassword": plugin.confirmForgotPassword, 47 | "signOut": plugin.signOut, 48 | "getUsername": plugin.getUsername, 49 | "isSignedIn": plugin.isSignedIn, 50 | "getIdentityId": plugin.getIdentityId, 51 | "currentUserState": plugin.currentUserState, 52 | "getUserAttributes": plugin.getUserAttributes, 53 | "updateUserAttributes": plugin.updateUserAttributes, 54 | "confirmUpdateUserAttribute": plugin.confirmUpdateUserAttribute, 55 | "getTokens": plugin.getTokens, 56 | "getCredentials": plugin.getCredentials, 57 | "federatedSignIn": plugin.federatedSignIn, 58 | "showSignIn": plugin.showSignIn, 59 | ] 60 | ) 61 | plugin.awsClient.addUserStateListener("test" as NSString) { userState, _ in 62 | channel.invokeMethod("userStateCallback", arguments: dumpUserState(userState)) 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /ios/Classes/serializer.swift: -------------------------------------------------------------------------------- 1 | import AWSMobileClient 2 | import Flutter 3 | 4 | func dumpUserCodeDeliveryDetails(_ userCodeDeliveryDetails: UserCodeDeliveryDetails?) -> [String] { 5 | if userCodeDeliveryDetails == nil { 6 | return [] 7 | } 8 | 9 | let u = userCodeDeliveryDetails! 10 | return [ 11 | u.attributeName!, 12 | u.destination!, 13 | String(describing: u.deliveryMedium) 14 | ] 15 | } 16 | 17 | func dumpSignUpResult(_ signUpResult: SignUpResult) -> [Any] { 18 | return [ 19 | signUpResult.signUpConfirmationState == SignUpConfirmationState.confirmed 20 | ] + dumpUserCodeDeliveryDetails( 21 | signUpResult.codeDeliveryDetails 22 | ) 23 | } 24 | 25 | let _androidSignInStateEnum = [ 26 | SignInState.smsMFA, 27 | SignInState.passwordVerifier, 28 | SignInState.customChallenge, 29 | SignInState.deviceSRPAuth, 30 | SignInState.devicePasswordVerifier, 31 | SignInState.adminNoSRPAuth, 32 | SignInState.newPasswordRequired, 33 | SignInState.signedIn, 34 | SignInState.unknown 35 | ] 36 | 37 | func dumpSignInResult(_ signInResult: SignInResult) -> [Any] { 38 | return [ 39 | _androidSignInStateEnum.firstIndex(of: signInResult.signInState)!, 40 | signInResult.parameters 41 | ] + dumpUserCodeDeliveryDetails( 42 | signInResult.codeDetails 43 | ) 44 | } 45 | 46 | let _androidForgotPasswordStateEnum = [ 47 | ForgotPasswordState.confirmationCodeSent, 48 | ForgotPasswordState.done 49 | ] 50 | 51 | func dumpForgotPasswordResult(_ forgotPasswordResult: ForgotPasswordResult) -> [Any] { 52 | return [ 53 | _androidForgotPasswordStateEnum.firstIndex(of: forgotPasswordResult.forgotPasswordState)! 54 | ] + dumpUserCodeDeliveryDetails( 55 | forgotPasswordResult.codeDeliveryDetails 56 | ) 57 | } 58 | 59 | let _androidUserStateEnum = [ 60 | UserState.signedIn, 61 | UserState.guest, 62 | UserState.signedOutFederatedTokensInvalid, 63 | UserState.signedOutUserPoolsTokenInvalid, 64 | UserState.signedOut, 65 | UserState.unknown 66 | ] 67 | 68 | func dumpUserState(_ userState: UserState) -> Int { 69 | return _androidUserStateEnum.firstIndex(of: userState)! 70 | } 71 | 72 | func dumpTokens(_ tokens: Tokens) -> [String?] { 73 | return [tokens.accessToken?.tokenString, tokens.idToken?.tokenString, tokens.refreshToken?.tokenString] 74 | } 75 | 76 | extension Date { 77 | var millisecondsSince1970: Int64 { 78 | return Int64((self.timeIntervalSince1970 * 1000.0).rounded()) 79 | } 80 | } 81 | 82 | func dumpCredentials(_ credentials: AWSCredentials) -> [Any?] { 83 | return [ 84 | credentials.accessKey, 85 | credentials.secretKey, 86 | credentials.sessionKey, 87 | credentials.expiration?.millisecondsSince1970 88 | ] 89 | } 90 | -------------------------------------------------------------------------------- /ios/flutter_cognito_plugin.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. 3 | # Run `pod lib lint flutter_cognito_plugin.podspec' to validate before publishing. 4 | # 5 | Pod::Spec.new do |s| 6 | s.name = 'flutter_cognito_plugin' 7 | s.version = '0.0.1' 8 | s.summary = 'A new flutter plugin project.' 9 | s.description = <<-DESC 10 | A new flutter plugin project. 11 | DESC 12 | s.homepage = 'http://example.com' 13 | s.license = { :file => '../LICENSE' } 14 | s.author = { 'Your Company' => 'email@example.com' } 15 | s.source = { :path => '.' } 16 | s.source_files = 'Classes/**/*' 17 | s.dependency 'Flutter' 18 | s.platform = :ios, '9.0' 19 | 20 | # Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported. 21 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' } 22 | s.swift_version = '5.0' 23 | 24 | s.dependency 'plugin_scaffold' 25 | s.dependency 'AWSMobileClient', '~> 2.19.1' 26 | s.dependency 'AWSAuth', '~> 2.19.1' 27 | s.dependency 'AWSCognito', '~> 2.19.1' 28 | s.dependency 'AWSAuthUI', '~> 2.19.1' 29 | s.dependency 'AWSUserPoolsSignIn', '~> 2.19.1' 30 | end 31 | -------------------------------------------------------------------------------- /lib/exception_serializer.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter/services.dart'; 4 | import 'package:flutter_cognito_plugin/exceptions.dart'; 5 | 6 | final iosErrorRegex = RegExp( 7 | r'''(AWSMobileClient\.AWSMobileClientError\.)(\w+)(\s*\(\s*message\s*\:\s*['"]\s*)([^\"^\']*)''', 8 | ); 9 | final androidErrorRegex = RegExp( 10 | r'''(com\.amazonaws\.services\.cognitoidentityprovider\.model\.|java\.lang\.|com\.amazonaws\.|java\.net\.)(\w+)''', 11 | ); 12 | 13 | dynamic convertException(dynamic e) { 14 | if (e is! PlatformException) return e; 15 | 16 | String code, message, details; 17 | if (Platform.isAndroid) { 18 | code = androidErrorRegex.firstMatch(e.code)?.group(2); 19 | message = e.message; 20 | details = e.details; 21 | } else if (Platform.isIOS) { 22 | final match = iosErrorRegex.firstMatch(e.code); 23 | code = match?.group(2); 24 | if (code != null) { 25 | code = code[0].toUpperCase() + code.substring(1) + "Exception"; 26 | } 27 | message = match?.group(4); 28 | details = e.details; 29 | } 30 | 31 | switch (code) { 32 | case "SocketTimeoutException": 33 | return SocketTimeoutException(message, details); 34 | case "UnknownHostException": 35 | return UnknownHostException(message, details); 36 | case "AmazonClientException": 37 | return AmazonClientException(message, details); 38 | case "IllegalStateException": 39 | return InvalidStateException(message, details); 40 | case "RuntimeException": 41 | return RuntimeException(message, details); 42 | case "AliasExistsException": 43 | return AliasExistsException(message, details); 44 | case "CodeDeliveryFailureException": 45 | return CodeDeliveryFailureException(message, details); 46 | case "CodeMismatchException": 47 | return CodeMismatchException(message, details); 48 | case "ExpiredCodeException": 49 | return ExpiredCodeException(message, details); 50 | case "GroupExistsException": 51 | return GroupExistsException(message, details); 52 | case "InternalErrorException": 53 | return InternalErrorException(message, details); 54 | case "InvalidLambdaResponseException": 55 | return InvalidLambdaResponseException(message, details); 56 | case "InvalidOAuthFlowException": 57 | return InvalidOAuthFlowException(message, details); 58 | case "InvalidParameterException": 59 | return InvalidParameterException(message, details); 60 | case "InvalidPasswordException": 61 | return InvalidPasswordException(message, details); 62 | case "InvalidUserPoolConfigurationException": 63 | return InvalidUserPoolConfigurationException(message, details); 64 | case "LimitExceededException": 65 | return LimitExceededException(message, details); 66 | case "MfaMethodNotFoundException": 67 | return MfaMethodNotFoundException(message, details); 68 | case "NotAuthorizedException": 69 | return NotAuthorizedException(message, details); 70 | case "PasswordResetRequiredException": 71 | return PasswordResetRequiredException(message, details); 72 | case "ResourceNotFoundException": 73 | return ResourceNotFoundException(message, details); 74 | case "ScopeDoesNotExistException": 75 | return ScopeDoesNotExistException(message, details); 76 | case "SoftwareTokenMFANotFoundException": 77 | return SoftwareTokenMFANotFoundException(message, details); 78 | case "TooManyFailedAttemptsException": 79 | return TooManyFailedAttemptsException(message, details); 80 | case "TooManyRequestsException": 81 | return TooManyRequestsException(message, details); 82 | case "UnexpectedLambdaException": 83 | return UnexpectedLambdaException(message, details); 84 | case "UserLambdaValidationException": 85 | return UserLambdaValidationException(message, details); 86 | case "UserNotConfirmedException": 87 | return UserNotConfirmedException(message, details); 88 | case "UserNotFoundException": 89 | return UserNotFoundException(message, details); 90 | case "UsernameExistsException": 91 | return UsernameExistsException(message, details); 92 | case "UnknownException": 93 | return UnknownException(message, details); 94 | case "NotSignedInException": 95 | return NotSignedInException(message, details); 96 | case "IdentityIdUnavailableException": 97 | return IdentityIdUnavailableException(message, details); 98 | case "GuestAccessNotAllowedException": 99 | return GuestAccessNotAllowedException(message, details); 100 | case "FederationProviderExistsException": 101 | return FederationProviderExistsException(message, details); 102 | case "CognitoIdentityPoolNotConfiguredException": 103 | return CognitoIdentityPoolNotConfiguredException(message, details); 104 | case "UnableToSignInException": 105 | return UnableToSignInException(message, details); 106 | case "InvalidStateException": 107 | return InvalidStateException(message, details); 108 | case "UserPoolNotConfiguredException": 109 | return UserPoolNotConfiguredException(message, details); 110 | case "UserCancelledSignInException": 111 | return UserCancelledSignInException(message, details); 112 | case "BadRequestException": 113 | return BadRequestException(message, details); 114 | case "ExpiredRefreshTokenException": 115 | return ExpiredRefreshTokenException(message, details); 116 | case "ErrorLoadingPageException": 117 | return ErrorLoadingPageException(message, details); 118 | case "SecurityFailedException": 119 | return SecurityFailedException(message, details); 120 | case "IdTokenNotIssuedException": 121 | return IdTokenNotIssuedException(message, details); 122 | case "IdTokenAndAcceessTokenNotIssuedException": 123 | return IdTokenAndAccessTokenNotIssuedException(message, details); 124 | case "InvalidConfigurationException": 125 | return InvalidConfigurationException(message, details); 126 | case "DeviceNotRememberedException": 127 | return DeviceNotRememberedException(message, details); 128 | default: 129 | return e; 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /lib/exceptions.dart: -------------------------------------------------------------------------------- 1 | class CognitoException implements Exception { 2 | String message, details; 3 | 4 | CognitoException(this.message, this.details); 5 | 6 | @override 7 | String toString() { 8 | return "$runtimeType: $message\n$details"; 9 | } 10 | } 11 | 12 | class AliasExistsException extends CognitoException { 13 | AliasExistsException(String message, String details) 14 | : super(message, details); 15 | } 16 | 17 | class CodeDeliveryFailureException extends CognitoException { 18 | CodeDeliveryFailureException(String message, String details) 19 | : super(message, details); 20 | } 21 | 22 | class CodeMismatchException extends CognitoException { 23 | CodeMismatchException(String message, String details) 24 | : super(message, details); 25 | } 26 | 27 | class ExpiredCodeException extends CognitoException { 28 | ExpiredCodeException(String message, String details) 29 | : super(message, details); 30 | } 31 | 32 | class GroupExistsException extends CognitoException { 33 | GroupExistsException(String message, String details) 34 | : super(message, details); 35 | } 36 | 37 | class InternalErrorException extends CognitoException { 38 | InternalErrorException(String message, String details) 39 | : super(message, details); 40 | } 41 | 42 | class InvalidLambdaResponseException extends CognitoException { 43 | InvalidLambdaResponseException(String message, String details) 44 | : super(message, details); 45 | } 46 | 47 | class InvalidOAuthFlowException extends CognitoException { 48 | InvalidOAuthFlowException(String message, String details) 49 | : super(message, details); 50 | } 51 | 52 | class InvalidParameterException extends CognitoException { 53 | InvalidParameterException(String message, String details) 54 | : super(message, details); 55 | } 56 | 57 | class InvalidPasswordException extends CognitoException { 58 | InvalidPasswordException(String message, String details) 59 | : super(message, details); 60 | } 61 | 62 | class InvalidUserPoolConfigurationException extends CognitoException { 63 | InvalidUserPoolConfigurationException(String message, String details) 64 | : super(message, details); 65 | } 66 | 67 | class LimitExceededException extends CognitoException { 68 | LimitExceededException(String message, String details) 69 | : super(message, details); 70 | } 71 | 72 | class MfaMethodNotFoundException extends CognitoException { 73 | MfaMethodNotFoundException(String message, String details) 74 | : super(message, details); 75 | } 76 | 77 | class NotAuthorizedException extends CognitoException { 78 | NotAuthorizedException(String message, String details) 79 | : super(message, details); 80 | } 81 | 82 | class PasswordResetRequiredException extends CognitoException { 83 | PasswordResetRequiredException(String message, String details) 84 | : super(message, details); 85 | } 86 | 87 | class ResourceNotFoundException extends CognitoException { 88 | ResourceNotFoundException(String message, String details) 89 | : super(message, details); 90 | } 91 | 92 | class ScopeDoesNotExistException extends CognitoException { 93 | ScopeDoesNotExistException(String message, String details) 94 | : super(message, details); 95 | } 96 | 97 | class SoftwareTokenMFANotFoundException extends CognitoException { 98 | SoftwareTokenMFANotFoundException(String message, String details) 99 | : super(message, details); 100 | } 101 | 102 | class TooManyFailedAttemptsException extends CognitoException { 103 | TooManyFailedAttemptsException(String message, String details) 104 | : super(message, details); 105 | } 106 | 107 | class TooManyRequestsException extends CognitoException { 108 | TooManyRequestsException(String message, String details) 109 | : super(message, details); 110 | } 111 | 112 | class UnexpectedLambdaException extends CognitoException { 113 | UnexpectedLambdaException(String message, String details) 114 | : super(message, details); 115 | } 116 | 117 | class UserLambdaValidationException extends CognitoException { 118 | UserLambdaValidationException(String message, String details) 119 | : super(message, details); 120 | } 121 | 122 | class UserNotConfirmedException extends CognitoException { 123 | UserNotConfirmedException(String message, String details) 124 | : super(message, details); 125 | } 126 | 127 | class UserNotFoundException extends CognitoException { 128 | UserNotFoundException(String message, String details) 129 | : super(message, details); 130 | } 131 | 132 | class UsernameExistsException extends CognitoException { 133 | UsernameExistsException(String message, String details) 134 | : super(message, details); 135 | } 136 | 137 | class UnknownException extends CognitoException { 138 | UnknownException(String message, String details) : super(message, details); 139 | } 140 | 141 | class NotSignedInException extends CognitoException { 142 | NotSignedInException(String message, String details) 143 | : super(message, details); 144 | } 145 | 146 | class IdentityIdUnavailableException extends CognitoException { 147 | IdentityIdUnavailableException(String message, String details) 148 | : super(message, details); 149 | } 150 | 151 | class GuestAccessNotAllowedException extends CognitoException { 152 | GuestAccessNotAllowedException(String message, String details) 153 | : super(message, details); 154 | } 155 | 156 | class FederationProviderExistsException extends CognitoException { 157 | FederationProviderExistsException(String message, String details) 158 | : super(message, details); 159 | } 160 | 161 | class CognitoIdentityPoolNotConfiguredException extends CognitoException { 162 | CognitoIdentityPoolNotConfiguredException(String message, String details) 163 | : super(message, details); 164 | } 165 | 166 | class UnableToSignInException extends CognitoException { 167 | UnableToSignInException(String message, String details) 168 | : super(message, details); 169 | } 170 | 171 | class InvalidStateException extends CognitoException { 172 | InvalidStateException(String message, String details) 173 | : super(message, details); 174 | } 175 | 176 | class UserPoolNotConfiguredException extends CognitoException { 177 | UserPoolNotConfiguredException(String message, String details) 178 | : super(message, details); 179 | } 180 | 181 | class UserCancelledSignInException extends CognitoException { 182 | UserCancelledSignInException(String message, String details) 183 | : super(message, details); 184 | } 185 | 186 | class BadRequestException extends CognitoException { 187 | BadRequestException(String message, String details) : super(message, details); 188 | } 189 | 190 | class ExpiredRefreshTokenException extends CognitoException { 191 | ExpiredRefreshTokenException(String message, String details) 192 | : super(message, details); 193 | } 194 | 195 | class ErrorLoadingPageException extends CognitoException { 196 | ErrorLoadingPageException(String message, String details) 197 | : super(message, details); 198 | } 199 | 200 | class SecurityFailedException extends CognitoException { 201 | SecurityFailedException(String message, String details) 202 | : super(message, details); 203 | } 204 | 205 | class IdTokenNotIssuedException extends CognitoException { 206 | IdTokenNotIssuedException(String message, String details) 207 | : super(message, details); 208 | } 209 | 210 | class IdTokenAndAccessTokenNotIssuedException extends CognitoException { 211 | IdTokenAndAccessTokenNotIssuedException(String message, String details) 212 | : super(message, details); 213 | } 214 | 215 | class InvalidConfigurationException extends CognitoException { 216 | InvalidConfigurationException(String message, String details) 217 | : super(message, details); 218 | } 219 | 220 | class DeviceNotRememberedException extends CognitoException { 221 | DeviceNotRememberedException(String message, String details) 222 | : super(message, details); 223 | } 224 | 225 | class AmazonClientException extends CognitoException { 226 | AmazonClientException(String message, String details) 227 | : super(message, details); 228 | } 229 | 230 | class ApolloException extends CognitoException { 231 | ApolloException(String message, String details) : super(message, details); 232 | } 233 | 234 | class RuntimeException extends CognitoException { 235 | RuntimeException(String message, String details) : super(message, details); 236 | } 237 | 238 | class UnknownHostException extends CognitoException { 239 | UnknownHostException(String message, String details) 240 | : super(message, details); 241 | } 242 | 243 | class SocketTimeoutException extends CognitoException { 244 | SocketTimeoutException(String message, String details) 245 | : super(message, details); 246 | } 247 | -------------------------------------------------------------------------------- /lib/flutter_cognito_plugin.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter/services.dart'; 3 | import 'package:flutter_cognito_plugin/exception_serializer.dart'; 4 | import 'package:flutter_cognito_plugin/exceptions.dart'; 5 | import 'package:flutter_cognito_plugin/models.dart'; 6 | import 'package:logging/logging.dart'; 7 | import 'package:plugin_scaffold/plugin_scaffold.dart'; 8 | 9 | export 'package:flutter_cognito_plugin/exceptions.dart'; 10 | export 'package:flutter_cognito_plugin/models.dart'; 11 | 12 | typedef OnUserStateChange(UserState userState); 13 | 14 | class Cognito { 15 | static final l = Logger("cognito"); 16 | 17 | static const pkgName = "com.pycampers.flutter_cognito_plugin"; 18 | static const channel = MethodChannel(pkgName); 19 | 20 | static List retryForExceptions = [ 21 | ApolloException("Failed to parse http response", null), 22 | ApolloException("Failed to execute http call", null), 23 | AmazonClientException("Unable to execute HTTP request", null), 24 | UnknownHostException("Unable to resolve host", null), 25 | ]; 26 | 27 | static bool shouldRetry(dynamic e, int tries) { 28 | if (e is! CognitoException || 29 | (autoRetryLimit != null && tries > autoRetryLimit)) { 30 | return false; 31 | } 32 | 33 | for (final rule in retryForExceptions) { 34 | if (e.runtimeType == rule.runtimeType && 35 | e.message.toUpperCase().contains(rule.message.toUpperCase())) { 36 | return true; 37 | } 38 | } 39 | 40 | return false; 41 | } 42 | 43 | /// The number of times to automatically retry sending a request. 44 | /// 45 | /// Useful for cases where network is flaky. 46 | /// 47 | /// Takes extra care to retry only for a network related error, 48 | /// and not a client error, like OTP incorrect, etc. 49 | /// 50 | /// 0 -> No retry. 51 | /// Non-zero number -> Retry specified number of times. 52 | /// null -> Infinite retry. 53 | static int autoRetryLimit = 0; 54 | 55 | /// The delay before retrying. 56 | static Duration retryDelay = Duration(); 57 | 58 | /// Invokes a method on specified [MethodChannel]. 59 | /// 60 | /// This is useful for other plugins/apps that want 61 | /// to leverage the auto retry capabilities of this plugin. 62 | static Future invokeMethodWithChannel( 63 | MethodChannel channel, 64 | String method, [ 65 | dynamic arguments, 66 | ]) async { 67 | var tries = 0; 68 | while (true) { 69 | tries += 1; 70 | try { 71 | return await channel.invokeMethod(method, arguments); 72 | } catch (error, trace) { 73 | var newError = convertException(error); 74 | if (shouldRetry(newError, tries)) { 75 | l.info( 76 | "caught exception { retryDelay: $retryDelay, tries: $tries, limit: $autoRetryLimit, $newError }", 77 | ); 78 | await Future.delayed(retryDelay); 79 | } else { 80 | await Future.error(newError, trace); 81 | } 82 | } 83 | } 84 | } 85 | 86 | static invokeMethod(String method, [dynamic arguments]) { 87 | return invokeMethodWithChannel(channel, method, arguments); 88 | } 89 | 90 | /// Initializes the AWS mobile client. 91 | /// 92 | /// This MUST be called before using any other methods under this class. 93 | /// A good strategy might be to invoke this before [runApp()] in [main()], like so: 94 | /// 95 | /// ``` 96 | /// void main() async { 97 | /// UserStateDetails details = await Cognito.initialize(); 98 | /// print(details); 99 | /// 100 | /// runApp(MyApp()); 101 | /// } 102 | /// ``` 103 | /// 104 | /// Returns the value of [Cognito.getCurrentUserState()]. 105 | static Future initialize() async { 106 | // don't trust the UserState returned by this 107 | // https://github.com/aws-amplify/aws-sdk-android/issues/873 108 | await invokeMethod("initialize"); 109 | 110 | var userState = await Cognito.getCurrentUserState(); 111 | 112 | if (userState == UserState.SIGNED_OUT_FEDERATED_TOKENS_INVALID || 113 | userState == UserState.SIGNED_OUT_USER_POOLS_TOKENS_INVALID) { 114 | await Cognito.signOut(); 115 | return await Cognito.getCurrentUserState(); 116 | } 117 | 118 | return await Cognito.getCurrentUserState(); 119 | } 120 | 121 | /// Registers a callback that gets called every-time the UserState changes. 122 | /// 123 | /// Replaces existing callback, if any. 124 | /// 125 | /// If `null` is passed, then the existing callback will be removed, if any. 126 | static void registerCallback(OnUserStateChange onUserStateChange) { 127 | if (onUserStateChange == null) { 128 | PluginScaffold.removeCallHandlersWithName(channel, "userStateCallback"); 129 | return; 130 | } 131 | PluginScaffold.setCallHandler(channel, "userStateCallback", (value) { 132 | onUserStateChange(UserState.values[value]); 133 | }); 134 | } 135 | 136 | static Future signUp( 137 | String username, 138 | String password, [ 139 | Map userAttributes, 140 | ]) async { 141 | return SignUpResult.fromMsg( 142 | await invokeMethod("signUp", { 143 | "username": username ?? "", 144 | "password": password ?? "", 145 | "userAttributes": userAttributes ?? {}, 146 | }), 147 | ); 148 | } 149 | 150 | static Future confirmSignUp( 151 | String username, 152 | String confirmationCode, 153 | ) async { 154 | return SignUpResult.fromMsg( 155 | await invokeMethod("confirmSignUp", { 156 | "username": username ?? "", 157 | "confirmationCode": confirmationCode ?? "", 158 | }), 159 | ); 160 | } 161 | 162 | static Future resendSignUp(String username) async { 163 | return SignUpResult.fromMsg( 164 | await invokeMethod("resendSignUp", { 165 | "username": username ?? "", 166 | }), 167 | ); 168 | } 169 | 170 | static Future signIn(String username, String password) async { 171 | return SignInResult.fromMsg( 172 | await invokeMethod("signIn", { 173 | "username": username ?? "", 174 | "password": password ?? "", 175 | }), 176 | ); 177 | } 178 | 179 | static Future federatedSignIn( 180 | String providerName, 181 | String token, 182 | ) async { 183 | var value = await invokeMethod("federatedSignIn", { 184 | "providerName": providerName ?? "", 185 | "token": token ?? "", 186 | }); 187 | return UserState.values[value]; 188 | } 189 | 190 | static Future confirmSignIn(String confirmationCode) async { 191 | return SignInResult.fromMsg( 192 | await invokeMethod("confirmSignIn", { 193 | "confirmationCode": confirmationCode ?? "", 194 | }), 195 | ); 196 | } 197 | 198 | static Future changePassword( 199 | String oldPassword, 200 | String newPassword, 201 | ) async { 202 | var res = await invokeMethod("changePassword", { 203 | "oldPassword": oldPassword ?? "", 204 | "newPassword": newPassword ?? "", 205 | }); 206 | } 207 | 208 | static Future forgotPassword(String username) async { 209 | return ForgotPasswordResult.fromMsg( 210 | await invokeMethod("forgotPassword", {"username": username ?? ""}), 211 | ); 212 | } 213 | 214 | static Future confirmForgotPassword( 215 | String username, 216 | String newPassword, 217 | String confirmationCode, 218 | ) async { 219 | return ForgotPasswordResult.fromMsg( 220 | await invokeMethod("confirmForgotPassword", { 221 | "username": username ?? "", 222 | "newPassword": newPassword ?? "", 223 | "confirmationCode": confirmationCode ?? "", 224 | }), 225 | ); 226 | } 227 | 228 | static Future getCurrentUserState() async { 229 | return UserState.values[await invokeMethod("currentUserState")]; 230 | } 231 | 232 | static Future signOut({ 233 | bool invalidateTokens: false, 234 | bool signOutGlobally: false, 235 | }) async { 236 | await invokeMethod("signOut", { 237 | "invalidateTokens": invalidateTokens, 238 | "signOutGlobally": signOutGlobally, 239 | }); 240 | } 241 | 242 | static Future getUsername() async { 243 | return await invokeMethod("getUsername"); 244 | } 245 | 246 | static Future isSignedIn() async { 247 | return await invokeMethod("isSignedIn"); 248 | } 249 | 250 | static Future getIdentityId() async { 251 | return await invokeMethod("getIdentityId"); 252 | } 253 | 254 | static Future> getUserAttributes() async { 255 | return Map.from(await invokeMethod("getUserAttributes")); 256 | } 257 | 258 | static Future> updateUserAttributes( 259 | Map userAttributes, 260 | ) async { 261 | List uL = await invokeMethod("updateUserAttributes", { 262 | "userAttributes": userAttributes ?? {}, 263 | }); 264 | return List.from( 265 | uL.map((u) { 266 | return UserCodeDeliveryDetails.fromMsg(u); 267 | }), 268 | ); 269 | } 270 | 271 | static Future confirmUpdateUserAttribute( 272 | String attributeName, 273 | String confirmationCode, 274 | ) async { 275 | await invokeMethod("confirmUpdateUserAttribute", { 276 | "attributeName": attributeName, 277 | "confirmationCode": confirmationCode, 278 | }); 279 | } 280 | 281 | /// Returns the tokens obtained from Cognito User Pools sign-in. 282 | /// Federated sign-in tokens are not supported. 283 | static Future getTokens() async { 284 | return Tokens.fromMsg(await invokeMethod("getTokens")); 285 | } 286 | 287 | static Future getCredentials() async { 288 | return Credentials.fromMsg(await invokeMethod("getCredentials")); 289 | } 290 | 291 | static Future showSignIn({ 292 | @required String identityProvider, 293 | @required List scopes, 294 | }) async { 295 | await invokeMethod("showSignIn", { 296 | "identityProvider": identityProvider, 297 | "scopes": scopes, 298 | }); 299 | } 300 | } 301 | -------------------------------------------------------------------------------- /lib/models.dart: -------------------------------------------------------------------------------- 1 | /// Indicates who is responsible (if known) for a failed request. 2 | /// 3 | /// For example, if a client is using an invalid AWS access key, the returned 4 | /// exception will indicate that there is an error in the request the caller 5 | /// is sending. Retrying that same request will *not* result in a successful 6 | /// response. The Client ErrorType indicates that there is a problem in the 7 | /// request the user is sending (ex: incorrect access keys, invalid parameter 8 | /// value, missing parameter, etc.), and that the caller must take some 9 | /// action to correct the request before it should be resent. Client errors 10 | /// are typically associated an HTTP error code in the 4xx range. 11 | /// 12 | /// The Service ErrorType indicates that although the request the caller sent 13 | /// was valid, the service was unable to fulfill the request because of 14 | /// problems on the service's side. These types of errors can be retried by 15 | /// the caller since the caller's request was valid and the problem occurred 16 | /// while processing the request on the service side. Service errors will be 17 | /// accompanied by an HTTP error code in the 5xx range. 18 | /// 19 | /// Finally, if there isn't enough information to determine who's fault the 20 | /// error response is, an Unknown ErrorType will be set. 21 | enum ErrorType { Client, Service, Unknown } 22 | 23 | enum UserState { 24 | SIGNED_IN, 25 | GUEST, 26 | SIGNED_OUT_FEDERATED_TOKENS_INVALID, 27 | SIGNED_OUT_USER_POOLS_TOKENS_INVALID, 28 | SIGNED_OUT, 29 | UNKNOWN, 30 | } 31 | 32 | enum SignInState { 33 | /// Next challenge is to supply an SMS_MFA_CODE, delivered via SMS. 34 | SMS_MFA, 35 | 36 | /// Next challenge is to supply PASSWORD_CLAIM_SIGNATURE, PASSWORD_CLAIM_SECRET_BLOCK, and TIMESTAMP after the client-side SRP calculations. 37 | PASSWORD_VERIFIER, 38 | 39 | /// This is returned if your custom authentication flow determines that the user should pass another challenge before tokens are issued. 40 | CUSTOM_CHALLENGE, 41 | 42 | /// If device tracking was enabled on your user pool and the previous challenges were passed, this challenge is returned so that Amazon Cognito can start tracking this device. 43 | DEVICE_SRP_AUTH, 44 | 45 | /// Similar to PASSWORD_VERIFIER, but for devices only. 46 | DEVICE_PASSWORD_VERIFIER, 47 | 48 | /// This is returned if you need to authenticate with USERNAME and PASSWORD directly. An app client must be enabled to use this flow. 49 | ADMIN_NO_SRP_AUTH, 50 | 51 | /// For users which are required to change their passwords after successful first login. This challenge should be passed with NEW_PASSWORD and any other required attributes. 52 | NEW_PASSWORD_REQUIRED, 53 | 54 | /// The flow is completed and no further steps are possible. 55 | DONE, 56 | 57 | /// Unknown sign-in state, potentially unsupported state 58 | UNKNOWN 59 | } 60 | 61 | enum ForgotPasswordState { CONFIRMATION_CODE, DONE, UNKNOWN } 62 | 63 | /// Determines where the confirmation code was sent. 64 | class UserCodeDeliveryDetails { 65 | final String attributeName, destination, deliveryMedium; 66 | 67 | UserCodeDeliveryDetails._internal(List msg) 68 | : attributeName = msg[0], 69 | destination = msg[1], 70 | deliveryMedium = msg[2]; 71 | 72 | factory UserCodeDeliveryDetails.fromMsg(List msg) { 73 | if (msg.length < 3) return null; 74 | return UserCodeDeliveryDetails._internal(msg); 75 | } 76 | 77 | @override 78 | String toString() { 79 | return "UserCodeDeliveryDetails { attributeName: $attributeName, " 80 | "destination: $destination, deliveryMedium: $deliveryMedium }"; 81 | } 82 | } 83 | 84 | /// The result from signing-in. Check the state to determine the next step. 85 | class SignInResult { 86 | final SignInState signInState; 87 | 88 | /// Used to determine the type of challenge that is being present from the service 89 | final Map parameters; 90 | final UserCodeDeliveryDetails userCodeDeliveryDetails; 91 | 92 | @override 93 | String toString() { 94 | return "SignInResult { signInState: $signInState, parameters: $parameters, " 95 | "userCodeDeliveryDetails: $userCodeDeliveryDetails }"; 96 | } 97 | 98 | SignInResult.fromMsg(List msg) 99 | : signInState = SignInState.values[msg[0]], 100 | parameters = (msg[1] == null) ? null : Map.from(msg[1]), 101 | userCodeDeliveryDetails = 102 | UserCodeDeliveryDetails.fromMsg(msg.sublist(2)); 103 | } 104 | 105 | /// The result of a sign up action. Check the confirmation state and delivery details to proceed. 106 | class SignUpResult { 107 | /// - [true] -> user is confirmed, no further action is necessary. 108 | /// - [false] -> check delivery details and call [confirmSignUp()]. 109 | final bool confirmationState; 110 | final UserCodeDeliveryDetails userCodeDeliveryDetails; 111 | 112 | @override 113 | String toString() { 114 | return "SignUpResult { confirmationState: $confirmationState, " 115 | "userCodeDeliveryDetails: $userCodeDeliveryDetails }"; 116 | } 117 | 118 | SignUpResult.fromMsg(List msg) 119 | : confirmationState = msg[0], 120 | userCodeDeliveryDetails = 121 | UserCodeDeliveryDetails.fromMsg(msg.sublist(1)); 122 | } 123 | 124 | /// The result of a forgot password action 125 | class ForgotPasswordResult { 126 | final ForgotPasswordState state; 127 | final UserCodeDeliveryDetails parameters; 128 | 129 | @override 130 | String toString() { 131 | return "ForgotPasswordResult { state: $state, parameters: $parameters }"; 132 | } 133 | 134 | ForgotPasswordResult.fromMsg(List msg) 135 | : state = ForgotPasswordState.values[msg[0]], 136 | parameters = UserCodeDeliveryDetails.fromMsg(msg.sublist(1)); 137 | } 138 | 139 | /// A container for different types of [Token]s. 140 | class Tokens { 141 | final String accessToken, idToken, refreshToken; 142 | 143 | Tokens.fromMsg(List msg) 144 | : accessToken = msg[0], 145 | idToken = msg[1], 146 | refreshToken = msg[2]; 147 | 148 | @override 149 | String toString() { 150 | return "Tokens { acessToken: $accessToken, " 151 | "idToken: $idToken, refreshToken: $refreshToken }"; 152 | } 153 | } 154 | 155 | class Credentials { 156 | final String accessKey, secretKey, sessionToken; 157 | DateTime expiry; 158 | 159 | Credentials.fromMsg(List msg) 160 | : accessKey = msg[0], 161 | secretKey = msg[1], 162 | sessionToken = msg[2], 163 | expiry = DateTime.fromMillisecondsSinceEpoch(msg[3]); 164 | 165 | @override 166 | String toString() { 167 | return "Credentials { accessKey: $accessKey, secretKey: $secretKey, sesionToken: $sessionToken, expiry: $expiry }"; 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "2.5.0-nullsafety.1" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "2.1.0-nullsafety.1" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "1.1.0-nullsafety.3" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.2.0-nullsafety.1" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "1.1.0-nullsafety.1" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "1.15.0-nullsafety.3" 46 | fake_async: 47 | dependency: transitive 48 | description: 49 | name: fake_async 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "1.2.0-nullsafety.1" 53 | flutter: 54 | dependency: "direct main" 55 | description: flutter 56 | source: sdk 57 | version: "0.0.0" 58 | flutter_test: 59 | dependency: "direct dev" 60 | description: flutter 61 | source: sdk 62 | version: "0.0.0" 63 | logging: 64 | dependency: "direct main" 65 | description: 66 | name: logging 67 | url: "https://pub.dartlang.org" 68 | source: hosted 69 | version: "0.11.4" 70 | matcher: 71 | dependency: transitive 72 | description: 73 | name: matcher 74 | url: "https://pub.dartlang.org" 75 | source: hosted 76 | version: "0.12.10-nullsafety.1" 77 | meta: 78 | dependency: transitive 79 | description: 80 | name: meta 81 | url: "https://pub.dartlang.org" 82 | source: hosted 83 | version: "1.3.0-nullsafety.3" 84 | path: 85 | dependency: transitive 86 | description: 87 | name: path 88 | url: "https://pub.dartlang.org" 89 | source: hosted 90 | version: "1.8.0-nullsafety.1" 91 | plugin_scaffold: 92 | dependency: "direct main" 93 | description: 94 | name: plugin_scaffold 95 | url: "https://pub.dartlang.org" 96 | source: hosted 97 | version: "3.0.1" 98 | sky_engine: 99 | dependency: transitive 100 | description: flutter 101 | source: sdk 102 | version: "0.0.99" 103 | source_span: 104 | dependency: transitive 105 | description: 106 | name: source_span 107 | url: "https://pub.dartlang.org" 108 | source: hosted 109 | version: "1.8.0-nullsafety.2" 110 | stack_trace: 111 | dependency: transitive 112 | description: 113 | name: stack_trace 114 | url: "https://pub.dartlang.org" 115 | source: hosted 116 | version: "1.10.0-nullsafety.1" 117 | stream_channel: 118 | dependency: transitive 119 | description: 120 | name: stream_channel 121 | url: "https://pub.dartlang.org" 122 | source: hosted 123 | version: "2.1.0-nullsafety.1" 124 | string_scanner: 125 | dependency: transitive 126 | description: 127 | name: string_scanner 128 | url: "https://pub.dartlang.org" 129 | source: hosted 130 | version: "1.1.0-nullsafety.1" 131 | term_glyph: 132 | dependency: transitive 133 | description: 134 | name: term_glyph 135 | url: "https://pub.dartlang.org" 136 | source: hosted 137 | version: "1.2.0-nullsafety.1" 138 | test_api: 139 | dependency: transitive 140 | description: 141 | name: test_api 142 | url: "https://pub.dartlang.org" 143 | source: hosted 144 | version: "0.2.19-nullsafety.2" 145 | typed_data: 146 | dependency: transitive 147 | description: 148 | name: typed_data 149 | url: "https://pub.dartlang.org" 150 | source: hosted 151 | version: "1.3.0-nullsafety.3" 152 | vector_math: 153 | dependency: transitive 154 | description: 155 | name: vector_math 156 | url: "https://pub.dartlang.org" 157 | source: hosted 158 | version: "2.1.0-nullsafety.3" 159 | sdks: 160 | dart: ">=2.10.0-110 <2.11.0" 161 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_cognito_plugin 2 | description: AWS Cognito plugin for flutter. 3 | version: 2.2.0 4 | author: Dev Aggarwal 5 | homepage: https://github.com/pycampers/flutter_cognito_plugin 6 | 7 | environment: 8 | sdk: ">=2.1.0 <3.0.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | plugin_scaffold: ^3.0.1 15 | logging: ^0.11.4 16 | 17 | dev_dependencies: 18 | flutter_test: 19 | sdk: flutter 20 | 21 | # For information on the generic Dart part of this file, see the 22 | # following page: https://www.dartlang.org/tools/pub/pubspec 23 | 24 | # The following section is specific to Flutter. 25 | flutter: 26 | # This section identifies this Flutter project as a plugin project. 27 | # The androidPackage and pluginClass identifiers should not ordinarily 28 | # be modified. They are used by the tooling to maintain consistency when 29 | # adding or updating assets for this project. 30 | plugin: 31 | androidPackage: com.pycampers.flutter_cognito_plugin 32 | pluginClass: FlutterCognitoPlugin 33 | 34 | # To add assets to your plugin package, add an assets section, like this: 35 | # assets: 36 | # - images/a_dot_burr.jpeg 37 | # - images/a_dot_ham.jpeg 38 | # 39 | # For details regarding assets in packages, see 40 | # https://flutter.io/assets-and-images/#from-packages 41 | # 42 | # An image asset can refer to one or more resolution-specific "variants", see 43 | # https://flutter.io/assets-and-images/#resolution-aware. 44 | 45 | # To add custom fonts to your plugin package, add a fonts section here, 46 | # in this "flutter" section. Each entry in this list should have a 47 | # "family" key with the font family name, and a "fonts" key with a 48 | # list giving the asset and other descriptors for the font. For 49 | # example: 50 | # fonts: 51 | # - family: Schyler 52 | # fonts: 53 | # - asset: fonts/Schyler-Regular.ttf 54 | # - asset: fonts/Schyler-Italic.ttf 55 | # style: italic 56 | # - family: Trajan Pro 57 | # fonts: 58 | # - asset: fonts/TrajanPro.ttf 59 | # - asset: fonts/TrajanPro_Bold.ttf 60 | # weight: 700 61 | # 62 | # For details regarding fonts in packages, see 63 | # https://flutter.io/custom-fonts/#from-packages 64 | --------------------------------------------------------------------------------