@colijnit/ioneconnector 1.0.141 → 1.0.142
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/connector.js +1 -1
- package/build/model/session.d.ts +1 -0
- package/build/model/session.js +1 -0
- package/build/provider/ajax.service.d.ts +0 -1
- package/build/provider/ajax.service.js +9 -15
- package/build/provider/base-backend-connection.service.d.ts +3 -2
- package/build/provider/base-backend-connection.service.js +2 -1
- package/build/service/datasession.service.d.ts +3 -3
- package/build/service/datasession.service.js +6 -9
- package/build/service/login.service.d.ts +5 -0
- package/build/service/login.service.js +51 -10
- package/build/service/public.service.d.ts +3 -3
- package/build/service/public.service.js +5 -8
- package/package.json +1 -1
package/build/connector.js
CHANGED
|
@@ -617,7 +617,7 @@ class Connector {
|
|
|
617
617
|
return frozenart;
|
|
618
618
|
}
|
|
619
619
|
static createConnector(options, externalStorage) {
|
|
620
|
-
if (options.username && options.password) {
|
|
620
|
+
if ((options.username && options.password) || options.session) {
|
|
621
621
|
return new connector_auth_1.ConnectorAuth(options, externalStorage);
|
|
622
622
|
}
|
|
623
623
|
else {
|
package/build/model/session.d.ts
CHANGED
package/build/model/session.js
CHANGED
|
@@ -6,7 +6,6 @@ import { BaseBackendConnectionService } from "./base-backend-connection.service"
|
|
|
6
6
|
import { Session } from "../model/session";
|
|
7
7
|
export declare class AjaxService extends BaseBackendConnectionService {
|
|
8
8
|
private _showLoaderRequests;
|
|
9
|
-
private _timeout;
|
|
10
9
|
constructor(url: string, options: Options, session?: Session, externalStorage?: ExternalStorage, secure?: boolean);
|
|
11
10
|
call(method: string, data?: DataServiceData, showLoader?: boolean, service?: BackendServiceName): Promise<any>;
|
|
12
11
|
protected waitForLogin(): Promise<boolean>;
|
|
@@ -11,30 +11,24 @@ class AjaxService extends base_backend_connection_service_1.BaseBackendConnectio
|
|
|
11
11
|
constructor(url, options, session = undefined, externalStorage = undefined, secure = false) {
|
|
12
12
|
super(url, options, session, externalStorage, secure);
|
|
13
13
|
this._showLoaderRequests = 0;
|
|
14
|
-
this._timeout = 180000;
|
|
15
14
|
if (options && options.timeoutInMs) {
|
|
16
|
-
this.
|
|
15
|
+
this.timeout = options.timeoutInMs;
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
async call(method, data = {}, showLoader = true, service = backend_service_name_enum_1.BackendServiceName.LoginService) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
service === backend_service_name_enum_1.BackendServiceName.DatasessionService) {
|
|
23
|
-
return this._doCall(method, data, showLoader, service);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
await this.waitForLogin();
|
|
27
|
-
return this._doCall(method, data, showLoader, service);
|
|
28
|
-
}
|
|
19
|
+
await this.waitForLogin();
|
|
20
|
+
return this._doCall(method, data, showLoader, service);
|
|
29
21
|
}
|
|
30
22
|
async waitForLogin() {
|
|
31
23
|
if (this.session && this.session.created) {
|
|
32
24
|
return true;
|
|
33
25
|
}
|
|
34
|
-
if (
|
|
35
|
-
await this.loginService.
|
|
26
|
+
if (this.session.loggingIn) {
|
|
27
|
+
return await this.loginService.waitForLoginToFinish();
|
|
36
28
|
}
|
|
37
|
-
|
|
29
|
+
this.session.loggingIn = true;
|
|
30
|
+
await this.loginService.loginAndCreateDataSession();
|
|
31
|
+
this.session.loggingIn = false;
|
|
38
32
|
}
|
|
39
33
|
_doCall(method, data = {}, showLoader = true, service = backend_service_name_enum_1.BackendServiceName.LoginService) {
|
|
40
34
|
if (showLoader) {
|
|
@@ -55,7 +49,7 @@ class AjaxService extends base_backend_connection_service_1.BaseBackendConnectio
|
|
|
55
49
|
method: 'post',
|
|
56
50
|
url: url,
|
|
57
51
|
data: message,
|
|
58
|
-
timeout: this.
|
|
52
|
+
timeout: this.timeout
|
|
59
53
|
}).then(response => {
|
|
60
54
|
resolve(response.data);
|
|
61
55
|
}).catch(error => {
|
|
@@ -8,11 +8,12 @@ import { ConnectionEndpoint } from "./connection-endpoint";
|
|
|
8
8
|
export declare abstract class BaseBackendConnectionService implements ConnectionEndpoint {
|
|
9
9
|
readonly showLoader: Subject<boolean>;
|
|
10
10
|
readonly connectionResetInactivity: Subject<void>;
|
|
11
|
+
timeout: number;
|
|
11
12
|
session: Session;
|
|
12
13
|
options: Options;
|
|
13
14
|
externalStorage: ExternalStorage;
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
callId: string;
|
|
16
|
+
url: string;
|
|
16
17
|
protected secure: boolean;
|
|
17
18
|
protected loginService: LoginService;
|
|
18
19
|
private _datasessionService;
|
|
@@ -10,6 +10,7 @@ class BaseBackendConnectionService {
|
|
|
10
10
|
constructor(url, options, session = undefined, externalStorage = undefined, secure = false) {
|
|
11
11
|
this.showLoader = new rxjs_1.Subject();
|
|
12
12
|
this.connectionResetInactivity = new rxjs_1.Subject();
|
|
13
|
+
this.timeout = 180000;
|
|
13
14
|
this.callId = "1";
|
|
14
15
|
this.url = this.addEndpointToUrl(url);
|
|
15
16
|
this.options = options;
|
|
@@ -23,7 +24,7 @@ class BaseBackendConnectionService {
|
|
|
23
24
|
this.session = this._createNewSession();
|
|
24
25
|
}
|
|
25
26
|
this.loginService = new login_service_1.LoginService(this);
|
|
26
|
-
this._datasessionService = new datasession_service_1.DatasessionService(this);
|
|
27
|
+
this._datasessionService = new datasession_service_1.DatasessionService(this.loginService);
|
|
27
28
|
}
|
|
28
29
|
async commit() {
|
|
29
30
|
return this._datasessionService.commit();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LoginService } from './login.service';
|
|
2
2
|
export declare class DatasessionService {
|
|
3
|
-
protected
|
|
4
|
-
constructor(
|
|
3
|
+
protected loginService: LoginService;
|
|
4
|
+
constructor(loginService: LoginService);
|
|
5
5
|
createDataSession(id: string): Promise<any>;
|
|
6
6
|
commit(): Promise<boolean>;
|
|
7
7
|
private _call;
|
|
@@ -3,23 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const backend_service_name_enum_1 = require("../enum/backend-service-name.enum");
|
|
4
4
|
const datasession_service_method_enum_1 = require("../enum/datasession-service-method.enum");
|
|
5
5
|
class DatasessionService {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
6
|
+
constructor(loginService) {
|
|
7
|
+
this.loginService = loginService;
|
|
8
8
|
}
|
|
9
9
|
createDataSession(id) {
|
|
10
|
-
return this._call(datasession_service_method_enum_1.DatasessionServiceMethod.OpenDataSession, { moduleName: id }
|
|
10
|
+
return this._call(datasession_service_method_enum_1.DatasessionServiceMethod.OpenDataSession, { moduleName: id });
|
|
11
11
|
}
|
|
12
12
|
async commit() {
|
|
13
|
-
return await this._call(datasession_service_method_enum_1.DatasessionServiceMethod.Commit, {}
|
|
13
|
+
return await this._call(datasession_service_method_enum_1.DatasessionServiceMethod.Commit, {});
|
|
14
14
|
}
|
|
15
|
-
_call(method, data
|
|
15
|
+
_call(method, data) {
|
|
16
16
|
if (data === undefined) {
|
|
17
17
|
data = {};
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
showLoader = true;
|
|
21
|
-
}
|
|
22
|
-
return this.backendConnection.call(method, data, showLoader, backend_service_name_enum_1.BackendServiceName.DatasessionService);
|
|
19
|
+
return this.loginService.call(method, data, backend_service_name_enum_1.BackendServiceName.DatasessionService);
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
22
|
exports.DatasessionService = DatasessionService;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { BackendServiceName } from "../enum/backend-service-name.enum";
|
|
1
2
|
import { Login } from "../model/login";
|
|
2
3
|
import { BaseBackendConnectionService } from "../provider/base-backend-connection.service";
|
|
4
|
+
import { DataServiceData } from '../model/data-service-data';
|
|
3
5
|
export declare class LoginService {
|
|
4
6
|
private static HEARTBEAT_INTERVAL_MS;
|
|
5
7
|
initialized: boolean;
|
|
@@ -13,9 +15,12 @@ export declare class LoginService {
|
|
|
13
15
|
private _useEncryption;
|
|
14
16
|
private _publicService;
|
|
15
17
|
private _datasessionService;
|
|
18
|
+
private _dataSessionCreated;
|
|
16
19
|
constructor(backendConnection: BaseBackendConnectionService);
|
|
17
20
|
loginAndCreateDataSession(): Promise<any>;
|
|
21
|
+
waitForLoginToFinish(): Promise<boolean>;
|
|
18
22
|
logout(): Promise<any>;
|
|
23
|
+
call(method: string, data?: DataServiceData, service?: BackendServiceName): Promise<any>;
|
|
19
24
|
private _login;
|
|
20
25
|
private _startHeartBeat;
|
|
21
26
|
private _stopHeartBeat;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const login_service_method_enum_1 = require("../enum/login-service-method.enum");
|
|
4
7
|
const backend_service_name_enum_1 = require("../enum/backend-service-name.enum");
|
|
@@ -6,6 +9,9 @@ const login_1 = require("../model/login");
|
|
|
6
9
|
const encrypt_service_1 = require("./encrypt.service");
|
|
7
10
|
const public_service_1 = require("./public.service");
|
|
8
11
|
const datasession_service_1 = require("./datasession.service");
|
|
12
|
+
const rxjs_1 = require("rxjs");
|
|
13
|
+
const url_utils_1 = require("../utils/url-utils");
|
|
14
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
15
|
class LoginService {
|
|
10
16
|
constructor(backendConnection) {
|
|
11
17
|
this.initialized = false;
|
|
@@ -13,6 +19,7 @@ class LoginService {
|
|
|
13
19
|
this.loggingOut = false;
|
|
14
20
|
this.windowsSessionId = 1;
|
|
15
21
|
this._useEncryption = false;
|
|
22
|
+
this._dataSessionCreated = new rxjs_1.Subject();
|
|
16
23
|
this.backendConnection = backendConnection;
|
|
17
24
|
this.loginModel = new login_1.Login();
|
|
18
25
|
if (this.backendConnection.options.schema === "") {
|
|
@@ -30,8 +37,8 @@ class LoginService {
|
|
|
30
37
|
this.loginModel.clientLanguage = this.backendConnection.options.languageCode;
|
|
31
38
|
this._useEncryption = this.backendConnection.options.useLoginEncryption;
|
|
32
39
|
this._encryptionService = new encrypt_service_1.EncryptService();
|
|
33
|
-
this._publicService = new public_service_1.PublicService(this
|
|
34
|
-
this._datasessionService = new datasession_service_1.DatasessionService(this
|
|
40
|
+
this._publicService = new public_service_1.PublicService(this, this._encryptionService);
|
|
41
|
+
this._datasessionService = new datasession_service_1.DatasessionService(this);
|
|
35
42
|
}
|
|
36
43
|
loginAndCreateDataSession() {
|
|
37
44
|
this.loggingIn = true;
|
|
@@ -43,6 +50,7 @@ class LoginService {
|
|
|
43
50
|
if (response.data === true) {
|
|
44
51
|
this.backendConnection.session.created = true;
|
|
45
52
|
this.loggingIn = false;
|
|
53
|
+
this._dataSessionCreated.next();
|
|
46
54
|
this._startHeartBeat();
|
|
47
55
|
resolve();
|
|
48
56
|
}
|
|
@@ -61,13 +69,49 @@ class LoginService {
|
|
|
61
69
|
});
|
|
62
70
|
});
|
|
63
71
|
}
|
|
72
|
+
async waitForLoginToFinish() {
|
|
73
|
+
return new Promise((resolve) => {
|
|
74
|
+
this._dataSessionCreated.subscribe(() => {
|
|
75
|
+
resolve(true);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
64
79
|
logout() {
|
|
65
80
|
this.loggingOut = true;
|
|
66
|
-
return this._call(login_service_method_enum_1.LoginServiceMethod.LogoutUser, {}
|
|
81
|
+
return this._call(login_service_method_enum_1.LoginServiceMethod.LogoutUser, {}).then((userData) => {
|
|
67
82
|
this.loggingOut = false;
|
|
68
83
|
this._stopHeartBeat();
|
|
69
84
|
});
|
|
70
85
|
}
|
|
86
|
+
call(method, data = {}, service = backend_service_name_enum_1.BackendServiceName.LoginService) {
|
|
87
|
+
return new Promise((resolve, reject) => {
|
|
88
|
+
const url = url_utils_1.UrlUtils.createReadableUrl(method, data, this.backendConnection.url);
|
|
89
|
+
const message = JSON.stringify({
|
|
90
|
+
service: service,
|
|
91
|
+
method: method,
|
|
92
|
+
id: this.backendConnection.callId,
|
|
93
|
+
data: data,
|
|
94
|
+
dataSessionId: this.backendConnection.session ? this.backendConnection.session.dataSessionId : "",
|
|
95
|
+
windowSessionId: this.backendConnection.session ? this.backendConnection.session.windowsId : "1",
|
|
96
|
+
sessionId: this.backendConnection.session ? this.backendConnection.session.id : ""
|
|
97
|
+
});
|
|
98
|
+
axios_1.default({
|
|
99
|
+
method: 'post',
|
|
100
|
+
url: url,
|
|
101
|
+
data: message,
|
|
102
|
+
timeout: this.backendConnection.timeout
|
|
103
|
+
}).then(response => {
|
|
104
|
+
resolve(response.data);
|
|
105
|
+
}).catch(error => {
|
|
106
|
+
if (error.code === "ECONNABORTED") {
|
|
107
|
+
reject("ECONNABORTED");
|
|
108
|
+
}
|
|
109
|
+
reject(error);
|
|
110
|
+
});
|
|
111
|
+
}).then(response => {
|
|
112
|
+
return new Promise((resolve) => { return resolve(response); });
|
|
113
|
+
});
|
|
114
|
+
}
|
|
71
115
|
_login() {
|
|
72
116
|
return new Promise((resolve, reject) => {
|
|
73
117
|
this._callLogin()
|
|
@@ -92,7 +136,7 @@ class LoginService {
|
|
|
92
136
|
_startHeartBeat() {
|
|
93
137
|
if (!this.heartbeatTimer) {
|
|
94
138
|
this.heartbeatTimer = setInterval(() => {
|
|
95
|
-
this._call(login_service_method_enum_1.LoginServiceMethod.GetHeartBeat, {}
|
|
139
|
+
this._call(login_service_method_enum_1.LoginServiceMethod.GetHeartBeat, {});
|
|
96
140
|
}, LoginService.HEARTBEAT_INTERVAL_MS);
|
|
97
141
|
}
|
|
98
142
|
}
|
|
@@ -118,17 +162,14 @@ class LoginService {
|
|
|
118
162
|
}
|
|
119
163
|
_callLogin() {
|
|
120
164
|
return this._checkEncryption().then(() => {
|
|
121
|
-
return this._call(login_service_method_enum_1.LoginServiceMethod.Login, this.loginModel.getSerialized()
|
|
165
|
+
return this._call(login_service_method_enum_1.LoginServiceMethod.Login, this.loginModel.getSerialized());
|
|
122
166
|
});
|
|
123
167
|
}
|
|
124
|
-
_call(method, data
|
|
168
|
+
_call(method, data) {
|
|
125
169
|
if (data === undefined) {
|
|
126
170
|
data = {};
|
|
127
171
|
}
|
|
128
|
-
|
|
129
|
-
showLoader = true;
|
|
130
|
-
}
|
|
131
|
-
return this.backendConnection.call(method, data, showLoader, backend_service_name_enum_1.BackendServiceName.LoginService);
|
|
172
|
+
return this.call(method, data, backend_service_name_enum_1.BackendServiceName.LoginService);
|
|
132
173
|
}
|
|
133
174
|
}
|
|
134
175
|
exports.LoginService = LoginService;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BaseBackendConnectionService } from '../provider/base-backend-connection.service';
|
|
2
1
|
import { EncryptService } from './encrypt.service';
|
|
2
|
+
import { LoginService } from './login.service';
|
|
3
3
|
export declare class PublicService {
|
|
4
|
-
protected
|
|
4
|
+
protected loginService: LoginService;
|
|
5
5
|
private _encryptionService;
|
|
6
|
-
constructor(
|
|
6
|
+
constructor(loginService: LoginService, encryptionService: EncryptService);
|
|
7
7
|
getPublicKey(): Promise<void>;
|
|
8
8
|
private _call;
|
|
9
9
|
}
|
|
@@ -3,26 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const backend_service_name_enum_1 = require("../enum/backend-service-name.enum");
|
|
4
4
|
const public_service_method_enum_1 = require("../enum/public-service-method.enum");
|
|
5
5
|
class PublicService {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
6
|
+
constructor(loginService, encryptionService) {
|
|
7
|
+
this.loginService = loginService;
|
|
8
8
|
this._encryptionService = encryptionService;
|
|
9
9
|
}
|
|
10
10
|
getPublicKey() {
|
|
11
11
|
return new Promise((resolve) => {
|
|
12
|
-
this._call(public_service_method_enum_1.PublicServiceMethod.GetPublicKey, {}
|
|
12
|
+
this._call(public_service_method_enum_1.PublicServiceMethod.GetPublicKey, {}).then((result) => {
|
|
13
13
|
this._encryptionService.publicKey = result.data;
|
|
14
14
|
resolve();
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
-
_call(method, data
|
|
18
|
+
_call(method, data) {
|
|
19
19
|
if (data === undefined) {
|
|
20
20
|
data = {};
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
showLoader = true;
|
|
24
|
-
}
|
|
25
|
-
return this.backendConnection.call(method, data, showLoader, backend_service_name_enum_1.BackendServiceName.PublicService);
|
|
22
|
+
return this.loginService.call(method, data, backend_service_name_enum_1.BackendServiceName.PublicService);
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
25
|
exports.PublicService = PublicService;
|