Giter Site home page Giter Site logo

Comments (18)

Equartey avatar Equartey commented on June 10, 2024 1

Hi @rhamnett, thanks for the extra info. I've been able to reproduce this and I'm looking into a fix.

We will provide an update here when we can, thanks.

from amplify-flutter.

rhamnett avatar rhamnett commented on June 10, 2024 1

Will be my pleasure. I'll try tomorrow and feed back.

from amplify-flutter.

Equartey avatar Equartey commented on June 10, 2024 1

@rhamnett oh sorry about the typo.

Not sure what the issue is yet, I'm not seeing that on my end.

I'll give you an update when I have one.

from amplify-flutter.

Equartey avatar Equartey commented on June 10, 2024 1

@rhamnett awesome, happy to hear.

Like I mentioned before, our approach may change, but we will update you here when its released.

from amplify-flutter.

Equartey avatar Equartey commented on June 10, 2024 1

@rhamnett sorry for the delay. It has been merged and will be part of the next release. We'll update you here when that is available!

from amplify-flutter.

Equartey avatar Equartey commented on June 10, 2024

Hi @rhamnett, can you please provide more context and reproduction steps so we can better assist you?

from amplify-flutter.

rhamnett avatar rhamnett commented on June 10, 2024

Hello thanks for the reply.

The problem is that there are special wallet connect (wc: ) type URLs, like in the initial post. Cognito plugin seems to be trying to parse these when opening them from the Web via an intent. It should just have a check to ensure that the Uri is a type that can be parsed. I have again included a stack trace for you.

If you want to recreate - have a plain project with amplify auth, then register the intent from the initial post.

You can go to opesea.com - click login, then click wallet connect, find "m1nty" wallet, then click to open the app via the intent.

Heres the culprit code in com.amazonaws.amplify.amplify_auth_cognito.AmplifyAuthCognitoPluginKt.getQueryParameters(AmplifyAuthCognitoPlugin.kt:546)

val Uri.queryParameters: MutableMap<String, String>
  get() {
    val queryParameters = mutableMapOf<String, String>()
    for (name in queryParameterNames) {
      queryParameters[name] = getQueryParameter(name) ?: ""
    }
    return queryParameters
  }

Causes

    Caused by: java.lang.UnsupportedOperationException: This isn't a hierarchical URI.
                                                                                                    	at android.net.Uri.getQueryParameterNames(Uri.java:1614)

Stack trace....

2024-03-07 22:44:08.884 13930-13930 AmplifyAut...nitoPlugin app.m1nty.android                    D  [onNewIntent] Got intent: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=wc: flg=0x14400000 cmp=app.m1nty.android/.MainActivity (has extras) }
2024-03-07 22:44:08.886 14163-14163 cessService0:36         pid-14163                            E  Not starting debugger since process cannot load the jdwp agent.
2024-03-07 22:44:08.886 13930-13930 AndroidRuntime          app.m1nty.android                    D  Shutting down VM
2024-03-07 22:44:08.896 13930-13930 AndroidRuntime          app.m1nty.android                    E  FATAL EXCEPTION: main
                                                                                                    Process: app.m1nty.android, PID: 13930
                                                                                                    java.lang.UnsupportedOperationException: This isn't a hierarchical URI.
                                                                                                    	at android.net.Uri.getQueryParameterNames(Uri.java:1614)
                                                                                                    	at com.amazonaws.amplify.amplify_auth_cognito.AmplifyAuthCognitoPluginKt.getQueryParameters(AmplifyAuthCognitoPlugin.kt:546)
                                                                                                    	at com.amazonaws.amplify.amplify_auth_cognito.AmplifyAuthCognitoPlugin.onNewIntent(AmplifyAuthCognitoPlugin.kt:468)
                                                                                                    	at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onNewIntent(FlutterEngineConnectionRegistry.java:838)
                                                                                                    	at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onNewIntent(FlutterEngineConnectionRegistry.java:450)
                                                                                                    	at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onNewIntent(FlutterActivityAndFragmentDelegate.java:838)
                                                                                                    	at io.flutter.embedding.android.FlutterFragment.onNewIntent(FlutterFragment.java:1219)
                                                                                                    	at io.flutter.embedding.android.FlutterFragmentActivity.onNewIntent(FlutterFragmentActivity.java:660)
                                                                                                    	at android.app.Activity.performNewIntent(Activity.java:8613)
                                                                                                    	at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1556)
                                                                                                    	at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1569)
                                                                                                    	at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:3962)
                                                                                                    	at android.app.ActivityThread.handleNewIntent(ActivityThread.java:3969)
                                                                                                    	at android.app.servertransaction.NewIntentItem.execute(NewIntentItem.java:56)
                                                                                                    	at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
                                                                                                    	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
                                                                                                    	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
                                                                                                    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:205)
                                                                                                    	at android.os.Looper.loop(Looper.java:294)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8177)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
