Implement login
This commit is contained in:
parent
f05de6a52e
commit
200f737083
109
source/app.d
109
source/app.d
|
@ -1,6 +1,8 @@
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import std.conv;
|
import std.conv;
|
||||||
|
|
||||||
|
import core.sys.linux.unistd;
|
||||||
|
|
||||||
import vibe.d;
|
import vibe.d;
|
||||||
import vibe.data.json;
|
import vibe.data.json;
|
||||||
import vibe.textfilter.urlencode;
|
import vibe.textfilter.urlencode;
|
||||||
|
@ -61,6 +63,31 @@ class StartFlow : ApiRequest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class WidgetEvents : ApiRequest
|
||||||
|
{
|
||||||
|
string applicationId;
|
||||||
|
Json[string][] widgetEventInformations;
|
||||||
|
|
||||||
|
this(string applicationId, string[string] widgetEventInformations, string[string] attributes)
|
||||||
|
{
|
||||||
|
this.applicationId = applicationId;
|
||||||
|
|
||||||
|
Json[string] eventInformations;
|
||||||
|
foreach(key, value; widgetEventInformations)
|
||||||
|
{
|
||||||
|
eventInformations[key] = value.serializeToJson;
|
||||||
|
}
|
||||||
|
this.widgetEventInformations = [eventInformations];
|
||||||
|
|
||||||
|
Json[string] jsonAttributes;
|
||||||
|
foreach(key, value; attributes)
|
||||||
|
{
|
||||||
|
jsonAttributes[key] = value.serializeToJson;
|
||||||
|
}
|
||||||
|
this.widgetEventInformations[0]["attributes"] = jsonAttributes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ApiMessage
|
class ApiMessage
|
||||||
{
|
{
|
||||||
string executionMode;
|
string executionMode;
|
||||||
|
@ -99,7 +126,7 @@ class SessionApiMessage : ApiMessage
|
||||||
|
|
||||||
class ApiClient
|
class ApiClient
|
||||||
{
|
{
|
||||||
enum string Endpoint = "https://m.belfius.be/F2CRenderingDexiaToClient/GEPARendering/machineIdentifier=s0/";
|
enum string Endpoint = "https://m.belfius.be/F2CRenderingDexiaToClient/GEPARendering/machineIdentifier=s4/";
|
||||||
|
|
||||||
private string _locale;
|
private string _locale;
|
||||||
|
|
||||||
|
@ -120,13 +147,78 @@ class ApiClient
|
||||||
_sessionId = response.responseSets[0].responses[0]["SessionOpened"][0]["sessionId"].get!string;
|
_sessionId = response.responseSets[0].responses[0]["SessionOpened"][0]["sessionId"].get!string;
|
||||||
_requestCounter = 1;
|
_requestCounter = 1;
|
||||||
|
|
||||||
auto startFlowRequest = new StartFlow("yui3a", "Container", "gef0.gef1.gemd.Flow_MobileApplication.diamlflow", ["deviceType": "simple", "language": "2", "smsType": "otpUrl"], null);
|
auto startFlowRequest = new StartFlow("yui3a", "Container", "gef0.gef1.gemd.Flow_MobileApplication.diamlflow",
|
||||||
|
["deviceType": "simple", "language": "2", "smsType": "otpUrl"], null);
|
||||||
response = sendRequest("sequential", startFlowRequest);
|
response = sendRequest("sequential", startFlowRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
ApiResponse sendRequest(T : ApiRequest)(string executionMode, T request)
|
void login1(string cardNumber, string phoneZone, string phoneSubscriber)
|
||||||
{
|
{
|
||||||
|
auto widgetEventsRequest = createClickImageEvent("Container@reuse_Screen@img_Operations");
|
||||||
|
sendRequest("sequential", widgetEventsRequest);
|
||||||
|
|
||||||
|
widgetEventsRequest = createChangeValueEvent("Container@reuse_flowAuthentication@inp_PanNumbersimple", cardNumber[0 .. 4]);
|
||||||
|
sendRequest("sequential", widgetEventsRequest);
|
||||||
|
|
||||||
|
widgetEventsRequest = createChangeValueEvent("Container@reuse_flowAuthentication@inp_PanNumbersimple", cardNumber);
|
||||||
|
sendRequest("sequential", widgetEventsRequest);
|
||||||
|
|
||||||
|
widgetEventsRequest = createChangeValueEvent("Container@reuse_flowAuthentication@inp_PhoneZone", phoneZone);
|
||||||
|
sendRequest("sequential", widgetEventsRequest);
|
||||||
|
|
||||||
|
widgetEventsRequest = createChangeValueEvent("Container@reuse_flowAuthentication@inp_PhoneSubscriber", phoneSubscriber);
|
||||||
|
sendRequest("sequential", widgetEventsRequest);
|
||||||
|
|
||||||
|
widgetEventsRequest = createClickButtonEvent("Container@reuse_flowAuthentication@btn_Identification");
|
||||||
|
sendRequest("sequential", widgetEventsRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
void login2(string otp, string password)
|
||||||
|
{
|
||||||
|
auto widgetEventsRequest = createClickImageEvent("Container@reuse_Screen@img_Operations");
|
||||||
|
sendRequest("sequential", widgetEventsRequest);
|
||||||
|
|
||||||
|
widgetEventsRequest = createChangeValueEvent("Container@reuse_flowAuthentication@inp_otp", otp);
|
||||||
|
sendRequest("sequential", widgetEventsRequest);
|
||||||
|
|
||||||
|
widgetEventsRequest = createChangeValueEvent("Container@reuse_flowAuthentication@inp_pw", password);
|
||||||
|
sendRequest("sequential", widgetEventsRequest);
|
||||||
|
|
||||||
|
widgetEventsRequest = createClickButtonEvent("Container@reuse_flowAuthentication@btn_Identification");
|
||||||
|
sendRequest("sequential", widgetEventsRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
WidgetEvents createClickImageEvent(string widgetId)
|
||||||
|
{
|
||||||
|
return new WidgetEvents("Container", [
|
||||||
|
"widgetId": widgetId,
|
||||||
|
"eventType": "clicked",
|
||||||
|
"widgetType": "Image",
|
||||||
|
], null);
|
||||||
|
}
|
||||||
|
|
||||||
|
WidgetEvents createClickButtonEvent(string widgetId)
|
||||||
|
{
|
||||||
|
return new WidgetEvents("Container", [
|
||||||
|
"widgetId": widgetId,
|
||||||
|
"eventType": "clicked",
|
||||||
|
"widgetType": "ActionButton",
|
||||||
|
], null);
|
||||||
|
}
|
||||||
|
|
||||||
|
WidgetEvents createChangeValueEvent(string widgetId, string value)
|
||||||
|
{
|
||||||
|
return new WidgetEvents("Container", [
|
||||||
|
"widgetId": widgetId,
|
||||||
|
"eventType": "valueChanged",
|
||||||
|
"widgetType": "Input",
|
||||||
|
], [
|
||||||
|
"text": value
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiResponse sendRequest(T : ApiRequest)(string executionMode, T request)
|
||||||
|
{
|
||||||
string requestString;
|
string requestString;
|
||||||
if(_sessionId !is null)
|
if(_sessionId !is null)
|
||||||
{
|
{
|
||||||
|
@ -141,6 +233,8 @@ class ApiClient
|
||||||
requestString = message.serializeToJsonString;
|
requestString = message.serializeToJsonString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
writeln("C> " ~ requestString);
|
||||||
|
|
||||||
auto response = requestHTTP(Endpoint,
|
auto response = requestHTTP(Endpoint,
|
||||||
(scope request) {
|
(scope request) {
|
||||||
request.method = HTTPMethod.POST;
|
request.method = HTTPMethod.POST;
|
||||||
|
@ -151,9 +245,9 @@ class ApiClient
|
||||||
}
|
}
|
||||||
).bodyReader.readAllUTF8;
|
).bodyReader.readAllUTF8;
|
||||||
|
|
||||||
auto json = response.parseJsonString;
|
writeln("S> " ~ response);
|
||||||
|
|
||||||
return json.deserializeJson!ApiResponse;
|
return response.parseJsonString.deserializeJson!ApiResponse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,4 +265,9 @@ shared static this()
|
||||||
|
|
||||||
auto apiClient = new ApiClient("nl_BE");
|
auto apiClient = new ApiClient("nl_BE");
|
||||||
apiClient.connect();
|
apiClient.connect();
|
||||||
|
apiClient.login1("67030514325746009", "0470", "854404");
|
||||||
|
write("OTP: ");
|
||||||
|
auto otp = readln()[0 .. $-1];
|
||||||
|
auto password = fromStringz(getpass("Password: ")).idup;
|
||||||
|
apiClient.login2(otp, password);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue