@etsoo/react 1.3.67 → 1.3.68
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/IServiceUser.d.ts +4 -0
- package/lib/app/ServiceApp.d.ts +19 -0
- package/lib/app/ServiceApp.js +26 -2
- package/package.json +1 -1
- package/src/app/IServiceUser.ts +6 -1
- package/src/app/ServiceApp.ts +44 -6
package/lib/app/ServiceApp.d.ts
CHANGED
|
@@ -20,6 +20,10 @@ export declare class ServiceApp<P extends IServicePageData = IServicePageData, U
|
|
|
20
20
|
* Core system user
|
|
21
21
|
*/
|
|
22
22
|
coreUser?: ISmartERPUser;
|
|
23
|
+
/**
|
|
24
|
+
* Service device id
|
|
25
|
+
*/
|
|
26
|
+
protected serviceDeviceId: string;
|
|
23
27
|
/**
|
|
24
28
|
* Constructor
|
|
25
29
|
* @param settings Settings
|
|
@@ -42,6 +46,21 @@ export declare class ServiceApp<P extends IServicePageData = IServicePageData, U
|
|
|
42
46
|
*/
|
|
43
47
|
refreshToken<D = RefreshTokenRQ>(props?: RefreshTokenProps<D>): Promise<boolean>;
|
|
44
48
|
private loginFailed;
|
|
49
|
+
/**
|
|
50
|
+
* Service decrypt message
|
|
51
|
+
* @param messageEncrypted Encrypted message
|
|
52
|
+
* @param passphrase Secret passphrase
|
|
53
|
+
* @returns Pure text
|
|
54
|
+
*/
|
|
55
|
+
serviceDecrypt(messageEncrypted: string, passphrase?: string): string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Service encrypt message
|
|
58
|
+
* @param message Message
|
|
59
|
+
* @param passphrase Secret passphrase
|
|
60
|
+
* @param iterations Iterations, 1000 times, 1 - 99
|
|
61
|
+
* @returns Result
|
|
62
|
+
*/
|
|
63
|
+
serviceEncrypt(message: string, passphrase?: string, iterations?: number): string;
|
|
45
64
|
/**
|
|
46
65
|
* Try login
|
|
47
66
|
*/
|
package/lib/app/ServiceApp.js
CHANGED
|
@@ -16,6 +16,10 @@ export class ServiceApp extends ReactApp {
|
|
|
16
16
|
*/
|
|
17
17
|
constructor(settings, name) {
|
|
18
18
|
super(settings, name);
|
|
19
|
+
/**
|
|
20
|
+
* Service device id
|
|
21
|
+
*/
|
|
22
|
+
this.serviceDeviceId = '';
|
|
19
23
|
// Check
|
|
20
24
|
if (settings.serviceId == null || settings.coreApi == null) {
|
|
21
25
|
throw new Error('No service settings');
|
|
@@ -93,7 +97,7 @@ export class ServiceApp extends ReactApp {
|
|
|
93
97
|
const userData = result.data;
|
|
94
98
|
// Use core system access token to service api to exchange service access token
|
|
95
99
|
const serviceResult = await this.api.put('Auth/ExchangeToken', {
|
|
96
|
-
token: userData.token
|
|
100
|
+
token: this.encryptEnhanced(userData.token, this.settings.serviceId.toString())
|
|
97
101
|
}, {
|
|
98
102
|
showLoading,
|
|
99
103
|
onError: (error) => {
|
|
@@ -139,7 +143,7 @@ export class ServiceApp extends ReactApp {
|
|
|
139
143
|
// Set password for the action
|
|
140
144
|
rq.pwd = this.encrypt(this.hash(pwd));
|
|
141
145
|
// Submit again
|
|
142
|
-
const result = await this.
|
|
146
|
+
const result = await this.coreApi.put('Auth/RefreshToken', rq, payload);
|
|
143
147
|
if (result == null)
|
|
144
148
|
return;
|
|
145
149
|
if (result.ok) {
|
|
@@ -172,6 +176,25 @@ export class ServiceApp extends ReactApp {
|
|
|
172
176
|
this.userUnauthorized();
|
|
173
177
|
this.toLoginPage();
|
|
174
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Service decrypt message
|
|
181
|
+
* @param messageEncrypted Encrypted message
|
|
182
|
+
* @param passphrase Secret passphrase
|
|
183
|
+
* @returns Pure text
|
|
184
|
+
*/
|
|
185
|
+
serviceDecrypt(messageEncrypted, passphrase) {
|
|
186
|
+
return this.decrypt(messageEncrypted, passphrase !== null && passphrase !== void 0 ? passphrase : this.serviceDeviceId);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Service encrypt message
|
|
190
|
+
* @param message Message
|
|
191
|
+
* @param passphrase Secret passphrase
|
|
192
|
+
* @param iterations Iterations, 1000 times, 1 - 99
|
|
193
|
+
* @returns Result
|
|
194
|
+
*/
|
|
195
|
+
serviceEncrypt(message, passphrase, iterations) {
|
|
196
|
+
return this.encrypt(message, passphrase !== null && passphrase !== void 0 ? passphrase : this.serviceDeviceId, iterations);
|
|
197
|
+
}
|
|
175
198
|
/**
|
|
176
199
|
* Try login
|
|
177
200
|
*/
|
|
@@ -207,6 +230,7 @@ export class ServiceApp extends ReactApp {
|
|
|
207
230
|
*/
|
|
208
231
|
userLoginEx(user, refreshToken, coreUser) {
|
|
209
232
|
// Service user login
|
|
233
|
+
this.serviceDeviceId = user.serviceDeviceId;
|
|
210
234
|
super.userLogin(user, refreshToken, false);
|
|
211
235
|
// Core system user
|
|
212
236
|
this.coreUser = coreUser;
|
package/package.json
CHANGED
package/src/app/IServiceUser.ts
CHANGED
|
@@ -3,7 +3,12 @@ import { IActionResult, IUser } from '@etsoo/appscript';
|
|
|
3
3
|
/**
|
|
4
4
|
* Service user interface
|
|
5
5
|
*/
|
|
6
|
-
export interface IServiceUser extends IUser {
|
|
6
|
+
export interface IServiceUser extends IUser {
|
|
7
|
+
/**
|
|
8
|
+
* Service device id
|
|
9
|
+
*/
|
|
10
|
+
serviceDeviceId: string;
|
|
11
|
+
}
|
|
7
12
|
|
|
8
13
|
/**
|
|
9
14
|
* Service user login result
|
package/src/app/ServiceApp.ts
CHANGED
|
@@ -37,6 +37,11 @@ export class ServiceApp<
|
|
|
37
37
|
*/
|
|
38
38
|
coreUser?: ISmartERPUser;
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Service device id
|
|
42
|
+
*/
|
|
43
|
+
protected serviceDeviceId: string = '';
|
|
44
|
+
|
|
40
45
|
/**
|
|
41
46
|
* Constructor
|
|
42
47
|
* @param settings Settings
|
|
@@ -143,7 +148,10 @@ export class ServiceApp<
|
|
|
143
148
|
const serviceResult = await this.api.put<ServiceLoginResult>(
|
|
144
149
|
'Auth/ExchangeToken',
|
|
145
150
|
{
|
|
146
|
-
token:
|
|
151
|
+
token: this.encryptEnhanced(
|
|
152
|
+
userData.token,
|
|
153
|
+
this.settings.serviceId.toString()
|
|
154
|
+
)
|
|
147
155
|
},
|
|
148
156
|
{
|
|
149
157
|
showLoading,
|
|
@@ -202,11 +210,12 @@ export class ServiceApp<
|
|
|
202
210
|
rq.pwd = this.encrypt(this.hash(pwd));
|
|
203
211
|
|
|
204
212
|
// Submit again
|
|
205
|
-
const result =
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
213
|
+
const result =
|
|
214
|
+
await this.coreApi.put<SmartERPLoginResult>(
|
|
215
|
+
'Auth/RefreshToken',
|
|
216
|
+
rq,
|
|
217
|
+
payload
|
|
218
|
+
);
|
|
210
219
|
|
|
211
220
|
if (result == null) return;
|
|
212
221
|
|
|
@@ -253,6 +262,34 @@ export class ServiceApp<
|
|
|
253
262
|
this.toLoginPage();
|
|
254
263
|
}
|
|
255
264
|
|
|
265
|
+
/**
|
|
266
|
+
* Service decrypt message
|
|
267
|
+
* @param messageEncrypted Encrypted message
|
|
268
|
+
* @param passphrase Secret passphrase
|
|
269
|
+
* @returns Pure text
|
|
270
|
+
*/
|
|
271
|
+
serviceDecrypt(messageEncrypted: string, passphrase?: string) {
|
|
272
|
+
return this.decrypt(
|
|
273
|
+
messageEncrypted,
|
|
274
|
+
passphrase ?? this.serviceDeviceId
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Service encrypt message
|
|
280
|
+
* @param message Message
|
|
281
|
+
* @param passphrase Secret passphrase
|
|
282
|
+
* @param iterations Iterations, 1000 times, 1 - 99
|
|
283
|
+
* @returns Result
|
|
284
|
+
*/
|
|
285
|
+
serviceEncrypt(message: string, passphrase?: string, iterations?: number) {
|
|
286
|
+
return this.encrypt(
|
|
287
|
+
message,
|
|
288
|
+
passphrase ?? this.serviceDeviceId,
|
|
289
|
+
iterations
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
256
293
|
/**
|
|
257
294
|
* Try login
|
|
258
295
|
*/
|
|
@@ -294,6 +331,7 @@ export class ServiceApp<
|
|
|
294
331
|
coreUser: ISmartERPUser
|
|
295
332
|
): void {
|
|
296
333
|
// Service user login
|
|
334
|
+
this.serviceDeviceId = user.serviceDeviceId;
|
|
297
335
|
super.userLogin(user, refreshToken, false);
|
|
298
336
|
|
|
299
337
|
// Core system user
|