@etsoo/materialui 1.3.89 → 1.3.91

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
@@ -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
@@ -48,19 +44,4 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
48
44
  * @param dispatch User state dispatch
49
45
  */
50
46
  userLogin(user: U, refreshToken: string, keep?: boolean, dispatch?: boolean): void;
51
- /**
52
- * Service decrypt message
53
- * @param messageEncrypted Encrypted message
54
- * @param passphrase Secret passphrase
55
- * @returns Pure text
56
- */
57
- serviceDecrypt(messageEncrypted: string, passphrase?: string): string | undefined;
58
- /**
59
- * Service encrypt message
60
- * @param message Message
61
- * @param passphrase Secret passphrase
62
- * @param iterations Iterations, 1000 times, 1 - 99
63
- * @returns Result
64
- */
65
- serviceEncrypt(message: string, passphrase?: string, iterations?: number): string;
66
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.");
@@ -80,27 +72,11 @@ export class ServiceApp extends ReactApp {
80
72
  userLogin(user, refreshToken, keep, dispatch) {
81
73
  // Super call, set token
82
74
  super.userLogin(user, refreshToken, keep, dispatch);
83
- // Set service passphrase
84
- this.servicePassphrase =
85
- this.decrypt(user.servicePassphrase, `${user.uid}-${this.settings.appId}`) ?? "";
86
- }
87
- /**
88
- * Service decrypt message
89
- * @param messageEncrypted Encrypted message
90
- * @param passphrase Secret passphrase
91
- * @returns Pure text
92
- */
93
- serviceDecrypt(messageEncrypted, passphrase) {
94
- return this.decrypt(messageEncrypted, passphrase ?? this.servicePassphrase);
95
- }
96
- /**
97
- * Service encrypt message
98
- * @param message Message
99
- * @param passphrase Secret passphrase
100
- * @param iterations Iterations, 1000 times, 1 - 99
101
- * @returns Result
102
- */
103
- serviceEncrypt(message, passphrase, iterations) {
104
- 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
+ }
105
81
  }
106
82
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.3.89",
3
+ "version": "1.3.91",
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.24",
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
  /**
@@ -31,11 +31,6 @@ export class ServiceApp<
31
31
  */
32
32
  readonly coreApi: IApi;
33
33
 
34
- /**
35
- * Service passphrase
36
- */
37
- protected servicePassphrase: string = "";
38
-
39
34
  /**
40
35
  * Constructor
41
36
  * @param settings Settings
@@ -45,11 +40,6 @@ export class ServiceApp<
45
40
  constructor(settings: S, name: string, debug: boolean = false) {
46
41
  super(settings, name, debug);
47
42
 
48
- // Check
49
- if (settings.appId == null) {
50
- throw new Error("Service Application ID is required.");
51
- }
52
-
53
43
  const coreEndpoint = settings.endpoints?.core;
54
44
  if (coreEndpoint == null) {
55
45
  throw new Error("Core API endpont is required.");
@@ -117,36 +107,13 @@ export class ServiceApp<
117
107
  // Super call, set token
118
108
  super.userLogin(user, refreshToken, keep, dispatch);
119
109
 
120
- // Set service passphrase
121
- this.servicePassphrase =
122
- this.decrypt(
123
- user.servicePassphrase,
110
+ if (user.passphrase) {
111
+ // Save the passphrase
112
+ const passphrase = this.decrypt(
113
+ user.passphrase,
124
114
  `${user.uid}-${this.settings.appId}`
125
- ) ?? "";
126
- }
127
-
128
- /**
129
- * Service decrypt message
130
- * @param messageEncrypted Encrypted message
131
- * @param passphrase Secret passphrase
132
- * @returns Pure text
133
- */
134
- serviceDecrypt(messageEncrypted: string, passphrase?: string) {
135
- return this.decrypt(messageEncrypted, passphrase ?? this.servicePassphrase);
136
- }
137
-
138
- /**
139
- * Service encrypt message
140
- * @param message Message
141
- * @param passphrase Secret passphrase
142
- * @param iterations Iterations, 1000 times, 1 - 99
143
- * @returns Result
144
- */
145
- serviceEncrypt(message: string, passphrase?: string, iterations?: number) {
146
- return this.encrypt(
147
- message,
148
- passphrase ?? this.servicePassphrase,
149
- iterations
150
- );
115
+ );
116
+ if (passphrase) this.updatePassphrase(passphrase);
117
+ }
151
118
  }
152
119
  }