@etsoo/materialui 1.3.94 → 1.3.95
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 +22 -2
- package/package.json +2 -2
- package/src/app/IServiceApp.ts +16 -1
- package/src/app/IServiceUser.ts +15 -3
- package/src/app/ServiceApp.ts +37 -4
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
|
@@ -73,13 +73,33 @@ export class ServiceApp extends ReactApp {
|
|
|
73
73
|
userLogin(user, refreshToken, keep, dispatch) {
|
|
74
74
|
// Super call, set token
|
|
75
75
|
super.userLogin(user, refreshToken, keep, dispatch);
|
|
76
|
-
if (user.
|
|
76
|
+
if (user.clientDeviceId && user.passphrase) {
|
|
77
77
|
// Save the passphrase
|
|
78
78
|
const passphrase = this.decrypt(user.passphrase, `${user.uid}-${this.settings.appId}`);
|
|
79
79
|
if (passphrase) {
|
|
80
|
-
this.deviceId = user.
|
|
80
|
+
this.deviceId = user.clientDeviceId;
|
|
81
81
|
this.updatePassphrase(passphrase);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* @param user Current user
|
|
88
|
+
* @param core Core system API token data
|
|
89
|
+
* @param keep Keep in local storage or not
|
|
90
|
+
* @param dispatch User state dispatch
|
|
91
|
+
*/
|
|
92
|
+
userLoginEx(user, core, keep, dispatch) {
|
|
93
|
+
// User login
|
|
94
|
+
const { refreshToken } = user;
|
|
95
|
+
this.userLogin(user, refreshToken, keep, dispatch);
|
|
96
|
+
// Core system login
|
|
97
|
+
core ?? (core = {
|
|
98
|
+
refreshToken,
|
|
99
|
+
accessToken: user.token,
|
|
100
|
+
tokenType: user.tokenScheme ?? "Bearer",
|
|
101
|
+
expiresIn: user.seconds
|
|
102
|
+
});
|
|
103
|
+
this.exchangeTokenAll(core, coreName);
|
|
104
|
+
}
|
|
85
105
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.95",
|
|
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";
|
|
@@ -108,16 +113,44 @@ export class ServiceApp<
|
|
|
108
113
|
// Super call, set token
|
|
109
114
|
super.userLogin(user, refreshToken, keep, dispatch);
|
|
110
115
|
|
|
111
|
-
if (user.
|
|
116
|
+
if (user.clientDeviceId && user.passphrase) {
|
|
112
117
|
// Save the passphrase
|
|
113
118
|
const passphrase = this.decrypt(
|
|
114
119
|
user.passphrase,
|
|
115
120
|
`${user.uid}-${this.settings.appId}`
|
|
116
121
|
);
|
|
117
122
|
if (passphrase) {
|
|
118
|
-
this.deviceId = user.
|
|
123
|
+
this.deviceId = user.clientDeviceId;
|
|
119
124
|
this.updatePassphrase(passphrase);
|
|
120
125
|
}
|
|
121
126
|
}
|
|
122
127
|
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
*
|
|
131
|
+
* @param user Current user
|
|
132
|
+
* @param core Core system API token data
|
|
133
|
+
* @param keep Keep in local storage or not
|
|
134
|
+
* @param dispatch User state dispatch
|
|
135
|
+
*/
|
|
136
|
+
userLoginEx(
|
|
137
|
+
user: U & ServiceUserToken,
|
|
138
|
+
core?: ApiRefreshTokenDto,
|
|
139
|
+
keep?: boolean,
|
|
140
|
+
dispatch?: boolean
|
|
141
|
+
) {
|
|
142
|
+
// User login
|
|
143
|
+
const { refreshToken } = user;
|
|
144
|
+
this.userLogin(user, refreshToken, keep, dispatch);
|
|
145
|
+
|
|
146
|
+
// Core system login
|
|
147
|
+
core ??= {
|
|
148
|
+
refreshToken,
|
|
149
|
+
accessToken: user.token,
|
|
150
|
+
tokenType: user.tokenScheme ?? "Bearer",
|
|
151
|
+
expiresIn: user.seconds
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
this.exchangeTokenAll(core, coreName);
|
|
155
|
+
}
|
|
123
156
|
}
|