Saturday 19 November 2022

essential tools for javascript developers

1) JSdoc

Documenting code is very essential as it provide better readabilty to other programmers.

< https://www.valentinog.com/blog/jsdoc/ >

  

2) ESlint

Code linting is essential for developement, for finding problem early and fixing them.

< https://eslint.org/ >


3) Jest

Jest is powerful javascript unit testing framework which helps you with automated testing.

https://jestjs.io/ >

https://www.youtube.com/watch?v=FgnxcUQ5vho >


4) Babel

< https://babeljs.io/docs/en/ >


5) Testing FireBase cloud functions 

https://firebase.google.com/docs/functions/unit-testing >


6) Unit testing react native apps

< https://jestjs.io/docs/tutorial-react-native >

https://blog.logrocket.com/unit-testing-react-native/ >


Some more :

https://everyday.codes/javascript/7-really-good-reasons-not-to-use-typescript/ >

Sunday 18 September 2022

All About "Time" in Java Script

 



While using date & time we always want to display time in local time, for example india is GMT + 5:30.

But what's GMT and UTC ?




For programmers building business-oriented apps, the upshot is that UTC is the new GMT. You can use the terms interchangeably, with the difference being literally less than a second. So for all practical purposes in most apps, no difference at all.


How do we store time ?

In computer we store time at 32-bit interger which is linux UTC epoch time. 

Try this code :

From where Time zone is decided ?

Time zone comes seperately from local setting either from your computer setting or mobile setting.
So based on you want to display local time ? or UTC time ? javascript convert epoch time into suitable string.

Firebase timestamp vs Javascript Date :





Friday 12 August 2022

Making secure apps with Firebase and react native

while working on security always remember that you should not trust client side data ever ! You can add validations on Client side and it's good practise to avoid loading of server but you should always perform same validation on server side.

First start scanning your client side and then slowly move towards your server side :



Detailed article about client side security from react native team :
https://reactnative.dev/docs/security

other refs:

https://stackoverflow.com/questions/55856221/what-is-the-most-secure-way-store-keys-in-react-native


Backend server side security :

Full check list from firebase team : https://firebase.google.com/support/guides/security-checklist

https://developers.google.com/learn/pathways/firebase-security-layers

https://firebase.blog/posts/2019/03/firebase-security-rules-admin-sdk-tips

https://www.youtube.com/watch?v=pvLkkLjHdkw

https://www.youtube.com/watch?v=BGCLPiR_0Lg

https://www.youtube.com/watch?v=oFlHzF5U-HA


Let's try to understand some common attacks on server side :


1) DDoS Attack :

Though this is not perfect but firebase provides facility for app check so that you can be assume that request is coming from verified app.

https://firebase.google.com/docs/app-check

App check for functions : https://firebase.google.com/docs/app-check/cloud-functions?authuser=0&hl=en

You can also setup cloudflare between firebase and your app and allow only certain origin.


2) Man In the middle? 

Man in the middle attack is common for uncrypted data, so always use encrypted Endpoints.

Luckily firebase cloud function calls are E2E encypted.
Still it recommeded that you more sensitive information we come up with our own encyption mechanism.


3) Protect Your FireStore:

Always remember write your security rules. Make your self confirtable with security rules and write them carefully.

ref:

https://www.youtube.com/watch?v=eW5MdE3ZcAw

https://www.youtube.com/watch?v=QEuu9X9L-MU&t=119s

https://www.youtube.com/watch?v=8Mzb9zmnbJs

https://www.youtube.com/watch?v=TglPc74M3DM


4) Be carefull about your NPM packages :

You can check all vulnerabilities on:

https://security.snyk.io/package/npm/firebase


5) Storing secrets in google cloud :

https://cloud.google.com/secret-manager/docs/creating-and-accessing-secrets#create

https://cloud.google.com/functions/docs/configuring/secrets

https://cloud.google.com/secret-manager/docs/reference/libraries#client-libraries-install-nodejs



5) Some already happned hacking:

How to NOT get a 30K Firebase Bill : https://www.youtube.com/watch?v=Lb-Pnytoi-8

Basic hacking for firebase : https://www.youtube.com/watch?v=mnTLrNrk93Q

https://stackoverflow.com/questions/67061264/is-it-possible-to-hack-and-update-a-firebase-realtime-database-data

