@etsoo/materialui 1.3.88 → 1.3.90
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/lib/app/CommonApp.d.ts +3 -4
- package/lib/app/CommonApp.js +6 -46
- package/lib/app/IServiceApp.d.ts +2 -19
- package/lib/app/IServiceAppSettings.d.ts +2 -2
- package/lib/app/IServiceUser.d.ts +0 -4
- package/lib/app/ReactApp.js +2 -2
- package/lib/app/ServiceApp.d.ts +18 -39
- package/lib/app/ServiceApp.js +51 -208
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/package.json +19 -19
- package/src/app/CommonApp.ts +8 -71
- package/src/app/IServiceApp.ts +2 -25
- package/src/app/IServiceAppSettings.ts +2 -2
- package/src/app/IServiceUser.ts +0 -5
- package/src/app/ReactApp.ts +1 -2
- package/src/app/ServiceApp.ts +70 -289
- package/src/index.ts +0 -1
- package/lib/app/IAppApi.d.ts +0 -29
- package/lib/app/IAppApi.js +0 -1
- package/src/app/IAppApi.ts +0 -37
package/lib/app/CommonApp.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAppSettings, IUser, RefreshTokenProps
|
|
1
|
+
import { IAppSettings, IUser, RefreshTokenProps } from "@etsoo/appscript";
|
|
2
2
|
import { IPageData } from "@etsoo/react";
|
|
3
3
|
import { ReactApp } from "./ReactApp";
|
|
4
4
|
/**
|
|
@@ -27,12 +27,11 @@ export declare abstract class CommonApp<U extends IUser = IUser, P extends IPage
|
|
|
27
27
|
* Refresh token
|
|
28
28
|
* @param props Props
|
|
29
29
|
*/
|
|
30
|
-
refreshToken
|
|
30
|
+
refreshToken(props?: RefreshTokenProps): Promise<boolean>;
|
|
31
31
|
/**
|
|
32
32
|
* Try login
|
|
33
|
-
* @param data Additional data
|
|
34
33
|
* @param showLoading Show loading bar or not
|
|
35
34
|
* @returns Result
|
|
36
35
|
*/
|
|
37
|
-
tryLogin
|
|
36
|
+
tryLogin(showLoading?: boolean): Promise<boolean>;
|
|
38
37
|
}
|
package/lib/app/CommonApp.js
CHANGED
|
@@ -37,7 +37,7 @@ export class CommonApp extends ReactApp {
|
|
|
37
37
|
*/
|
|
38
38
|
async refreshToken(props) {
|
|
39
39
|
// Destruct
|
|
40
|
-
const { callback,
|
|
40
|
+
const { callback, showLoading = false } = props ?? {};
|
|
41
41
|
// Token
|
|
42
42
|
const token = this.getCacheToken();
|
|
43
43
|
if (token == null || token === "") {
|
|
@@ -47,10 +47,7 @@ export class CommonApp extends ReactApp {
|
|
|
47
47
|
}
|
|
48
48
|
// Reqest data
|
|
49
49
|
const rq = {
|
|
50
|
-
deviceId: this.deviceId
|
|
51
|
-
region: this.region,
|
|
52
|
-
timezone: this.getTimeZone(),
|
|
53
|
-
...data
|
|
50
|
+
deviceId: this.deviceId
|
|
54
51
|
};
|
|
55
52
|
// Payload
|
|
56
53
|
const payload = {
|
|
@@ -89,41 +86,7 @@ export class CommonApp extends ReactApp {
|
|
|
89
86
|
if (!result.ok) {
|
|
90
87
|
// Remove the wrong token
|
|
91
88
|
this.clearCacheToken();
|
|
92
|
-
|
|
93
|
-
// Try login
|
|
94
|
-
// Dialog to receive password
|
|
95
|
-
var labels = this.getLabels("reloginTip", "login");
|
|
96
|
-
this.notifier.prompt(labels.reloginTip, async (pwd) => {
|
|
97
|
-
if (pwd == null) {
|
|
98
|
-
this.toLoginPage();
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
// Set password for the action
|
|
102
|
-
rq.pwd = this.encrypt(this.hash(pwd));
|
|
103
|
-
// Submit again
|
|
104
|
-
const result = await this.api.put("Auth/RefreshToken", rq, payload);
|
|
105
|
-
if (result == null)
|
|
106
|
-
return;
|
|
107
|
-
if (result.ok) {
|
|
108
|
-
success(result, (loginResult) => {
|
|
109
|
-
if (loginResult === true) {
|
|
110
|
-
if (callback)
|
|
111
|
-
callback(true);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const message = this.formatRefreshTokenResult(loginResult);
|
|
115
|
-
if (message)
|
|
116
|
-
this.notifier.alert(message);
|
|
117
|
-
});
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
// Popup message
|
|
121
|
-
this.alertResult(result);
|
|
122
|
-
return false;
|
|
123
|
-
}, labels.login, { type: "password" });
|
|
124
|
-
// Fake truth to avoid reloading
|
|
125
|
-
return true;
|
|
126
|
-
}
|
|
89
|
+
// Callback
|
|
127
90
|
if (callback)
|
|
128
91
|
callback(result);
|
|
129
92
|
return false;
|
|
@@ -132,21 +95,18 @@ export class CommonApp extends ReactApp {
|
|
|
132
95
|
}
|
|
133
96
|
/**
|
|
134
97
|
* Try login
|
|
135
|
-
* @param data Additional data
|
|
136
98
|
* @param showLoading Show loading bar or not
|
|
137
99
|
* @returns Result
|
|
138
100
|
*/
|
|
139
|
-
async tryLogin(
|
|
101
|
+
async tryLogin(showLoading) {
|
|
140
102
|
// Reset user state
|
|
141
|
-
const result = await super.tryLogin(
|
|
103
|
+
const result = await super.tryLogin(showLoading);
|
|
142
104
|
if (!result)
|
|
143
105
|
return false;
|
|
144
106
|
// Refresh token
|
|
145
107
|
return await this.refreshToken({
|
|
146
108
|
callback: (result) => this.doRefreshTokenResult(result),
|
|
147
|
-
|
|
148
|
-
showLoading,
|
|
149
|
-
relogin: true
|
|
109
|
+
showLoading
|
|
150
110
|
});
|
|
151
111
|
}
|
|
152
112
|
}
|
package/lib/app/IServiceApp.d.ts
CHANGED
|
@@ -1,29 +1,12 @@
|
|
|
1
|
-
import { IApi, RefreshTokenResult } from "@etsoo/appscript";
|
|
2
|
-
import { IServiceUser } from "./IServiceUser";
|
|
3
1
|
import { ReactAppType } from "./ReactApp";
|
|
4
|
-
import { IAppApi } from "./IAppApi";
|
|
5
2
|
/**
|
|
6
3
|
* Service application interface
|
|
7
4
|
*/
|
|
8
5
|
export interface IServiceApp extends ReactAppType {
|
|
9
6
|
/**
|
|
10
|
-
*
|
|
7
|
+
* Load core system UI
|
|
11
8
|
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Service user
|
|
15
|
-
*/
|
|
16
|
-
readonly serviceUser?: IServiceUser;
|
|
17
|
-
/**
|
|
18
|
-
* Service application API login
|
|
19
|
-
* @param appApi Service application API
|
|
20
|
-
* @param callback Callback
|
|
21
|
-
*/
|
|
22
|
-
apiLogin(appApi: IAppApi, callback?: (result: RefreshTokenResult, successData?: string) => void): Promise<boolean>;
|
|
23
|
-
/**
|
|
24
|
-
* Load SmartERP core
|
|
25
|
-
*/
|
|
26
|
-
loadSmartERP(): void;
|
|
9
|
+
loadCore(): void;
|
|
27
10
|
/**
|
|
28
11
|
* Service decrypt message
|
|
29
12
|
* @param messageEncrypted Encrypted message
|
package/lib/app/ReactApp.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BridgeUtils, CoreApp
|
|
1
|
+
import { BridgeUtils, CoreApp } from "@etsoo/appscript";
|
|
2
2
|
import { NotificationMessageType } from "@etsoo/notificationbase";
|
|
3
3
|
import { WindowStorage } from "@etsoo/shared";
|
|
4
4
|
import React from "react";
|
|
@@ -69,7 +69,7 @@ export class ReactApp extends CoreApp {
|
|
|
69
69
|
* @param debug Debug mode
|
|
70
70
|
*/
|
|
71
71
|
constructor(settings, name, debug = false) {
|
|
72
|
-
super(settings,
|
|
72
|
+
super(settings, null, ReactApp.createNotifier(debug), new WindowStorage(), name, debug);
|
|
73
73
|
/**
|
|
74
74
|
* User state
|
|
75
75
|
*/
|
package/lib/app/ServiceApp.d.ts
CHANGED
|
@@ -1,34 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExternalEndpoint, IApi, InitCallDto, InitCallResult } from "@etsoo/appscript";
|
|
2
2
|
import { IServiceApp } from "./IServiceApp";
|
|
3
3
|
import { IServiceAppSettings } from "./IServiceAppSettings";
|
|
4
4
|
import { IServicePageData } from "./IServicePage";
|
|
5
5
|
import { IServiceUser } from "./IServiceUser";
|
|
6
|
-
import { ISmartERPUser } from "./ISmartERPUser";
|
|
7
6
|
import { ReactApp } from "./ReactApp";
|
|
8
|
-
import { IAppApi } from "./IAppApi";
|
|
9
|
-
/**
|
|
10
|
-
* Service application refresh token properties
|
|
11
|
-
*/
|
|
12
|
-
export interface ServiceRefreshTokenProps extends RefreshTokenProps<Partial<RefreshTokenRQ>> {
|
|
13
|
-
appApi?: IAppApi;
|
|
14
|
-
}
|
|
15
7
|
/**
|
|
16
8
|
* Core Service App
|
|
17
9
|
* Service login to core system, get the refesh token and access token
|
|
18
10
|
* Use the acess token to the service api, get a service access token
|
|
19
11
|
* Use the new acess token and refresh token to login
|
|
20
12
|
*/
|
|
21
|
-
export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends IServicePageData = IServicePageData, S extends IServiceAppSettings = IServiceAppSettings> extends ReactApp<S,
|
|
13
|
+
export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends IServicePageData = IServicePageData, S extends IServiceAppSettings = IServiceAppSettings> extends ReactApp<S, U, P> implements IServiceApp {
|
|
22
14
|
/**
|
|
23
|
-
*
|
|
15
|
+
* Core endpoint
|
|
24
16
|
*/
|
|
25
|
-
|
|
26
|
-
private _serviceUser?;
|
|
17
|
+
protected coreEndpoint: ExternalEndpoint;
|
|
27
18
|
/**
|
|
28
|
-
*
|
|
19
|
+
* Core system API
|
|
29
20
|
*/
|
|
30
|
-
|
|
31
|
-
protected set serviceUser(value: U | undefined);
|
|
21
|
+
readonly coreApi: IApi;
|
|
32
22
|
/**
|
|
33
23
|
* Service passphrase
|
|
34
24
|
*/
|
|
@@ -41,15 +31,15 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
|
|
|
41
31
|
*/
|
|
42
32
|
constructor(settings: S, name: string, debug?: boolean);
|
|
43
33
|
/**
|
|
44
|
-
*
|
|
45
|
-
* @param appApi Service application API
|
|
46
|
-
* @param callback Callback
|
|
34
|
+
* Load core system UI
|
|
47
35
|
*/
|
|
48
|
-
|
|
36
|
+
loadCore(): void;
|
|
49
37
|
/**
|
|
50
|
-
*
|
|
38
|
+
* Api init call, for service application, call the core system API
|
|
39
|
+
* @param data Data
|
|
40
|
+
* @returns Result
|
|
51
41
|
*/
|
|
52
|
-
|
|
42
|
+
apiInitCall(data: InitCallDto): Promise<InitCallResult | undefined>;
|
|
53
43
|
/**
|
|
54
44
|
* Go to the login page
|
|
55
45
|
* @param tryLogin Try to login again
|
|
@@ -57,10 +47,13 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
|
|
|
57
47
|
*/
|
|
58
48
|
toLoginPage(tryLogin?: boolean, removeUrl?: boolean): void;
|
|
59
49
|
/**
|
|
60
|
-
*
|
|
61
|
-
* @param
|
|
50
|
+
* User login extended
|
|
51
|
+
* @param user New user
|
|
52
|
+
* @param refreshToken Refresh token
|
|
53
|
+
* @param keep Keep in local storage or not
|
|
54
|
+
* @param dispatch User state dispatch
|
|
62
55
|
*/
|
|
63
|
-
refreshToken
|
|
56
|
+
userLogin(user: U, refreshToken: string, keep?: boolean, dispatch?: boolean): void;
|
|
64
57
|
/**
|
|
65
58
|
* Service decrypt message
|
|
66
59
|
* @param messageEncrypted Encrypted message
|
|
@@ -76,18 +69,4 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
|
|
|
76
69
|
* @returns Result
|
|
77
70
|
*/
|
|
78
71
|
serviceEncrypt(message: string, passphrase?: string, iterations?: number): string;
|
|
79
|
-
/**
|
|
80
|
-
* Try login
|
|
81
|
-
* @param data Additional data
|
|
82
|
-
* @param showLoading Show loading bar or not
|
|
83
|
-
* @returns Result
|
|
84
|
-
*/
|
|
85
|
-
tryLogin<D extends object = {}>(data?: D, showLoading?: boolean): Promise<boolean>;
|
|
86
|
-
/**
|
|
87
|
-
* User login extended
|
|
88
|
-
* @param user Core system user
|
|
89
|
-
* @param refreshToken Refresh token
|
|
90
|
-
* @param serviceUser Service user
|
|
91
|
-
*/
|
|
92
|
-
userLoginEx(user: ISmartERPUser, refreshToken: string, serviceUser: U): void;
|
|
93
72
|
}
|
package/lib/app/ServiceApp.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { BridgeUtils
|
|
2
|
-
import { CoreConstants } from "@etsoo/react";
|
|
3
|
-
import { DomUtils } from "@etsoo/shared";
|
|
1
|
+
import { BridgeUtils } from "@etsoo/appscript";
|
|
4
2
|
import { ReactApp } from "./ReactApp";
|
|
3
|
+
const coreName = "core";
|
|
5
4
|
/**
|
|
6
5
|
* Core Service App
|
|
7
6
|
* Service login to core system, get the refesh token and access token
|
|
@@ -9,15 +8,6 @@ import { ReactApp } from "./ReactApp";
|
|
|
9
8
|
* Use the new acess token and refresh token to login
|
|
10
9
|
*/
|
|
11
10
|
export class ServiceApp extends ReactApp {
|
|
12
|
-
/**
|
|
13
|
-
* Service user
|
|
14
|
-
*/
|
|
15
|
-
get serviceUser() {
|
|
16
|
-
return this._serviceUser;
|
|
17
|
-
}
|
|
18
|
-
set serviceUser(value) {
|
|
19
|
-
this._serviceUser = value;
|
|
20
|
-
}
|
|
21
11
|
/**
|
|
22
12
|
* Constructor
|
|
23
13
|
* @param settings Settings
|
|
@@ -31,186 +21,76 @@ export class ServiceApp extends ReactApp {
|
|
|
31
21
|
*/
|
|
32
22
|
this.servicePassphrase = "";
|
|
33
23
|
// Check
|
|
34
|
-
if (settings.
|
|
35
|
-
throw new Error("
|
|
24
|
+
if (settings.appId == null) {
|
|
25
|
+
throw new Error("Service Application ID is required.");
|
|
36
26
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this.
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Service application API login
|
|
46
|
-
* @param appApi Service application API
|
|
47
|
-
* @param callback Callback
|
|
48
|
-
*/
|
|
49
|
-
apiLogin(appApi, callback) {
|
|
50
|
-
return this.refreshToken({
|
|
51
|
-
callback,
|
|
52
|
-
data: appApi.getRefreshTokenData(),
|
|
53
|
-
relogin: false,
|
|
54
|
-
showLoading: false,
|
|
55
|
-
appApi
|
|
56
|
-
});
|
|
27
|
+
const coreEndpoint = settings.endpoints?.core;
|
|
28
|
+
if (coreEndpoint == null) {
|
|
29
|
+
throw new Error("Core API endpont is required.");
|
|
30
|
+
}
|
|
31
|
+
this.coreEndpoint = coreEndpoint;
|
|
32
|
+
this.coreApi = this.createApi(coreName, coreEndpoint);
|
|
57
33
|
}
|
|
58
34
|
/**
|
|
59
|
-
* Load
|
|
35
|
+
* Load core system UI
|
|
60
36
|
*/
|
|
61
|
-
|
|
37
|
+
loadCore() {
|
|
62
38
|
if (BridgeUtils.host == null) {
|
|
63
|
-
|
|
39
|
+
globalThis.location.href = this.coreEndpoint.webUrl;
|
|
64
40
|
}
|
|
65
41
|
else {
|
|
66
|
-
BridgeUtils.host.loadApp(
|
|
42
|
+
BridgeUtils.host.loadApp(coreName);
|
|
67
43
|
}
|
|
68
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Api init call, for service application, call the core system API
|
|
47
|
+
* @param data Data
|
|
48
|
+
* @returns Result
|
|
49
|
+
*/
|
|
50
|
+
async apiInitCall(data) {
|
|
51
|
+
return await this.coreApi.put(this.initCallApi, data);
|
|
52
|
+
}
|
|
69
53
|
/**
|
|
70
54
|
* Go to the login page
|
|
71
55
|
* @param tryLogin Try to login again
|
|
72
56
|
* @param removeUrl Remove current URL for reuse
|
|
73
57
|
*/
|
|
74
58
|
toLoginPage(tryLogin, removeUrl) {
|
|
75
|
-
|
|
59
|
+
// Cache current URL
|
|
60
|
+
this.cachedUrl = removeUrl ? undefined : globalThis.location.href;
|
|
76
61
|
// Make sure apply new device id for new login
|
|
77
62
|
this.clearDeviceId();
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
BridgeUtils.host.loadApp("core", parameters);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Refresh token
|
|
88
|
-
* @param props Props
|
|
89
|
-
*/
|
|
90
|
-
async refreshToken(props) {
|
|
91
|
-
// Destruct
|
|
92
|
-
const { appApi, callback, data, relogin = false, showLoading = false } = props ?? {};
|
|
93
|
-
// Token
|
|
94
|
-
const token = this.getCacheToken();
|
|
95
|
-
if (token == null || token === "") {
|
|
96
|
-
if (callback)
|
|
97
|
-
callback(false);
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
// Reqest data
|
|
101
|
-
// Merge additional data passed
|
|
102
|
-
const rq = {
|
|
103
|
-
deviceId: this.deviceId,
|
|
63
|
+
// Get the redirect URL
|
|
64
|
+
this.api
|
|
65
|
+
.get("Auth/GetLogInUrl", {
|
|
104
66
|
region: this.region,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (callback)
|
|
114
|
-
callback(error);
|
|
115
|
-
// Prevent further processing
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
// Success callback
|
|
120
|
-
const success = async (result, failCallback) => {
|
|
121
|
-
// Token
|
|
122
|
-
const refreshToken = this.getResponseToken(payload.response);
|
|
123
|
-
if (refreshToken == null || result.data == null) {
|
|
124
|
-
if (failCallback)
|
|
125
|
-
failCallback(this.get("noData"));
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
// User data
|
|
129
|
-
const userData = result.data;
|
|
130
|
-
// Use core system access token to service api to exchange service access token
|
|
131
|
-
const api = appApi ? appApi.api : this.serviceApi;
|
|
132
|
-
const serviceResult = await api.put("Auth/ExchangeToken", {
|
|
133
|
-
token: this.encryptEnhanced(userData.token, (appApi?.serviceId ?? this.settings.serviceId).toString())
|
|
134
|
-
}, {
|
|
135
|
-
showLoading,
|
|
136
|
-
onError: (error) => {
|
|
137
|
-
if (failCallback)
|
|
138
|
-
failCallback(error);
|
|
139
|
-
// Prevent further processing
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
if (serviceResult == null)
|
|
144
|
-
return false;
|
|
145
|
-
if (!serviceResult.ok) {
|
|
146
|
-
if (failCallback)
|
|
147
|
-
failCallback(serviceResult);
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
if (serviceResult.data == null) {
|
|
151
|
-
if (failCallback)
|
|
152
|
-
failCallback(this.get("noData"));
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
// Login
|
|
156
|
-
if (appApi) {
|
|
157
|
-
// Authorize external service application API
|
|
158
|
-
appApi.authorize(userData, refreshToken, serviceResult.data);
|
|
67
|
+
device: this.deviceId
|
|
68
|
+
})
|
|
69
|
+
.then((url) => {
|
|
70
|
+
if (!url)
|
|
71
|
+
return;
|
|
72
|
+
url += `?tryLogin=${tryLogin ?? false}`;
|
|
73
|
+
if (BridgeUtils.host == null) {
|
|
74
|
+
globalThis.location.href = url;
|
|
159
75
|
}
|
|
160
76
|
else {
|
|
161
|
-
|
|
162
|
-
this.userLoginEx(userData, refreshToken, serviceResult.data);
|
|
163
|
-
}
|
|
164
|
-
// Success callback
|
|
165
|
-
if (failCallback)
|
|
166
|
-
failCallback(true);
|
|
167
|
-
return true;
|
|
168
|
-
};
|
|
169
|
-
// Call API
|
|
170
|
-
const result = await this.api.put("Auth/RefreshToken", rq, payload);
|
|
171
|
-
if (result == null)
|
|
172
|
-
return false;
|
|
173
|
-
if (!result.ok) {
|
|
174
|
-
if (result.type === "TokenExpired" && relogin) {
|
|
175
|
-
// Try login
|
|
176
|
-
// Dialog to receive password
|
|
177
|
-
var labels = this.getLabels("reloginTip", "login");
|
|
178
|
-
this.notifier.prompt(labels.reloginTip, async (pwd) => {
|
|
179
|
-
if (pwd == null) {
|
|
180
|
-
this.toLoginPage();
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
// Set password for the action
|
|
184
|
-
rq.pwd = this.encrypt(this.hash(pwd));
|
|
185
|
-
// Submit again
|
|
186
|
-
const result = await this.api.put("Auth/RefreshToken", rq, payload);
|
|
187
|
-
if (result == null)
|
|
188
|
-
return;
|
|
189
|
-
if (result.ok) {
|
|
190
|
-
await success(result, (loginResult) => {
|
|
191
|
-
if (loginResult === true) {
|
|
192
|
-
if (callback)
|
|
193
|
-
callback(true);
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
const message = this.formatRefreshTokenResult(loginResult);
|
|
197
|
-
if (message)
|
|
198
|
-
this.notifier.alert(message);
|
|
199
|
-
});
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
// Popup message
|
|
203
|
-
this.alertResult(result);
|
|
204
|
-
return false;
|
|
205
|
-
}, labels.login, { type: "password" });
|
|
206
|
-
// Fake truth to avoid reloading
|
|
207
|
-
return true;
|
|
77
|
+
BridgeUtils.host.loadApp(coreName, url);
|
|
208
78
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* User login extended
|
|
83
|
+
* @param user New user
|
|
84
|
+
* @param refreshToken Refresh token
|
|
85
|
+
* @param keep Keep in local storage or not
|
|
86
|
+
* @param dispatch User state dispatch
|
|
87
|
+
*/
|
|
88
|
+
userLogin(user, refreshToken, keep, dispatch) {
|
|
89
|
+
// Super call, set token
|
|
90
|
+
super.userLogin(user, refreshToken, keep, dispatch);
|
|
91
|
+
// Set service passphrase
|
|
92
|
+
this.servicePassphrase =
|
|
93
|
+
this.decrypt(user.servicePassphrase, `${user.uid}-${this.settings.appId}`) ?? "";
|
|
214
94
|
}
|
|
215
95
|
/**
|
|
216
96
|
* Service decrypt message
|
|
@@ -231,41 +111,4 @@ export class ServiceApp extends ReactApp {
|
|
|
231
111
|
serviceEncrypt(message, passphrase, iterations) {
|
|
232
112
|
return this.encrypt(message, passphrase ?? this.servicePassphrase, iterations);
|
|
233
113
|
}
|
|
234
|
-
/**
|
|
235
|
-
* Try login
|
|
236
|
-
* @param data Additional data
|
|
237
|
-
* @param showLoading Show loading bar or not
|
|
238
|
-
* @returns Result
|
|
239
|
-
*/
|
|
240
|
-
async tryLogin(data, showLoading) {
|
|
241
|
-
// Reset user state
|
|
242
|
-
const result = await super.tryLogin(data, showLoading);
|
|
243
|
-
if (!result)
|
|
244
|
-
return false;
|
|
245
|
-
// Refresh token
|
|
246
|
-
return await this.refreshToken({
|
|
247
|
-
callback: (result) => this.doRefreshTokenResult(result),
|
|
248
|
-
data,
|
|
249
|
-
showLoading,
|
|
250
|
-
relogin: true
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* User login extended
|
|
255
|
-
* @param user Core system user
|
|
256
|
-
* @param refreshToken Refresh token
|
|
257
|
-
* @param serviceUser Service user
|
|
258
|
-
*/
|
|
259
|
-
userLoginEx(user, refreshToken, serviceUser) {
|
|
260
|
-
// Service user login
|
|
261
|
-
this.servicePassphrase =
|
|
262
|
-
this.decrypt(serviceUser.servicePassphrase, this.settings.serviceId.toString()) ?? "";
|
|
263
|
-
// Service user
|
|
264
|
-
this.serviceUser = serviceUser;
|
|
265
|
-
// Service API token
|
|
266
|
-
this.serviceApi.authorize(serviceUser.tokenScheme ?? "Bearer", serviceUser.token);
|
|
267
|
-
// Keep = true, means service could hold the refresh token for long access
|
|
268
|
-
// Trigger Context change and serviceUser is ready then
|
|
269
|
-
super.userLogin(user, refreshToken, true);
|
|
270
|
-
}
|
|
271
114
|
}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.90",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -47,16 +47,16 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@dnd-kit/core": "^6.1.0",
|
|
49
49
|
"@dnd-kit/sortable": "^8.0.0",
|
|
50
|
-
"@emotion/css": "^11.13.
|
|
50
|
+
"@emotion/css": "^11.13.4",
|
|
51
51
|
"@emotion/react": "^11.13.3",
|
|
52
52
|
"@emotion/styled": "^11.13.0",
|
|
53
|
-
"@etsoo/appscript": "^1.5.
|
|
54
|
-
"@etsoo/notificationbase": "^1.1.
|
|
55
|
-
"@etsoo/react": "^1.7.
|
|
56
|
-
"@etsoo/shared": "^1.2.
|
|
57
|
-
"@mui/icons-material": "^6.1.
|
|
58
|
-
"@mui/material": "^6.1.
|
|
59
|
-
"@mui/x-data-grid": "^7.
|
|
53
|
+
"@etsoo/appscript": "^1.5.22",
|
|
54
|
+
"@etsoo/notificationbase": "^1.1.48",
|
|
55
|
+
"@etsoo/react": "^1.7.68",
|
|
56
|
+
"@etsoo/shared": "^1.2.46",
|
|
57
|
+
"@mui/icons-material": "^6.1.2",
|
|
58
|
+
"@mui/material": "^6.1.2",
|
|
59
|
+
"@mui/x-data-grid": "^7.19.0",
|
|
60
60
|
"chart.js": "^4.4.4",
|
|
61
61
|
"chartjs-plugin-datalabels": "^2.2.0",
|
|
62
62
|
"eventemitter3": "^5.0.1",
|
|
@@ -70,25 +70,25 @@
|
|
|
70
70
|
"react-imask": "7.6.1"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@babel/cli": "^7.25.
|
|
74
|
-
"@babel/core": "^7.25.
|
|
75
|
-
"@babel/plugin-transform-runtime": "^7.25.
|
|
76
|
-
"@babel/preset-env": "^7.25.
|
|
77
|
-
"@babel/preset-react": "^7.
|
|
78
|
-
"@babel/preset-typescript": "^7.
|
|
79
|
-
"@babel/runtime-corejs3": "^7.25.
|
|
73
|
+
"@babel/cli": "^7.25.7",
|
|
74
|
+
"@babel/core": "^7.25.7",
|
|
75
|
+
"@babel/plugin-transform-runtime": "^7.25.7",
|
|
76
|
+
"@babel/preset-env": "^7.25.7",
|
|
77
|
+
"@babel/preset-react": "^7.25.7",
|
|
78
|
+
"@babel/preset-typescript": "^7.25.7",
|
|
79
|
+
"@babel/runtime-corejs3": "^7.25.7",
|
|
80
80
|
"@testing-library/jest-dom": "^6.5.0",
|
|
81
81
|
"@testing-library/react": "^16.0.1",
|
|
82
82
|
"@types/jest": "^29.5.13",
|
|
83
83
|
"@types/pica": "^9.0.4",
|
|
84
84
|
"@types/pulltorefreshjs": "^0.1.7",
|
|
85
|
-
"@types/react": "^18.3.
|
|
85
|
+
"@types/react": "^18.3.11",
|
|
86
86
|
"@types/react-avatar-editor": "^13.0.3",
|
|
87
87
|
"@types/react-dom": "^18.3.0",
|
|
88
88
|
"@types/react-input-mask": "^3.0.5",
|
|
89
89
|
"@types/react-window": "^1.8.8",
|
|
90
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
91
|
-
"@typescript-eslint/parser": "^8.
|
|
90
|
+
"@typescript-eslint/eslint-plugin": "^8.8.0",
|
|
91
|
+
"@typescript-eslint/parser": "^8.8.0",
|
|
92
92
|
"jest": "^29.7.0",
|
|
93
93
|
"jest-environment-jsdom": "^29.7.0",
|
|
94
94
|
"typescript": "^5.6.2"
|