aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.12k forks source link

Amplify v6 - TypeError: Cannot read property 'decode' of undefined (underlying error response from `signIn` method) #13122

Open langerkirill opened 6 months ago

langerkirill commented 6 months ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Authentication

Amplify Version

v6

Amplify Categories

auth

Backend

Other

Environment information

``` # Put output below this line System: OS: macOS 13.2.1 CPU: (10) arm64 Apple M1 Max Memory: 473.06 MB / 32.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 20.5.1 - ~/.nvm/versions/node/v20.5.1/bin/node Yarn: 1.22.22 - /opt/homebrew/bin/yarn npm: 9.8.0 - ~/.nvm/versions/node/v20.5.1/bin/npm Watchman: 2024.01.22.00 - /opt/homebrew/bin/watchman Browsers: Chrome: 122.0.6261.128 Safari: 16.3 npmPackages: @apollo/client: ^3.4.16 => 3.9.7 @apollo/client/cache: undefined () @apollo/client/core: undefined () @apollo/client/dev: undefined () @apollo/client/errors: undefined () @apollo/client/link/batch: undefined () @apollo/client/link/batch-http: undefined () @apollo/client/link/context: undefined () @apollo/client/link/core: undefined () @apollo/client/link/error: undefined () @apollo/client/link/http: undefined () @apollo/client/link/persisted-queries: undefined () @apollo/client/link/remove-typename: undefined () @apollo/client/link/retry: undefined () @apollo/client/link/schema: undefined () @apollo/client/link/subscriptions: undefined () @apollo/client/link/utils: undefined () @apollo/client/link/ws: undefined () @apollo/client/react: undefined () @apollo/client/react/components: undefined () @apollo/client/react/context: undefined () @apollo/client/react/hoc: undefined () @apollo/client/react/hooks: undefined () @apollo/client/react/internal: undefined () @apollo/client/react/parser: undefined () @apollo/client/react/ssr: undefined () @apollo/client/testing: undefined () @apollo/client/testing/core: undefined () @apollo/client/utilities: undefined () @apollo/client/utilities/globals: undefined () @apollo/client/utilities/subscriptions/relay: undefined () @apollo/client/utilities/subscriptions/urql: undefined () @aws-amplify/react-native: ^1.0.20 => 1.0.20 @babel/core: ^7.20.0 => 7.24.0 @babel/plugin-transform-export-namespace-from: ^7.22.11 => 7.23.4 @babel/plugin-transform-flow-strip-types: ^7.22.5 => 7.23.3 @babel/plugin-transform-private-methods: ^7.22.5 => 7.23.3 @babel/preset-env: ^7.20.0 => 7.24.0 @babel/runtime: ^7.20.0 => 7.24.0 @cognitohealth/ui-libs: 8.2.5 => 8.2.5 @notifee/react-native: ^5.0.2 => 5.7.0 @react-native-async-storage/async-storage: ^1.22.3 => 1.22.3 @react-native-clipboard/clipboard: ^1.12.1 => 1.13.2 @react-native-community/netinfo: ^11.3.1 => 11.3.1 (9.5.0) @react-native-firebase/app: ^14.11.0 => 14.12.0 @react-native-firebase/messaging: ^14.11.0 => 14.12.0 @react-navigation/drawer: ^6.1.8 => 6.6.14 @react-navigation/native: ^6.0.8 => 6.1.16 @react-navigation/native-stack: ^6.2.5 => 6.9.25 @testing-library/jest-native: ^4.0.4 => 4.0.13 @testing-library/react-native: ^9.1.0 => 9.2.0 HelloWorld: 0.0.1 apollo-link-http: ^1.5.17 => 1.5.17 (1.5.8) appcenter-cli: ^2.14.0 => 2.14.0 aws-amplify: 6.0.20 => 6.0.20 aws-amplify/adapter-core: undefined () aws-amplify/analytics: undefined () aws-amplify/analytics/kinesis: undefined () aws-amplify/analytics/kinesis-firehose: undefined () aws-amplify/analytics/personalize: undefined () aws-amplify/analytics/pinpoint: undefined () aws-amplify/api: undefined () aws-amplify/api/server: undefined () aws-amplify/auth: undefined () aws-amplify/auth/cognito: undefined () aws-amplify/auth/cognito/server: undefined () aws-amplify/auth/enable-oauth-listener: undefined () aws-amplify/auth/server: undefined () aws-amplify/datastore: undefined () aws-amplify/in-app-messaging: undefined () aws-amplify/in-app-messaging/pinpoint: undefined () aws-amplify/push-notifications: undefined () aws-amplify/push-notifications/pinpoint: undefined () aws-amplify/storage: undefined () aws-amplify/storage/s3: undefined () aws-amplify/storage/s3/server: undefined () aws-amplify/storage/server: undefined () aws-amplify/utils: undefined () aws-appsync: ^4.1.4 => 4.1.10 aws-sdk: ^2.1058.0 => 2.1578.0 axios: ^0.24.0 => 0.24.0 babel-eslint: ^10.1.0 => 10.1.0 babel-jest: ^29.2.1 => 29.7.0 core-js: ^3.32.2 => 3.36.0 eslint: ^7.14.0 => 7.32.0 eslint-config-prettier: ^8.5.0 => 8.10.0 eslint-config-react-app: ^7.0.1 => 7.0.1 eslint-plugin-formatjs: ^4.1.0 => 4.12.2 eslint-plugin-prettier: ^4.0.0 => 4.2.1 eslint-plugin-react-native: ^4.0.0 => 4.1.0 husky: ^7.0.4 => 7.0.4 jest: ^29.2.1 => 29.7.0 jest-fetch-mock: ^3.0.3 => 3.0.3 lodash: ^4.17.21 => 4.17.21 metro-react-native-babel-preset: ^0.73.10 => 0.73.10 moment: ^2.29.2 => 2.30.1 prettier: ^2.6.2 => 2.8.8 react: 18.2.0 => 18.2.0 react-intl: ^5.24.4 => 5.25.1 react-native: ^0.71.13 => 0.71.17 react-native-code-push: ^8.1.0 => 8.2.1 react-native-config: ^1.4.6 => 1.5.1 react-native-device-info: ^8.4.9 => 8.7.1 react-native-error-boundary: ^1.1.15 => 1.2.4 react-native-exception-handler: ^2.10.10 => 2.10.10 react-native-gesture-handler: ^2.9.0 => 2.15.0 react-native-get-random-values: ^1.11.0 => 1.11.0 react-native-keyboard-aware-scroll-view: ^0.9.5 => 0.9.5 react-native-safe-area-context: ^4.5.1 => 4.9.0 react-native-screens: ^3.19.0 => 3.29.0 react-native-sound: ^0.11.2 => 0.11.2 react-native-super-grid: ^4.2.0 => 4.6.1 react-native-system-setting: ^1.7.6 => 1.7.6 react-native-table-component: ^1.2.1 => 1.2.2 react-native-uuid: ^2.0.1 => 2.0.1 react-test-renderer: 18.2.0 => 18.2.0 rn-material-ui-textfield: ^1.0.5 => 1.0.9 twrnc: ^3.0.2 => 3.6.8 typescript: ^4.6.3 => 4.9.5 (5.4.2) util: ^0.12.4 => 0.12.5 npmGlobalPackages: corepack: 0.19.0 npm: 9.8.0 ```

