Skip to content

Unable to install library @aws-sdk/client-cognito-identity-provider #87

Open
@jbaldaraje-cg

Description

Environment

System:
OS: macOS 14.4.1
CPU: (8) arm64 Apple M1
Memory: 105.70 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 18.19.1
path: ~/.nvm/versions/node/v18.19.1/bin/node
Yarn:
version: 1.22.21
path: ~/.nvm/versions/node/v18.19.1/bin/yarn
npm:
version: 10.2.4
path: ~/.nvm/versions/node/v18.19.1/bin/npm
Watchman: Not Found
Managers:
CocoaPods:
version: 1.15.2
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.2
- iOS 17.2
- macOS 14.2
- tvOS 17.2
- visionOS 1.0
- watchOS 10.2
Android SDK: Not Found
IDEs:
Android Studio: 2023.1 AI-231.9392.1.2311.11330709
Xcode:
version: 15.2/15C500b
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.10
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby

Description

I'm receiving an error TypeError: Object.defineProperty() invoked on non-object when I try to install the library @aws-sdk/client-cognito-identity-provider, but other libraries are working correctly.

Reproducible Demo

try to install library on super app @aws-sdk/client-cognito-identity-provider and try running the application you will received the error

CODE

`import { CognitoIdentityProviderClient, InitiateAuthCommand } from '@aws-sdk/client-cognito-identity-provider';

interface loginParams {
username: string;
password: string;
type: string;
mobile_pin: string,
customChallenge: boolean
}

const login = ({username, password,type, mobile_pin, customChallenge} : loginParams): Promise => {

const client = new CognitoIdentityProviderClient({
region: 'YOUR_REGION',
credentials: {
accessKeyId: 'YOUR_ACCESS_KEY',
secretAccessKey: 'ACCESS_KEY',
},
});

const params = {
AuthFlow: 'CUSTOM_AUTH',
ClientId: 'POOL_ID',
AuthParameters: {
USERNAME: username,
PASSWORD: password,
},
};

return new Promise((resolve, reject) => {
// Attempt login
client.send(new InitiateAuthCommand(params))
.then(data => {
console.log('Authentication successful:', data);
})
.catch(err => {
console.error('Authentication failed:', err);
});

});
};

export { login };
`
simulator_screenshot_02F9233A-C6A2-4BFB-9880-356A64FBAFEE

Activity

jbroma

jbroma commented on May 20, 2024

@jbroma
Member

Hi @jbaldaraje-cg,

I was able to resolve your issue by adding the following dependencies to transpiled node_modules:

diff --git a/packages/host/webpack.config.mjs b/packages/host/webpack.config.mjs
index 8b16341..571f287 100644
--- a/packages/host/webpack.config.mjs
+++ b/packages/host/webpack.config.mjs
@@ -147,7 +147,7 @@ export default env => {
        */
       rules: [
         {
-          test: /\.[jt]sx?$/,
+          test: /\.[cm]?[jt]sx?$/,
           include: [
             /node_modules(.*[/\\])+react/,
             /node_modules(.*[/\\])+@react-native/,
@@ -158,6 +158,10 @@ export default env => {
             /node_modules(.*[/\\])+metro/,
             /node_modules(.*[/\\])+abort-controller/,
             /node_modules(.*[/\\])+@callstack\/repack/,
+            /node_modules(.*[/\\])+@aws-sdk/,
+            /node_modules(.*[/\\])+@aws-crypto/,
+            /node_modules(.*[/\\])+@smithy/,
+            /node_modules(.*[/\\])+fast-xml-parser/,
           ],
           use: 'babel-loader',
         },

You should be able to get rid of the error this way. In Re.Pack 4.0.0 we included we've added greater compat with Metro, but in this case, you would still need to specify those dependencies yourself.

This is something we're planning to address in the next major release and get rid of this problem altogether.

jbaldaraje-cg

jbaldaraje-cg commented on May 21, 2024

@jbaldaraje-cg
Author

Hi @jbroma
I already added that and get rid the errors but after trying the library. I'm getting this new error

Simulator Screenshot - iPhone 15 Pro - 2024-05-21 at 11 04 42

On aws sdk v3 it was written on the documentation that needed to add this 2 imports on index file
import 'react-native-get-random-values';
import 'react-native-url-polyfill/auto';

But still getting the same error. Did you try on your end if its working?

Screenshot 2024-05-21 at 11 09 32 AM
jbaldaraje-cg

jbaldaraje-cg commented on May 30, 2024

@jbaldaraje-cg
Author

@jbroma Everything is working now on my end when I run to local but when I release the app. It's not working

I have auth module chunks uploaded to the s3 remote URL and connected to the host app.
on host index, I added this 2 line

import 'react-native-get-random-values';
import 'react-native-url-polyfill/auto';

this is working on my local but when I deploy to production it's not working.

this is the error I'm getting.
Screenshot 2024-05-30 at 10 37 19 AM

jbaldaraje-cg

jbaldaraje-cg commented on Nov 18, 2024

@jbaldaraje-cg
Author

@jbroma Any update on this? Do you support now using aws sdk v3?

jbroma

jbroma commented on Jan 10, 2025

@jbroma
Member

Should be supported with the current setup & rspack where everything is transpiled by default, give it a try :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Unable to install library @aws-sdk/client-cognito-identity-provider · Issue #87 · callstack/super-app-showcase