@etsoo/materialui 1.3.94 → 1.3.96
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/IServiceApp.d.ts +10 -1
- package/lib/app/IServiceUser.d.ts +14 -3
- package/lib/app/ServiceApp.d.ts +10 -2
- package/lib/app/ServiceApp.js +26 -5
- package/package.json +2 -2
- package/src/app/IServiceApp.ts +16 -1
- package/src/app/IServiceUser.ts +15 -3
- package/src/app/ServiceApp.ts +42 -8
package/lib/app/IServiceApp.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { IApi } from "@etsoo/appscript";
|
|
1
|
+
import { ApiRefreshTokenDto, IApi } from "@etsoo/appscript";
|
|
2
2
|
import { ReactAppType } from "./ReactApp";
|
|
3
|
+
import { IServiceUser, ServiceUserToken } from "./IServiceUser";
|
|
3
4
|
/**
|
|
4
5
|
* Service application interface
|
|
5
6
|
*/
|
|
@@ -12,4 +13,12 @@ export interface IServiceApp extends ReactAppType {
|
|
|
12
13
|
* Load core system UI
|
|
13
14
|
*/
|
|
14
15
|
loadCore(): void;
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param user Current user
|
|
19
|
+
* @param core Core system API token data
|
|
20
|
+
* @param keep Keep in local storage or not
|
|
21
|
+
* @param dispatch User state dispatch
|
|
22
|
+
*/
|
|
23
|
+
userLoginEx(user: IServiceUser & ServiceUserToken, core?: ApiRefreshTokenDto, keep?: boolean, dispatch?: boolean): void;
|
|
15
24
|
}
|
|
@@ -20,11 +20,22 @@ export interface IServiceUser extends IUser {
|
|
|
20
20
|
*/
|
|
21
21
|
readonly passphrase?: string;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
23
|
+
* Client device id
|
|
24
|
+
* 客户端设备编号
|
|
25
25
|
*/
|
|
26
|
-
readonly
|
|
26
|
+
readonly clientDeviceId?: string;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Service user token return type
|
|
30
|
+
* 服务用户令牌返回类型
|
|
31
|
+
*/
|
|
32
|
+
export type ServiceUserToken = {
|
|
33
|
+
/**
|
|
34
|
+
* Refresh token
|
|
35
|
+
* 刷新令牌
|
|
36
|
+
*/
|
|
37
|
+
readonly refreshToken: string;
|
|
38
|
+
};
|
|
28
39
|
/**
|
|
29
40
|
* Service user login result
|
|
30
41
|
*/
|
package/lib/app/ServiceApp.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ExternalEndpoint, IApi } from "@etsoo/appscript";
|
|
1
|
+
import { ApiRefreshTokenDto, ExternalEndpoint, IApi } from "@etsoo/appscript";
|
|
2
2
|
import { IServiceApp } from "./IServiceApp";
|
|
3
3
|
import { IServiceAppSettings } from "./IServiceAppSettings";
|
|
4
4
|
import { IServicePageData } from "./IServicePage";
|
|
5
|
-
import { IServiceUser } from "./IServiceUser";
|
|
5
|
+
import { IServiceUser, ServiceUserToken } from "./IServiceUser";
|
|
6
6
|
import { ReactApp } from "./ReactApp";
|
|
7
7
|
/**
|
|
8
8
|
* Core Service App
|
|
@@ -44,4 +44,12 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
|
|
|
44
44
|
* @param dispatch User state dispatch
|
|
45
45
|
*/
|
|
46
46
|
userLogin(user: U, refreshToken: string, keep?: boolean, dispatch?: boolean): void;
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @param user Current user
|
|
50
|
+
* @param core Core system API token data
|
|
51
|
+
* @param keep Keep in local storage or not
|
|
52
|
+
* @param dispatch User state dispatch
|
|
53
|
+
*/
|
|
54
|
+
userLoginEx(user: U & ServiceUserToken, core?: ApiRefreshTokenDto, keep?: boolean, dispatch?: boolean): void;
|
|
47
55
|
}
|
package/lib/app/ServiceApp.js
CHANGED
|
@@ -71,15 +71,36 @@ export class ServiceApp extends ReactApp {
|
|
|
71
71
|
* @param dispatch User state dispatch
|
|
72
72
|
*/
|
|
73
73
|
userLogin(user, refreshToken, keep, dispatch) {
|
|
74
|
-
|
|
75
|
-
super.userLogin(user, refreshToken, keep, dispatch);
|
|
76
|
-
if (user.deviceId && user.passphrase) {
|
|
74
|
+
if (user.clientDeviceId && user.passphrase) {
|
|
77
75
|
// Save the passphrase
|
|
78
|
-
|
|
76
|
+
// Interpolated string expressions are different between TypeScript and C# for the null value
|
|
77
|
+
const passphrase = this.decrypt(user.passphrase, `${user.uid ?? ""}-${this.settings.appId}`);
|
|
79
78
|
if (passphrase) {
|
|
80
|
-
this.deviceId = user.
|
|
79
|
+
this.deviceId = user.clientDeviceId;
|
|
81
80
|
this.updatePassphrase(passphrase);
|
|
82
81
|
}
|
|
83
82
|
}
|
|
83
|
+
// Super call, set token
|
|
84
|
+
super.userLogin(user, refreshToken, keep, dispatch);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
* @param user Current user
|
|
89
|
+
* @param core Core system API token data
|
|
90
|
+
* @param keep Keep in local storage or not
|
|
91
|
+
* @param dispatch User state dispatch
|
|
92
|
+
*/
|
|
93
|
+
userLoginEx(user, core, keep, dispatch) {
|
|
94
|
+
// User login
|
|
95
|
+
const { refreshToken } = user;
|
|
96
|
+
this.userLogin(user, refreshToken, keep, dispatch);
|
|
97
|
+
// Core system login
|
|
98
|
+
core ?? (core = {
|
|
99
|
+
refreshToken,
|
|
100
|
+
accessToken: user.token,
|
|
101
|
+
tokenType: user.tokenScheme ?? "Bearer",
|
|
102
|
+
expiresIn: user.seconds
|
|
103
|
+
});
|
|
104
|
+
this.exchangeTokenAll(core, coreName);
|
|
84
105
|
}
|
|
85
106
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.96",
|
|
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.
|
|
53
|
+
"@etsoo/appscript": "^1.5.28",
|
|
54
54
|
"@etsoo/notificationbase": "^1.1.49",
|
|
55
55
|
"@etsoo/react": "^1.7.69",
|
|
56
56
|
"@etsoo/shared": "^1.2.48",
|
package/src/app/IServiceApp.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { IApi } from "@etsoo/appscript";
|
|
1
|
+
import { ApiRefreshTokenDto, IApi } from "@etsoo/appscript";
|
|
2
2
|
import { ReactAppType } from "./ReactApp";
|
|
3
|
+
import { IServiceUser, ServiceUserToken } from "./IServiceUser";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Service application interface
|
|
@@ -14,4 +15,18 @@ export interface IServiceApp extends ReactAppType {
|
|
|
14
15
|
* Load core system UI
|
|
15
16
|
*/
|
|
16
17
|
loadCore(): void;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param user Current user
|
|
22
|
+
* @param core Core system API token data
|
|
23
|
+
* @param keep Keep in local storage or not
|
|
24
|
+
* @param dispatch User state dispatch
|
|
25
|
+
*/
|
|
26
|
+
userLoginEx(
|
|
27
|
+
user: IServiceUser & ServiceUserToken,
|
|
28
|
+
core?: ApiRefreshTokenDto,
|
|
29
|
+
keep?: boolean,
|
|
30
|
+
dispatch?: boolean
|
|
31
|
+
): void;
|
|
17
32
|
}
|
package/src/app/IServiceUser.ts
CHANGED
|
@@ -24,12 +24,24 @@ export interface IServiceUser extends IUser {
|
|
|
24
24
|
readonly passphrase?: string;
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
27
|
+
* Client device id
|
|
28
|
+
* 客户端设备编号
|
|
29
29
|
*/
|
|
30
|
-
readonly
|
|
30
|
+
readonly clientDeviceId?: string;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Service user token return type
|
|
35
|
+
* 服务用户令牌返回类型
|
|
36
|
+
*/
|
|
37
|
+
export type ServiceUserToken = {
|
|
38
|
+
/**
|
|
39
|
+
* Refresh token
|
|
40
|
+
* 刷新令牌
|
|
41
|
+
*/
|
|
42
|
+
readonly refreshToken: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
33
45
|
/**
|
|
34
46
|
* Service user login result
|
|
35
47
|
*/
|
package/src/app/ServiceApp.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ApiRefreshTokenDto,
|
|
3
|
+
BridgeUtils,
|
|
4
|
+
ExternalEndpoint,
|
|
5
|
+
IApi
|
|
6
|
+
} from "@etsoo/appscript";
|
|
2
7
|
import { IServiceApp } from "./IServiceApp";
|
|
3
8
|
import { IServiceAppSettings } from "./IServiceAppSettings";
|
|
4
9
|
import { IServicePageData } from "./IServicePage";
|
|
5
|
-
import { IServiceUser } from "./IServiceUser";
|
|
10
|
+
import { IServiceUser, ServiceUserToken } from "./IServiceUser";
|
|
6
11
|
import { ReactApp } from "./ReactApp";
|
|
7
12
|
|
|
8
13
|
const coreName = "core";
|
|
@@ -105,19 +110,48 @@ export class ServiceApp<
|
|
|
105
110
|
keep?: boolean,
|
|
106
111
|
dispatch?: boolean
|
|
107
112
|
): void {
|
|
108
|
-
|
|
109
|
-
super.userLogin(user, refreshToken, keep, dispatch);
|
|
110
|
-
|
|
111
|
-
if (user.deviceId && user.passphrase) {
|
|
113
|
+
if (user.clientDeviceId && user.passphrase) {
|
|
112
114
|
// Save the passphrase
|
|
115
|
+
// Interpolated string expressions are different between TypeScript and C# for the null value
|
|
113
116
|
const passphrase = this.decrypt(
|
|
114
117
|
user.passphrase,
|
|
115
|
-
`${user.uid}-${this.settings.appId}`
|
|
118
|
+
`${user.uid ?? ""}-${this.settings.appId}`
|
|
116
119
|
);
|
|
117
120
|
if (passphrase) {
|
|
118
|
-
this.deviceId = user.
|
|
121
|
+
this.deviceId = user.clientDeviceId;
|
|
119
122
|
this.updatePassphrase(passphrase);
|
|
120
123
|
}
|
|
121
124
|
}
|
|
125
|
+
|
|
126
|
+
// Super call, set token
|
|
127
|
+
super.userLogin(user, refreshToken, keep, dispatch);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
*
|
|
132
|
+
* @param user Current user
|
|
133
|
+
* @param core Core system API token data
|
|
134
|
+
* @param keep Keep in local storage or not
|
|
135
|
+
* @param dispatch User state dispatch
|
|
136
|
+
*/
|
|
137
|
+
userLoginEx(
|
|
138
|
+
user: U & ServiceUserToken,
|
|
139
|
+
core?: ApiRefreshTokenDto,
|
|
140
|
+
keep?: boolean,
|
|
141
|
+
dispatch?: boolean
|
|
142
|
+
) {
|
|
143
|
+
// User login
|
|
144
|
+
const { refreshToken } = user;
|
|
145
|
+
this.userLogin(user, refreshToken, keep, dispatch);
|
|
146
|
+
|
|
147
|
+
// Core system login
|
|
148
|
+
core ??= {
|
|
149
|
+
refreshToken,
|
|
150
|
+
accessToken: user.token,
|
|
151
|
+
tokenType: user.tokenScheme ?? "Bearer",
|
|
152
|
+
expiresIn: user.seconds
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
this.exchangeTokenAll(core, coreName);
|
|
122
156
|
}
|
|
123
157
|
}
|