Describe the bug

I have been unable to use the new signIn with amplify v6. I am continuously receiving the bug:

 LOG  underlying [TypeError: Cannot read property 'decode' of undefined]

In response to a login attempt. This is impossible for me to debug, I tracked it down to a failure in signInHelpers.ts in @aws-amplify/auth:

console.log("jsonReq", jsonReq);

const resp = await initiateAuth(
{
    region: getRegion(userPoolId),
    userAgentValue: getAuthUserAgentValue(AuthAction.SignIn),
},
jsonReq,
);

console.log("resp", resp);

jsonReq logs to the console but resp does not.

Expected behavior

A sign-in occurs and the user is logged in.

Reproduction steps

Install amplify version 6.0.20. Attempt to use the new signIn method. Observe the failure.

Code Snippet

amplify configuration:

    const amplifyConfig = {
        Auth: {
            Cognito: {
                userPoolId: vars.Auth.CognitoUserPoolId,
                userPoolClientId: vars.Auth.CognitoAndroidClientId,
            },
        },
    };

    Amplify.configure(amplifyConfig);

Calling the signIn method:

import { signIn } from "aws-amplify/auth";
import { Amplify } from "aws-amplify";

async function logIn(
    username,
    password,
    props,
    setShowActivityIndicator,
    setValidUserID,
    setValidPassword,
    setShowNewPasswordModal
) {
    try {
        const config = Amplify.getConfig();
        console.log("config mobile", config);
        const { nextStep, isSignedIn } = await signIn({
            username,
            password,
        });
        console.log("isSignedIn", isSignedIn);
        if (nextStep === "NEW_PASSWORD_REQUIRED") {
            setShowActivityIndicator(false);
            setShowNewPasswordModal(true);
            return;
        }
        setShowActivityIndicator(false);
        props.navigation.navigate("CareUnitScreen");
    } catch (error) {
        setShowActivityIndicator(false);
        setValidUserID(false);
        setValidPassword(false);
        console.log("underlying", error.underlyingError);
        console.log("name", error.name);
        console.log("message", error.message);
        console.log("code", error.code);
        console.log("stack", error.stack);
    }
}