I/FA      (20125): Application backgrounded at: timestamp_millis: 1709917536352
D/com.llfbandit.app_links(20125): Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=wc: flg=0x14400000 cmp=app.m1nty.android/.MainActivity (has extras) }
D/com.llfbandit.app_links(20125): handleIntent: (Action) android.intent.action.VIEW
D/com.llfbandit.app_links(20125): handleIntent: (Data) wc:b96fafd049f6b75f2e7755b693589f2d36733495f03244dcb81945091613394f@2?relay-protocol=irn&symKey=0f2f13318d31828764b6bc30851a22f5a763aeb2cc90ada177d9ecf5d1d18362
D/AmplifyAuthCognitoPlugin(20125): [onNewIntent] Got intent: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=wc: flg=0x14400000 cmp=app.m1nty.android/.MainActivity (has extras) }

from amplify-flutter.

rhamnett avatar rhamnett commented on June 10, 2024

Ah brilliant. Thanks so much for taking the time to look into this. Really appreciate it

from amplify-flutter.

Equartey avatar Equartey commented on June 10, 2024

@rhamnett no problem.

I opened a PR that at least prevents the error, although not sure this will be the fix we end up using.

Can you give it a try and see if it unblocks you?

Add this to your pubspec.yaml:

dependency_overrides:
  amplify_auth_cognito:
    git:
      url: https://github.com/aws-amplify/amplify-flutter.git
      ref: 8d8bc637502e0837a518d74b7700bf3ee61d6afd
      path: packages/auth/amplify_auth_cognito

from amplify-flutter.

rhamnett avatar rhamnett commented on June 10, 2024

@Equartey just tried this, sorry.....please can you help me understand what versions I'll need to make this override work?

