@etsoo/materialui 1.3.1 → 1.3.3

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,6 +1,7 @@
1
1
  import { IApi } from "@etsoo/restclient";
2
2
  import { ISmartERPUser } from "./ISmartERPUser";
3
3
  import { RefreshTokenRQ } from "@etsoo/appscript";
4
+ import { IServiceUser } from "./IServiceUser";
4
5
  /**
5
6
  * Service application API, Implement interface calls between different services
6
7
  * 服务程序接口,实现不同服务之间的接口调用
@@ -22,9 +23,9 @@ export interface IAppApi {
22
23
  * Authorize the API
23
24
  * @param user SmartERP user
24
25
  * @param refreshToken SmartERP user refresh token
25
- * @param token Access token
26
+ * @param serviceUser Service user
26
27
  */
27
- authorize(user: ISmartERPUser, refreshToken: string, token: string): void;
28
+ authorize(user: ISmartERPUser, refreshToken: string, serviceUser: IServiceUser): void;
28
29
  /**
29
30
  * Get refresh token data
30
31
  */
@@ -116,6 +116,7 @@ export class ServiceApp extends ReactApp {
116
116
  };
117
117
  // Success callback
118
118
  const success = async (result, failCallback) => {
119
+ var _a;
119
120
  // Token
120
121
  const refreshToken = this.getResponseToken(payload.response);
121
122
  if (refreshToken == null || result.data == null) {
@@ -128,7 +129,7 @@ export class ServiceApp extends ReactApp {
128
129
  // Use core system access token to service api to exchange service access token
129
130
  const api = appApi ? appApi.api : this.serviceApi;
130
131
  const serviceResult = await api.put("Auth/ExchangeToken", {
131
- token: this.encryptEnhanced(userData.token, this.settings.serviceId.toString())
132
+ token: this.encryptEnhanced(userData.token, ((_a = appApi === null || appApi === void 0 ? void 0 : appApi.serviceId) !== null && _a !== void 0 ? _a : this.settings.serviceId).toString())
132
133
  }, {
133
134
  showLoading,
134
135
  onError: (error) => {
@@ -158,7 +159,7 @@ export class ServiceApp extends ReactApp {
158
159
  this.setApiErrorHandler(appApi.api, true);
159
160
  }
160
161
  // Authorize external service application API
161
- appApi.authorize(userData, refreshToken, serviceResult.data.token);
162
+ appApi.authorize(userData, refreshToken, serviceResult.data);
162
163
  }
163
164
  else {
164
165
  // Authorize local service
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1,6 +1,7 @@
1
1
  import { IApi } from "@etsoo/restclient";
2
2
  import { ISmartERPUser } from "./ISmartERPUser";
3
3
  import { RefreshTokenRQ } from "@etsoo/appscript";
4
+ import { IServiceUser } from "./IServiceUser";
4
5
 
5
6
  /**
6
7
  * Service application API, Implement interface calls between different services
@@ -26,9 +27,13 @@ export interface IAppApi {
26
27
  * Authorize the API
27
28
  * @param user SmartERP user
28
29
  * @param refreshToken SmartERP user refresh token
29
- * @param token Access token
30
+ * @param serviceUser Service user
30
31
  */
31
- authorize(user: ISmartERPUser, refreshToken: string, token: string): void;
32
+ authorize(
33
+ user: ISmartERPUser,
34
+ refreshToken: string,
35
+ serviceUser: IServiceUser
36
+ ): void;
32
37
 
33
38
  /**
34
39
  * Get refresh token data
@@ -201,7 +201,7 @@ export class ServiceApp<
201
201
  {
202
202
  token: this.encryptEnhanced(
203
203
  userData.token,
204
- this.settings.serviceId.toString()
204
+ (appApi?.serviceId ?? this.settings.serviceId).toString()
205
205
  )
206
206
  },
207
207
  {
@@ -236,7 +236,7 @@ export class ServiceApp<
236
236
  }
237
237
 
238
238
  // Authorize external service application API
239
- appApi.authorize(userData, refreshToken, serviceResult.data.token);
239
+ appApi.authorize(userData, refreshToken, serviceResult.data);
240
240
  } else {
241
241
  // Authorize local service
242
242
  this.userLoginEx(userData, refreshToken, serviceResult.data);