@etsoo/materialui 1.3.90 → 1.3.92

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.
@@ -1,25 +1,15 @@
1
+ import { IApi } from "@etsoo/appscript";
1
2
  import { ReactAppType } from "./ReactApp";
2
3
  /**
3
4
  * Service application interface
4
5
  */
5
6
  export interface IServiceApp extends ReactAppType {
6
7
  /**
7
- * Load core system UI
8
- */
9
- loadCore(): void;
10
- /**
11
- * Service decrypt message
12
- * @param messageEncrypted Encrypted message
13
- * @param passphrase Secret passphrase
14
- * @returns Pure text
8
+ * Core system API
15
9
  */
16
- serviceDecrypt(messageEncrypted: string, passphrase?: string): string | undefined;
10
+ readonly coreApi: IApi;
17
11
  /**
18
- * Service encrypt message
19
- * @param message Message
20
- * @param passphrase Secret passphrase
21
- * @param iterations Iterations, 1000 times, 1 - 99
22
- * @returns Result
12
+ * Load core system UI
23
13
  */
24
- serviceEncrypt(message: string, passphrase?: string, iterations?: number): string | undefined;
14
+ loadCore(): void;
25
15
  }
@@ -1,11 +1,11 @@
1
1
  import { IAppSettings } from "@etsoo/appscript";
2
- import { IdType } from "@etsoo/shared";
3
2
  /**
4
3
  * Service app settings interface
5
4
  */
6
- export interface IServiceAppSettings<S extends IdType = number> extends IAppSettings {
5
+ export interface IServiceAppSettings extends IAppSettings {
7
6
  /**
8
- * Service application id
7
+ * Application id
8
+ * 程序编号
9
9
  */
10
- readonly appId: S;
10
+ appId: number;
11
11
  }
@@ -11,12 +11,14 @@ export interface IServiceUser extends IUser {
11
11
  readonly uid: string;
12
12
  /**
13
13
  * Organization name
14
+ * 机构名称
14
15
  */
15
16
  readonly organizationName: string;
16
17
  /**
17
18
  * Service (App) passphrase encrypted
19
+ * 服务(应用)加密密钥
18
20
  */
19
- readonly servicePassphrase: string;
21
+ readonly passphrase?: string;
20
22
  }
21
23
  /**
22
24
  * Service user login result
@@ -1,4 +1,4 @@
1
- import { ExternalEndpoint, IApi, InitCallDto, InitCallResult } from "@etsoo/appscript";
1
+ import { ExternalEndpoint, IApi } from "@etsoo/appscript";
2
2
  import { IServiceApp } from "./IServiceApp";
3
3
  import { IServiceAppSettings } from "./IServiceAppSettings";
4
4
  import { IServicePageData } from "./IServicePage";
@@ -19,10 +19,6 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
19
19
  * Core system API
20
20
  */
21
21
  readonly coreApi: IApi;
22
- /**
23
- * Service passphrase
24
- */
25
- protected servicePassphrase: string;
26
22
  /**
27
23
  * Constructor
28
24
  * @param settings Settings
@@ -34,12 +30,6 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
34
30
  * Load core system UI
35
31
  */
36
32
  loadCore(): void;
37
- /**
38
- * Api init call, for service application, call the core system API
39
- * @param data Data
40
- * @returns Result
41
- */
42
- apiInitCall(data: InitCallDto): Promise<InitCallResult | undefined>;
43
33
  /**
44
34
  * Go to the login page
45
35
  * @param tryLogin Try to login again
@@ -54,19 +44,4 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
54
44
  * @param dispatch User state dispatch
55
45
  */
56
46
  userLogin(user: U, refreshToken: string, keep?: boolean, dispatch?: boolean): void;
57
- /**
58
- * Service decrypt message
59
- * @param messageEncrypted Encrypted message
60
- * @param passphrase Secret passphrase
61
- * @returns Pure text
62
- */
63
- serviceDecrypt(messageEncrypted: string, passphrase?: string): string | undefined;
64
- /**
65
- * Service encrypt message
66
- * @param message Message
67
- * @param passphrase Secret passphrase
68
- * @param iterations Iterations, 1000 times, 1 - 99
69
- * @returns Result
70
- */
71
- serviceEncrypt(message: string, passphrase?: string, iterations?: number): string;
72
47
  }