Log output

``` // Put your logs below this line LOG Running "CognitoHealthRNApp" with {"rootTag":831} info Opening developer menu... LOG [CodePush] An update is available but it is not targeting the binary version of your app. info Opening developer menu... LOG configuring amplify LOG config ui libs {"Auth": {"Cognito": {"userPoolClientId": "5rsj80tit6csifv50sn7ragq9c", "userPoolId": "us-east-2_ROeqeGDC3"}}} LOG done LOG configuring amplify LOG config ui libs {"Auth": {"Cognito": {"userPoolClientId": "5rsj80tit6csifv50sn7ragq9c", "userPoolId": "us-east-2_ROeqeGDC3"}}} LOG done LOG config mobile {"Auth": {"Cognito": {"userPoolClientId": "5rsj80tit6csifv50sn7ragq9c", "userPoolId": "us-east-2_ROeqeGDC3"}}} LOG input {"password": "safe2020", "username": "level1-user"} LOG signinhelpers LOG jsonReq {"AuthFlow": "USER_SRP_AUTH", "AuthParameters": {"SRP_A": "dc8aed8c12187fd1141e5b948fd9f1eea1ff81812c2f78bca125d6d986f65c89939e4606e16223e6757a87704b64e6448ed22a8dc1eecf49bfce1f2040072293c460a8819fa043396e915c007027f599cbaa2a7eb6c92bdfbff917028a917b26f6edf74d812b48e8ef1aa2ca46f7473fe9c362deed654a040b5542ceeee44e31d54023661877964c34f9ba68cf21d4dd3079b7d1a754d5144b342e8f7fbf76c1cf17f96060d352bc7be2b83d0906640e4ecb3ad237c6a8f021062c0e40f792e9ce0c79e2cf24957ec9c38ca3c8ab3a385e9350caf1e0080a9de252a0e17fd04f51bd3b4cd3093aa7b261bd594854e5e52f56ac535353c68dc8e824bfd635cea8e6de879c6ef30c9c712d3df817500b98edd7018c6830854286db2fd52d58e1be901ddb2b9b979a680c17c55ae9b6b00070d7c52de7c818a37ccc5383dfc27a5c319fa60dc0bd598bc0b93fe423b658d2bedd591b5de3d1ce02e5f41700627bbcb0bc8d5d9b8d221e39897ea194c4aff8fe0584b521f28afc6564f9b1e023e5d8", "USERNAME": "level1-user"}, "ClientId": "5rsj80tit6csifv50sn7ragq9c", "ClientMetadata": undefined, "UserContextData": undefined} LOG signInWithSRP error [TypeError: Cannot read property 'decode' of undefined] LOG underlying [TypeError: Cannot read property 'decode' of undefined] LOG name Unknown LOG message An unknown error has occurred. LOG code undefined LOG stack Unknown: An unknown error has occurred. at construct (native) at apply (native) at _construct (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:22860:106) at Wrapper (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:22832:64) at construct (native) at _callSuper (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:494230:170) at AmplifyError (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:494241:25) at construct (native) at _callSuper (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:517162:170) at AuthError (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:517169:25) at assertServiceError (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:517877:75) at ?anon_0_ (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:521400:108) at throw (native) at asyncGeneratorStep (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:23855:26) at _throw (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:23877:29) at tryCallOne (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/3u613d2l/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:53:16) at anonymous (/root/react-native/ReactAndroid/hermes-engine/.cxx/Release/3u613d2l/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:139:27) at apply (native) at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:29431:26) at _callTimer (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:29350:17) at _callReactNativeMicrotasksPass (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:29380:17) at callReactNativeMicrotasks (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:29543:44) at __callReactNativeMicrotasks (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:5608:46) at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:5420:45) at __guard (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:5592:15) at flushedQueue (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:5419:21) at invokeCallbackAndReturnFlushedQueue (http://localhost:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.cognitohealth.cognito3.development&modulesOnly=false&runModule=true:5413:33) ```

