Tuesday, 29 September 2020

Avoiding Net.createConnection errors in Node

I am currently building an app with React and Node.js

In this app, I need to query a database on my own server with the following function, located in a separate file called "database.js"

const fetchQuery = util.promisify(con.query).bind(con)

// Get all the tracks for a given date from the 
const fetchTracks = async (date) => {
  const rows = await fetchQuery("SELECT * FROM tracks WHERE playlistDate = '"+date+"'");
}

This works perfectly when I run the file with Node from the command line. However, when I attempt to import it into my react app with

import { fetchTracks, addTracks } from '../scripts/database'

I begin to get errors in the database file, specifically Unhandled Rejection (TypeError): Net.createConnection is not a function on my fetchQuery call.

From what I've read, this happens when attempting to call the function from the browser, as that would pose a security risk. However, as I understand it, all node operations are performed on the server side, right? Why would I be getting this flag when the database is supposedly queried before the page is served? What do I need to do amend this?



from Avoiding Net.createConnection errors in Node

JWT token mismatch while OTP verification

I'm generating token while user verified OTP. but while i verify the token in header then I'm getting Invalid payload.
if any help for why i'm getting this error then would be much appreciated.

serializers.py :

class OTPVerifyForResetPasswordAPIView(APIView):
    permission_classes = (AllowAny,)
    
    def post(self,request,*args,**kwargs):
        data                = request.data
        user                = request.user
        print(user)
        
        phone_number       = request.data['phone_number']
        country_code        = request.data['country_code']
        verification_code   = request.data['verification_code']
        
        if phone_number and country_code and verification_code:
            obj_qs = User.objects.filter(phone_number__iexact = phone_number,country_code__iexact = country_code)
            obj = ''
            if obj_qs.exists() and obj_qs.count() ==1:
                user_obj = obj_qs.first() 
        
                #Development

                if verification_code == '1234':
                   
                    payload =  jwt_payload_handler(user_obj)
                    token   =  jwt_encode_handler(payload)
                    token   =  'JWT '+str(token)

                    return Response({
                        'success' : 'True',
                        'message' : 'Your mobile number verified successfully',
                        'data'    : {
                                    'phone_number' : user_obj.phone_number,
                                    'country_code'  : user_obj.country_code,
                                    'token'         : token,
                                    }
                        },status=HTTP_200_OK)
                else:
                    ##some logic....   

            else:
                ## some logic...



from JWT token mismatch while OTP verification

Monday, 28 September 2020

Unable to take screenshot in V2 Flutter using native code, it was working well in V1 Flutter

We are building an SDK that will take screenshots of an app once it is integrated. We are able to take screenshots for Native Android, Native iOS, Cordova, IONIC, React Native, Xamarin platforms. However unable to take a snapshot in V2 Flutter. The code was working fine until V1 Flutter as well. But when the same native code when executed on V2 Flutter returns a BLACK screenshot of the app.

The issue here is that V1's FlutterView was publicly available to third party plugins using a method called registrar.view(), in V2 this view is not exposed to any plugins now! https://api.flutter.dev/javadoc/io/flutter/plugin/common/PluginRegistry.Registrar.html Using V1's FlutterView we were able to capture the screenshot of the view(s) using PixelCopy, we are not able to get V2's FlutterView and we did not find any solution to capture that as well.

We have tried the following, but with no success. Can someone help me out here?

  1. Tried to get the activity from context we pass in our SDK initialization, we took view from activity and tried to paint it, blank screenshots being captured
  2. Tried to migrate the SDK Flutter Plugin to V2 using https://flutter.dev/docs/development/packages-and-plugins/plugin-api-migration
  3. Tried to traverse view hierarchy and paint the views using Activity context, blank screenshots being captured
  4. Tried to paint the view received from FlutterActivity.getWindow().getDecorView().getRootView(), blank screenshots being captured.


from Unable to take screenshot in V2 Flutter using native code, it was working well in V1 Flutter