https://book.hacktricks.xyz/network-services-pentesting/pentesting-web/buckets/firebase-database




Tuesday 26 July 2022

Filling revised return due to rectification in India

Types of Filings :




Type of Taxs :

Most of us individual have to pay Regular Assesment tax ( 400 ) using Challan 280.

1) Regular Assesment - 400

2) Self Assesment - 300

3) Advance Tax - 100



Demands:





Saturday 16 July 2022

Push notifications and Fire base messaging in React Native

 


Referance:

https://firebase.google.com/docs/cloud-messaging/android/client

https://rnfirebase.io/messaging/usage

https://rnfirebase.io/reference/messaging


QnA:

https://stackoverflow.com/questions/34225779/how-to-set-the-app-icon-as-the-notification-icon-in-the-notification-drawer

https://stackoverflow.com/questions/57140028/get-fcm-token-in-react-native



Applications:

https://firebase.google.com/docs/functions/use-cases

https://github.com/firebase/functions-samples/blob/main/fcm-notifications/functions/index.js


Notifee:

https://github.com/stacktiger/local-notifications-react-native-demo

https://github.com/invertase/notifee/issues/291

https://www.youtube.com/watch?v=yYyopSDbw18




Android - React native quick cheat sheet

1) check version of any package : 

npm view @react-native-community/netinfo version

2) uninstall any package:

npm uninstall @react-native-community/netinfo

3) install any package:

npm install @react-native-community/netinfo

4) install specific version of package:

npm install @react-native-community/netinfo@6.0.0

5) install latest version of package:

npm install @react-native-community/netinfo@latest

6) --save flag to that command to add it to your package.json dependencies 

7) JDK download and installation : https://jdk.java.net/archive/

- after downloading zip file unzip and keep it in any folder example : C:\Program Files\jdk-11.0.2\

- set top level path as JAVA_HOME system variable : C:\Program Files\jdk-11.0.2\

- add path variable for java binaries : C:\Program Files\jdk-11.0.2\bin\

- open cmd and type : java -version and check version.

https://stackoverflow.com/questions/68344424/unrecognized-attribute-name-module-class-com-sun-tools-javac-util-sharednametab

8) Check JAVA_HOME : echo %JAVA_HOME%

9) Clear cache :

React native : react-native start --reset-cache

npm : npm start -- --reset-cache

https://stackoverflow.com/questions/46878638/how-to-clear-react-native-cache

10) Note : if you using vs code you might need to restart vs code to get updated path varibales.

11) If some process keep getting stuck clear cache and try to restart the PC.

12) watchman watch-del <Project-Path>

13) gradlew build -Phttp.socketTimeout=60000 -Phttp.connectionTimeout=60000

https://stackoverflow.com/questions/37156568/increase-timeout-for-gradle-to-get-a-maven-dependency

14) use implementation instead of compile :
https://stackoverflow.com/questions/44493378/whats-the-difference-between-implementation-api-and-compile-in-gradle







Saturday 18 June 2022

react native regex quick guide

 

^  => Start of line
$  => End of line

[ ... ]  => one of the character in bracket.

( ... )  => Capturing group

(?: ... ) =>  Non capturing group

+ => one or more time

|  => logical OR

{40} => exactly 40 times , can be used to provide length



/   => escape special characters
i  => case incencitive


Referance :
https://www.rexegg.com/regex-quickstart.html#chars


Wednesday 25 May 2022

List of tools for a lean mobile development team

 here I would try to list some tools which will provide high yield to a lean team.


1) Design your Idea :

Figma 

2) Source code management :

Github

GUI - Github for desktop

Github can be alternative to Atlassian tools for small team as well.

3) Communication :

GSuite

Slack

4) Editor :

VS code

5) Database :

AWS

Firebase

6) Other:

Microsoft Office suites -> ppts and excels.


Thursday 19 May 2022

Run Firebase functions locally

Prerequisite :

- firebase admin must be set up on your local machine

- your cloud functions must be deployed.


Steps:

1) open cmd.exe type : firebase emulators:start

2) in another cmd.exe type: firebase functions:shell

3) Now type any cloud function as if you calling any function like : hello() , add(2,3) etc.


Reference: 

https://www.youtube.com/watch?v=J0j1uhelY7M

https://firebase.google.com/docs/functions/local-shell

https://firebase.google.com/docs/functions/write-firebase-functions

Saturday 8 January 2022