Running Gradle task 'assembleDebug'...
Warning: unexpected element (uri:"", local:"extension-level"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
Warning: unexpected element (uri:"", local:"base-extension"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
Warning: unexpected element (uri:"", local:"base-extension"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
../../.pub-cache/git/amplify-flutter-8d8bc637502e0837a518d74b7700bf3ee61d6afd/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_impl.dart:66:10: Error: Type 'LegacyDeviceDetails' not found.
  Future<LegacyDeviceDetails?> fetchLegacyDeviceSecrets({
         ^^^^^^^^^^^^^^^^^^^
../../.pub-cache/git/amplify-flutter-8d8bc637502e0837a518d74b7700bf3ee61d6afd/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_impl.dart:71:23: Error: The method 'fetchLegacyDeviceSecrets' isn't defined for the class 'LegacyCredentialProvider'.
 - 'LegacyCredentialProvider' is from 'package:amplify_auth_cognito_dart/src/credentials/legacy_credential_provider.dart' ('../../.pub-cache/hosted/pub.dev/amplify_auth_cognito_dart-0.10.10/lib/src/credentials/legacy_credential_provider.dart').
Try correcting the name to the name of an existing method, or defining a method named 'fetchLegacyDeviceSecrets'.
    return _instance!.fetchLegacyDeviceSecrets(
                      ^^^^^^^^^^^^^^^^^^^^^^^^
../../.pub-cache/git/amplify-flutter-8d8bc637502e0837a518d74b7700bf3ee61d6afd/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_impl.dart:83:23: Error: The method 'deleteLegacyDeviceSecrets' isn't defined for the class 'LegacyCredentialProvider'.
 - 'LegacyCredentialProvider' is from 'package:amplify_auth_cognito_dart/src/credentials/legacy_credential_provider.dart' ('../../.pub-cache/hosted/pub.dev/amplify_auth_cognito_dart-0.10.10/lib/src/credentials/legacy_credential_provider.dart').
Try correcting the name to the name of an existing method, or defining a method named 'deleteLegacyDeviceSecrets'.
    return _instance!.deleteLegacyDeviceSecrets(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^
../../.pub-cache/git/amplify-flutter-8d8bc637502e0837a518d74b7700bf3ee61d6afd/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_ios.dart:165:10: Error: Type 'LegacyDeviceDetails' not found.
  Future<LegacyDeviceDetails?> fetchLegacyDeviceSecrets({
         ^^^^^^^^^^^^^^^^^^^
../../.pub-cache/git/amplify-flutter-8d8bc637502e0837a518d74b7700bf3ee61d6afd/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_ios.dart:195:12: Error: The method 'LegacyDeviceDetails' isn't defined for the class 'LegacyCredentialProviderIOS'.
 - 'LegacyCredentialProviderIOS' is from 'package:amplify_auth_cognito/src/credentials/legacy_credential_provider_ios.dart' ('../../.pub-cache/git/amplify-flutter-8d8bc637502e0837a518d74b7700bf3ee61d6afd/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_ios.dart').
Try correcting the name to the name of an existing method, or defining a method named 'LegacyDeviceDetails'.
    return LegacyDeviceDetails(
           ^^^^^^^^^^^^^^^^^^^
../../.pub-cache/git/amplify-flutter-8d8bc637502e0837a518d74b7700bf3ee61d6afd/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_android.dart:52:10: Error: Type 'LegacyDeviceDetails' not found.
  Future<LegacyDeviceDetails?> fetchLegacyDeviceSecrets({
         ^^^^^^^^^^^^^^^^^^^
../../.pub-cache/git/amplify-flutter-8d8bc637502e0837a518d74b7700bf3ee61d6afd/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_device_details_extension.dart:15:3: Error: Type 'LegacyDeviceDetails' not found.
  LegacyDeviceDetails? toLegacyDeviceDetails() {
  ^^^^^^^^^^^^^^^^^^^
../../.pub-cache/git/amplify-flutter-8d8bc637502e0837a518d74b7700bf3ee61d6afd/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_device_details_extension.dart:16:12: Error: The method 'LegacyDeviceDetails' isn't defined for the class 'LegacyDeviceDetailsSecret'.
 - 'LegacyDeviceDetailsSecret' is from 'package:amplify_auth_cognito/src/native_auth_plugin.g.dart' ('../../.pub-cache/git/amplify-flutter-8d8bc637502e0837a518d74b7700bf3ee61d6afd/packages/auth/amplify_auth_cognito/lib/src/native_auth_plugin.g.dart').
Try correcting the name to the name of an existing method, or defining a method named 'LegacyDeviceDetails'.
    return LegacyDeviceDetails(
           ^^^^^^^^^^^^^^^^^^^
Target kernel_snapshot failed: Exception


FAILURE: Build failed with an exception.

* Where:
Script '/Users/rick/flutter/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy' line: 1297

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/Users/rick/flutter/bin/flutter'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 8s
Exception: Gradle task assembleDebug failed with exit code 1

pubspec.yaml:

version: 1.0.8+141

environment:
  sdk: ">=3.0.0 <4.0.0"

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers  below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
#  amplify_auth_cognito: ^1.7.0
  amplify_flutter: ^1.7.0
  cached_network_image: ^3.3.0
  cloud_kit: ^1.2.0
  cupertino_icons: ^1.0.2
  eth_sig_util: ^0.0.8
  ethers: ^0.0.1+3
  firebase_analytics: ^10.6.4
  firebase_app_check: ^0.2.1+1
  firebase_core: ^2.19.0
  firebase_crashlytics: ^3.4.4
  firebase_messaging: ^14.7.4
  firebase_remote_config: ^4.3.4
  firebase_auth: ^4.13.0
  google_sign_in: ^6.1.6
  cloud_firestore: ^4.14.0
  flutter:
    sdk: flutter
  flutter_markdown: ^0.6.18
  flutter_secure_storage: ^9.0.0
  http: ^0.13.5
  is_first_run: ^1.0.0
  path: null
  path_provider: null
  share_plus: ^7.2.2
  app_links: ^3.4.5
  url_launcher: ^6.1.4
  sensors: ^2.0.3
  qr_flutter: ^4.0.0
  rate_my_app: ^2.0.0
  local_auth: ^2.1.6
  web3dart: ^2.5.0
  webview_flutter: ^4.2.2
  wallet_connect_v2: 1.0.8
  qr_code_scanner: ^1.0.1
  shared_preferences: ^2.2.2
#  flutter_wallet_card: ^3.0.3
  get_it: ^7.6.4
  connectivity_plus: ^5.0.2

flutter_icons:
  android: "launcher_icon"
#  android: false
  ios: true

  image_path: "assets/icon/logo512.png"
  min_sdk_android: 21 # android min sdk min:16, default 21
  remove_alpha_ios: true
#  adaptive_icon_background: "#161616"

dev_dependencies:
  flutter_launcher_icons: ^0.13.1
  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^2.0.1
  flutter_test:
    sdk: flutter
  logging: ^1.1.0

dependency_overrides:
  amplify_auth_cognito:
    git:
      url: https://github.com/aws-amplify/amplify-flutter.git
      ref: 8d8bc637502e0837a518d74b7700bf3ee61d6afd
      path: packages/auth/amplify_auth_cognito


from amplify-flutter.

Equartey avatar Equartey commented on June 10, 2024

@rhamnett hm versions look good. Try flutter pub clean & flutter pub get. Does that give any errors?

from amplify-flutter.

rhamnett avatar rhamnett commented on June 10, 2024

Tried that I'm afraid, same error @Equartey

flutter clean
flutter pub get

(flutter pub clean - is not a command)

from amplify-flutter.

rhamnett avatar rhamnett commented on June 10, 2024

@Equartey no problem, could if be that your patch is from 1.7.0 not 1.7.1?

! amplify_auth_cognito 1.7.0 from git https://github.com/aws-amplify/amplify-flutter.git at 8d8bc6 in packages/auth/amplify_auth_cognito (overridden)

from amplify-flutter.

Equartey avatar Equartey commented on June 10, 2024

Hi @rhamnett, I've made an update to my branch. Can you retry using this updated pubspec override?

dependency_overrides:
  amplify_auth_cognito:
    git:
      url: https://github.com/aws-amplify/amplify-flutter.git
      ref: fix/auth-android-intent-uri-query-parsing
      path: packages/auth/amplify_auth_cognito
  amplify_auth_cognito_dart:
    git:
      url: https://github.com/aws-amplify/amplify-flutter.git
      ref: fix/auth-android-intent-uri-query-parsing
      path: packages/auth/amplify_auth_cognito_dart

from amplify-flutter.

rhamnett avatar rhamnett commented on June 10, 2024

@Equartey thanks for the continued help, after a flutter clean :

Error detected in pubspec.yaml:
No file or variants found for asset: packages/amplify_auth_cognito_dart/lib/src/workers/workers.min.js.

This asset was included from package amplify_auth_cognito_dart.
Target debug_android_application failed: Exception: Failed to bundle asset files.

from amplify-flutter.

Equartey avatar Equartey commented on June 10, 2024

@rhamnett hmm, can you try without the amplify_auth_cognito_dart override?

from amplify-flutter.

rhamnett avatar rhamnett commented on June 10, 2024

@Equartey
That's worked and I believe it's solved the original query params issue!

from amplify-flutter.

rhamnett avatar rhamnett commented on June 10, 2024

Hello just wondering if this got merged at any point or if I should keep my override. Thank you

from amplify-flutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.