Hybrid Encryption for GET request using React and Node JS - encryption

I managed to to POST/UPDATE and DEL request from React application (from different microfrontend using Webpack 5), to multiple backend application (microservice) written in Node JS.
Each data is encrypted using a key created with symmetric key. The symmetric key is also encrypted using Public key from client. Then both encrypted data and key sent to server to be decrypted in the server for storing.
What about GET request ? How do I do reverse encryption of data sent from server to be read on the client, especially I have multiple micro front end client. Do I create multiple RSA pair keys for each micro front end, with private keys stored in each client, public key to be sent along with GET request to the server ?

Related

Produce/keep static AES key for all the applications

Whenever any application(browser, thick client application) is requesting to generate an AES key, I would like to supply a static key to that application.
Is there any way to do this in Linux or windows?
There is not an universal way of generating AES keys that applications needs to adhere to.
Forcing a static key on an arbitrary application ought to be hard/impossible if the application is secure - and would be a case by case activity.

When is the right time to create dynamodb connection in a server application?

Let's assume you are developing a server-side application with express and for incoming requests, you have to access DynamoDb and retrieve something. The question is, when is the right time to instantiate the DynamoDb connection:
const dynamodb = new AWS.DynamoDB({
region: process.env.AWS_DEFAULT_REGION,
});
const docClient = new AWS.DynamoDB.DocumentClient({ service: dynamodb });
Should I do this once for all the API handlers or should I create a new connection for each incoming request?
As a best practice, it is recommended to declare DocumentClient the outside the function. However, please note that DocumentClient is not a database connection object. DocumentClient is just an abstraction in the AWS.DynamoDB namespace. The document client abstraction makes it easier to read and write data to Amazon DynamoDB with the AWS SDK for JavaScript.
Unlike RDBMS connection, it is not required to maintain the connection or connection pool to connect to DynamoDB database.
DynamoDB is a web service, and interactions with it are stateless.
Applications do not need to maintain persistent network connections.
Instead, interaction with DynamoDB occurs using HTTP(S) requests and
responses.
new AWS.DynamoDB(options = {}) ⇒ Object
The service object AWS.DynamoDB uses asynchronous request to send data to DynamoDB. The DocumentClient also uses this service object internally.
By default, the SDK will send asynchronous HTTP requests to DynamoDB. However, you can change the default behavior by setting the attribute httpOptions.xhrAsync to false.

Send Request to Web Connector using my Application Quick Books

I want to Add Customer by sending request to Web Connector. I have done with the sample code provided by the SDK. I want to know the process of getting and sending data using Web Connector.
How can i call Quick Book Web Service and send request and retrieve data.
How can i call Quick Book Web Service
You can't.
That is not the way that the QuickBooks Web Connector works.
You're starting point should be to read the 98-page PDF about the QuickBooks Web Connector included with the QuickBooks SDK. Here's a link:
https://developer-static.intuit.com/qbSDK-current/doc/PDF/QBWC_proguide.pdf
As an overview, the way the Web Connector is a simple SOAP client that sits next to QuickBooks and it calls your web service, not the other way around. It polls a web service (SOAP) that you set up and essentially asks "Hey, what should I do?" over and over again. You then give it XML (qbXML) commands telling it what to do (e.g. <CustomerAdd>...</CustomerAdd>, etc.)
As an overview, you implement a SOAP web service with these methods:
array authenticate(string strUserName, string strPassword)
You should have the username and password stored in your web app.
If the username and password are valid, you generate a session ID (a “ticket”) and store this ticket in your database. Every subsequent call to you will include this ticket string, and you'll check to ensure the ticket is valid on every subsequent call.
You should then check to see if there is anything to do. You should be maintaining a queue of things to do within your SOAP server. Return an appropriate response per the spec.
string sendRequestXML(string ticket, string strHCPResponse, string strCompanyFileName, string qbXMLCountry, int qbXMLMajorVers, int qbXMLMinorVer)
The Web Connector will call this method to ask you "Hey, what should I do?".
You should check your internal queue of things to do, and pull the next item out of the queue. You should return a valid qbXML XML request for that queue item as a string.
So if you wanted to add a customer to QuickBooks, you'd return something like <CustomerAdd><Name>...</Name></CustomerAdd>
If you wanted to get a list of customers from QuickBooks, you can do something like <CustomerQuery>...</CustomerQuery>
integer receiveResponseXML(string ticket, string response, string hresult, string message)
This is how the Web Connector sends data back to you. So for example, if you told the Web Connector to add a customer, it's going to add the customer to QuickBooks and then send you an XML response telling you if it was successful or not.
That's all there is to it.
You need to implement a SOAP service with 3 very simple methods, and a queue full of XML commands.
A larger explanation, complete with SOAP and qbXML examples is here:
http://wiki.consolibyte.com/wiki/doku.php/quickbooks_web_connector
If you're developing in .NET, then you should install the QuickBooks SDK:
https://developer.intuit.com/docs/0250_qb/0020_get_set_up/sdk_downloads
Because it provides you with sample code in .NET which shows you how to implement all of this stuff. It gets put here on your computer when you install the SDK:
C:\Program Files (x86)\Intuit\IDN\QBSDK13.0\samples\qbdt\c-sharp\qbXML\WCWebService\