@@ -16,14 +16,6 @@ export class ServiceApp extends ReactApp {
16
16
  */
17
17
  constructor(settings, name, debug = false) {
18
18
  super(settings, name, debug);
19
- /**
20
- * Service passphrase
21
- */
22
- this.servicePassphrase = "";
23
- // Check
24
- if (settings.appId == null) {
25
- throw new Error("Service Application ID is required.");
26
- }
27
19
  const coreEndpoint = settings.endpoints?.core;
28
20
  if (coreEndpoint == null) {
29
21
  throw new Error("Core API endpont is required.");
@@ -42,14 +34,6 @@ export class ServiceApp extends ReactApp {
42
34
  BridgeUtils.host.loadApp(coreName);
43
35
  }
44
36
  }
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
- }
53
37
  /**
54
38
  * Go to the login page
55
39
  * @param tryLogin Try to login again
@@ -88,27 +72,11 @@ export class ServiceApp extends ReactApp {
88
72
  userLogin(user, refreshToken, keep, dispatch) {
89
73
  // Super call, set token
90
74
  super.userLogin(user, refreshToken, keep, dispatch);
91
- // Set service passphrase
92
- this.servicePassphrase =
93
- this.decrypt(user.servicePassphrase, `${user.uid}-${this.settings.appId}`) ?? "";
94
- }
95
- /**
96
- * Service decrypt message
97
- * @param messageEncrypted Encrypted message
98
- * @param passphrase Secret passphrase
99
- * @returns Pure text
100
- */
101
- serviceDecrypt(messageEncrypted, passphrase) {
102
- return this.decrypt(messageEncrypted, passphrase ?? this.servicePassphrase);
103
- }
104
- /**
105
- * Service encrypt message
106
- * @param message Message
107
- * @param passphrase Secret passphrase
108
- * @param iterations Iterations, 1000 times, 1 - 99
109
- * @returns Result
110
- */
111
- serviceEncrypt(message, passphrase, iterations) {
112
- return this.encrypt(message, passphrase ?? this.servicePassphrase, iterations);
75
+ if (user.passphrase) {
76
+ // Save the passphrase
77
+ const passphrase = this.decrypt(user.passphrase, `${user.uid}-${this.settings.appId}`);
78
+ if (passphrase)
79
+ this.updatePassphrase(passphrase);
80
+ }
113
81
  }
114
82
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.3.90",
3
+ "version": "1.3.92",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -50,7 +50,7 @@
50
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.22",
53
+ "@etsoo/appscript": "^1.5.25",
54
54
  "@etsoo/notificationbase": "^1.1.48",
55
55
  "@etsoo/react": "^1.7.68",
56
56
  "@etsoo/shared": "^1.2.46",
@@ -1,3 +1,4 @@
1
+ import { IApi } from "@etsoo/appscript";
1
2
  import { ReactAppType } from "./ReactApp";
2
3
 
3
4
  /**
@@ -5,31 +6,12 @@ import { ReactAppType } from "./ReactApp";
5
6
  */
6
7
  export interface IServiceApp extends ReactAppType {
7
8
  /**
8
- * Load core system UI
9
+ * Core system API
9
10
  */
10
- loadCore(): void;
11
+ readonly coreApi: IApi;
11
12
 
12
13
  /**
13
- * Service decrypt message
14
- * @param messageEncrypted Encrypted message
15
- * @param passphrase Secret passphrase
16
- * @returns Pure text
17
- */
18
- serviceDecrypt(
19
- messageEncrypted: string,
20
- passphrase?: string
21
- ): string | undefined;
22
-
23
- /**
24
- * Service encrypt message
25
- * @param message Message
26
- * @param passphrase Secret passphrase
27
- * @param iterations Iterations, 1000 times, 1 - 99
28
- * @returns Result
14
+ * Load core system UI
29
15
  */
30
- serviceEncrypt(
31
- message: string,
32
- passphrase?: string,
33
- iterations?: number
34
- ): string | undefined;
16
+ loadCore(): void;
35
17
  }
@@ -1,13 +1,12 @@
1
1
  import { IAppSettings } from "@etsoo/appscript";
2
- import { IdType } from "@etsoo/shared";
3
2
 
4
3
  /**
5
4
  * Service app settings interface
6
5
  */
7
- export interface IServiceAppSettings<S extends IdType = number>
8
- extends IAppSettings {
6
+ export interface IServiceAppSettings extends IAppSettings {
9
7
  /**
10
- * Service application id
8
+ * Application id
9
+ * 程序编号
11
10
  */
12
- readonly appId: S;
11
+ appId: number;
13
12
  }
@@ -13,13 +13,15 @@ export interface IServiceUser extends IUser {
13
13
 
14
14
  /**
15
15
  * Organization name
16
+ * 机构名称
16
17
  */
17
18
  readonly organizationName: string;
18
19
 
19
20
  /**
20
21
  * Service (App) passphrase encrypted
22
+ * 服务(应用)加密密钥
21
23
  */
22
- readonly servicePassphrase: string;
24
+ readonly passphrase?: string;
23
25
  }
24
26
 
25
27
  /**
@@ -1,10 +1,4 @@
1
- import {
2
- BridgeUtils,
3
- ExternalEndpoint,
4
- IApi,
5
- InitCallDto,
6
- InitCallResult
7
- } from "@etsoo/appscript";
1
+ import { BridgeUtils, ExternalEndpoint, IApi } from "@etsoo/appscript";
8
2
  import { IServiceApp } from "./IServiceApp";
9
3
  import { IServiceAppSettings } from "./IServiceAppSettings";
10
4
  import { IServicePageData } from "./IServicePage";
@@ -37,11 +31,6 @@ export class ServiceApp<
37
31
  */
38
32
  readonly coreApi: IApi;
39
33
 
40
- /**
41
- * Service passphrase
42
- */
43
- protected servicePassphrase: string = "";
44
-
45
34
  /**
46
35
  * Constructor
47
36
  * @param settings Settings
@@ -51,11 +40,6 @@ export class ServiceApp<
51
40
  constructor(settings: S, name: string, debug: boolean = false) {
52
41
  super(settings, name, debug);
53
42
 
54
- // Check
55
- if (settings.appId == null) {
56
- throw new Error("Service Application ID is required.");
57
- }
58
-
59
43
  const coreEndpoint = settings.endpoints?.core;
60
44
  if (coreEndpoint == null) {
61
45
  throw new Error("Core API endpont is required.");
@@ -76,15 +60,6 @@ export class ServiceApp<
76
60
  }
77
61
  }
78
62
 
79
- /**
80
- * Api init call, for service application, call the core system API
81
- * @param data Data
82
- * @returns Result
83
- */
84
- override async apiInitCall(data: InitCallDto) {
85
- return await this.coreApi.put<InitCallResult>(this.initCallApi, data);
86
- }
87
-
88
63
  /**
89
64
  * Go to the login page
90
65
  * @param tryLogin Try to login again
@@ -132,36 +107,13 @@ export class ServiceApp<
132
107
  // Super call, set token
133
108
  super.userLogin(user, refreshToken, keep, dispatch);
134
109
 
135
- // Set service passphrase
136
- this.servicePassphrase =
137
- this.decrypt(
138
- user.servicePassphrase,
110
+ if (user.passphrase) {
111
+ // Save the passphrase
112
+ const passphrase = this.decrypt(
113
+ user.passphrase,
139
114
  `${user.uid}-${this.settings.appId}`
140
- ) ?? "";
141
- }
142
-
143
- /**
144
- * Service decrypt message
145
- * @param messageEncrypted Encrypted message
146
- * @param passphrase Secret passphrase
147
- * @returns Pure text
148
- */
149
- serviceDecrypt(messageEncrypted: string, passphrase?: string) {
150
- return this.decrypt(messageEncrypted, passphrase ?? this.servicePassphrase);
151
- }
152
-
153
- /**
154
- * Service encrypt message
155
- * @param message Message
156
- * @param passphrase Secret passphrase
157
- * @param iterations Iterations, 1000 times, 1 - 99
158
- * @returns Result
159
- */
160
- serviceEncrypt(message: string, passphrase?: string, iterations?: number) {
161
- return this.encrypt(
162
- message,
163
- passphrase ?? this.servicePassphrase,
164
- iterations
165
- );
115
+ );
116
+ if (passphrase) this.updatePassphrase(passphrase);
117
+ }
166
118
  }
167
119
  }