aws-exports.js

No response

Manual configuration

Auth: {
    Cognito: {
        userPoolId: vars.Auth.CognitoUserPoolId,
        userPoolClientId: vars.Auth.CognitoAndroidClientId,
    },
}

Additional configuration

{
    "UserPool": {
        "Id": "us-east-2_...",
        "Name": "...",
        "Policies": {
            "PasswordPolicy": {
                "MinimumLength": 8,
                "RequireUppercase": false,
                "RequireLowercase": false,
                "RequireNumbers": false,
                "RequireSymbols": false,
                "TemporaryPasswordValidityDays": 7
            }
        },
        "DeletionProtection": "INACTIVE",
        "LambdaConfig": {
            "PreSignUp": "arn:aws:lambda:us-east-2:...:function:us-east-2-dev-AuthStack-...",
            "PreTokenGeneration": "arn:aws:lambda:us-east-2:...:function:latest-v3-CloudDeployment-RS..."
        },
        "LastModifiedDate": "2022-06-30T13:22:09.042000-06:00",
        "CreationDate": "2022-06-30T13:22:09.042000-06:00",
        "SchemaAttributes": [
            {
                "Name": "sub",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": false,
                "Required": true,
                "StringAttributeConstraints": {
                    "MinLength": "1",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "given_name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "family_name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "middle_name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "nickname",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "preferred_username",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "profile",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "picture",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "website",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
            {
                "Name": "email",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "email_verified",
                "AttributeDataType": "Boolean",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false
            },
            {
                "Name": "gender",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "birthdate",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "10",
                    "MaxLength": "10"
                }
            },
            {
                "Name": "zoneinfo",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "locale",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "phone_number",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "phone_number_verified",
                "AttributeDataType": "Boolean",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false
            },
            {
                "Name": "address",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "0",
                    "MaxLength": "2048"
                }
            },
            {
                "Name": "updated_at",
                "AttributeDataType": "Number",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "NumberAttributeConstraints": {
                    "MinValue": "0"
                }
            },
            {
                "Name": "custom:custom:first_name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "1",
                    "MaxLength": "256"
                }
            },
            {
                "Name": "custom:custom:last_name",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "1",
                    "MaxLength": "256"
                }
            },
            {
                "Name": "custom:custom:expire",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "1",
                    "MaxLength": "256"
            {
                "Name": "custom:care_units",
                "AttributeDataType": "String",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false,
                "StringAttributeConstraints": {
                    "MinLength": "1",
                    "MaxLength": "256"
                }
            }
        ],
        "AutoVerifiedAttributes": [
            "email"
        ],
        "AliasAttributes": [
            "email"
        ],
        "VerificationMessageTemplate": {
            "DefaultEmailOption": "CONFIRM_WITH_CODE"
        },
        "UserAttributeUpdateSettings": {
            "AttributesRequireVerificationBeforeUpdate": []
        },
        "MfaConfiguration": "OFF",
        "EstimatedNumberOfUsers": 12,
        "EmailConfiguration": {
            "EmailSendingAccount": "COGNITO_DEFAULT"
        },
        "UserPoolTags": {},
        "AdminCreateUserConfig": {
            "AllowAdminCreateUserOnly": true,
            "UnusedAccountValidityDays": 7,
            "InviteMessageTemplate": {
                "EmailMessage": "A Cognito Health account has been created using this email address.<br/>\n\n<div>\n<b>Acco
unt Id: </b> {username}<br/>\n<b>Temporary Password: </b>{####}<br/>\n</div>\n\nThe above password must be reset the next t
ime you log in.\n",
                "EmailSubject": "Temporary Password for Your Cognito Health Account"
            }
        },
        "UsernameConfiguration": {
            "CaseSensitive": false
        },
        "Arn": "arn:aws:cognito-idp:us-east-2:...:userpool/us-east-2_...
    }

Mobile Device

Google Pixel 7

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

cwomack commented 6 months ago

Hey, @langerkirill and thanks for opening this issue. The decode method in React Native is vended by base-64 package which is a dependency of @aws-amplify/react-native. Can you see if deleting your node_modules folder, as well as your package-lock.json file, then reinstalling dependences with npm install resolves the error?

If it doesn't, possibly verify you have the necessary dependency with npm why base-64 as well.

langerkirill commented 6 months ago

Hi @cwomack, thanks for the response. I tried deleting node_modules and yarn.lock, no luck. I got the same error. It does appear that I have base-64:

Mobile git:2890-slow-login ❯ yarn why base-64                                                                              ✹ ✭
yarn why v1.22.22
warning ../../package.json: No license field
[1/4] 🤔  Why do we have the module "base-64"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "base-64@1.0.0"
info Reasons this module exists
   - "@aws-amplify#react-native" depends on it
   - Hoisted from "@aws-amplify#react-native#base-64"
info Disk size without dependencies: "20KB"
info Disk size with unique dependencies: "20KB"
info Disk size with transitive dependencies: "20KB"
info Number of shared dependencies: 0
✨  Done in 0.29s.
cwomack commented 6 months ago

@langerkirill, are you able to provide a sample repo possibly that can reproduce this reliably? We haven't been able to reproduce it on our side with a React Native app. Can you also clarify if you're calling Amplify.configure() at the root of your app as well?

langerkirill commented 6 months ago

@cwomack, we are unable to call Amplify.configure() in the root of our app because our app requires that users input a Facility ID on the first page which we then need to use to fetch information that we pass into the Amplify configuration. We have different userpoolid values for users in different regions for example. We need to configure Amplify on the second page before sign in. This was never an issue with v4. Do you think it may have become an issue for v6?

I will see about getting you a sample repo.

langerkirill commented 6 months ago

@cwomack I added you as a collaborator to a sample repo where you can reproduce this issue yourself. You should be able to pull it down and follow the instructions I will add to the README to reproduce the issue. Thanks.

langerkirill commented 6 months ago

I found another error in the debug console mode related to an undefined URL.

Screenshot 2024-03-20 at 5 39 59 PM
langerkirill commented 6 months ago

My issues were resolved by implementing the suggestion in the following comment:

https://github.com/aws/aws-sdk-js-v3/issues/4877#issuecomment-1803353706

cwomack commented 6 months ago

@langerkirill, glad you found the workaround already! We'll mark this as a bug on our side due to the dependencies in our library on the aws-sdk. We're tracking this internally and will update this issue when a fix is released on our side that updates our dependencies.

In the mean time, if anyone comes across this same blocker please refer to this comment for a workaround.