C# TCP Multithread Server and Client with requirements

I am currently working on TCP multithread server and clients written in C#. I was looking around on Google and tried more than 5 examples but seems none of them can serve all requirements. As I am not familiar with networking, so it would be appreciated if someone can point me to the right direction.
Here are the requirements I need:
multithread, I need a server which can handle multiple clients, though those clients do not need to communicate each other.
continous operations, after clients connected to the server, they need to keep sending messages to each other, until the server drops all the clients. The server needs to identify each client. The clients do not need to disconnect from server on themselves, normally.
disconnection notification, most of those examples found on Google do not have this feature, I need the server to know when the connected client disconnects, so the server can notifiy the user.
Actually the closest example I found is this:
http://www.codeproject.com/Articles/22918/How-To-Use-the-SocketAsyncEventArgs-Class
But the problem I am facing is that the messages are inside the class Token, I included all those classes in my Window Form Application, which is my main application. Those information like client ID, client status, or actions to clients, will be performed in the Form. I dont know how to bring those variables from Token class to my Form.
This is another example seems can suit my purpose:
http://www.codeproject.com/Articles/2866/Multi-threaded-NET-TCP-Server-Examples
But I am not sure how to change it since it blocked my Form from displaying.
Thanks for help.
Some months later... First, you have to keep in mind that the window form isn't async native, you have to implement invoke methods to use the tcp AsyncCallback. Elsewhere to handle clients, you have to create a new dictionary like :
Dictionary<string, System.Net.Sockets> clientList;
It could be int in case of database ids or simply you could use the native system handle :
this.anonymousSock.Client.Handle
And adding them like this :
clientList.Add("ID", this.anonymousSock);
Finaly :
public void Send(string data, string id)
{
Socket Client = this.clientList[id];
byte[] byteData = Encoding.ASCII.GetBytes(data);
Client.BeginSend(byteData, 0,
byteData.Length, 0,
new AsyncCallback(SendCallback), Client);
}
While receiving, you could in this case identify client by checking your sockets entries or by using tokens.
And then no cpu/memory burn with threads.

SOAP Web Service on ASP.NET - Multiple Connection - Static Values - XMLRPC API

Have a SOAP Web Service that encapsulates calls to a 3rd party API... so our application can simply call my service and then my service handles all the various calls to the API. Works just fine.
However, we've hit a problem where the API we're connecting to allows a max of 10 connections at any given time for a given set of credentials.
Connections at most take a couple of seconds to process, but when we go live, we could in theory have users that max out this. So we've created multiple accounts (5) to the API giving us 50 connections across the 5 users.
How does ASP.NET handle connections to the Web service? I know it works asynchronously, but does it spawn multiple instances of my class or reuse the same class. Will variables persist across instances (i.e Will static variables work)?
What I need to do is if a call to the API fails on Client1, rollover to Client2 (or Clients[0], Clients[1]) etc... Sadly I have no way to detect if a given Client is out of connections at any given moment. I could poll it with a test call, but that would take time and be no guarantee the the client has a connection available when I make the call.
The API I'm calling is via XMLRPC Proxy class (CookComputing). Is the "connection" made when the Client is created or when the call is made, passing along the credentials?
public static IVoicestar GetClient(string userID, string password)
{
IVoicestar client = XmlRpcProxyGen.Create<IVoicestar>();
client.Credentials = new NetworkCredential(userID, password);
return client;
}
Seems from this that the credentials simply "ride along" until I make a call via Client.MethodCall() and then the connection is made.
If you are using ASP.NET Web Services (asmx) then it would spawn a new instance of your web service class for each request. In case WCF based web services, you can control the instancing /concurrency using attributes/configuartion (see this article) - you have three instancing modes possible - per call, per session and singleton.
Irrespective of what you are using, you can always implement your own pooling mechanism to pool your API connection. You already have a factory method to get the API client - just put call to pooling layer within method.
Normally Windows XP and Windows 7 have a limit of 10 concurrent TCP/IP connections. Maybe that's it. Be sure to work in a windows server version.

Resources