@etsoo/appscript 1.5.17 → 1.5.19

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.
@@ -83,7 +83,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
83
83
  get region(): string;
84
84
  private _deviceId;
85
85
  /**
86
- * Country or region, like CN
86
+ * Device id, randome string from ServiceBase.InitCallAsync
87
87
  */
88
88
  get deviceId(): string;
89
89
  /**
@@ -550,7 +550,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
550
550
  * Refresh token
551
551
  * @param props Props
552
552
  */
553
- refreshToken<D extends object = {}>(props?: RefreshTokenProps<D>): Promise<boolean>;
553
+ refreshToken(props?: RefreshTokenProps): Promise<boolean>;
554
554
  /**
555
555
  * Setup callback
556
556
  */
@@ -36,7 +36,7 @@ class CoreApp {
36
36
  return this._region;
37
37
  }
38
38
  /**
39
- * Country or region, like CN
39
+ * Device id, randome string from ServiceBase.InitCallAsync
40
40
  */
41
41
  get deviceId() {
42
42
  return this._deviceId;
@@ -1391,7 +1391,9 @@ class CoreApp {
1391
1391
  userLogin(user, refreshToken, keep) {
1392
1392
  this.userData = user;
1393
1393
  // Cache the encrypted serverside device id
1394
- this.storage.setData(this.fields.serversideDeviceId, user.deviceId);
1394
+ if (user.deviceId) {
1395
+ this.storage.setData(this.fields.serversideDeviceId, user.deviceId);
1396
+ }
1395
1397
  if (keep) {
1396
1398
  this.authorize(user.token, user.tokenScheme, refreshToken);
1397
1399
  }
@@ -41,19 +41,11 @@ export type FormatResultCustomCallback = ((data: FormatResultCustom) => string |
41
41
  /**
42
42
  * Refresh token props
43
43
  */
44
- export interface RefreshTokenProps<D extends object> {
44
+ export interface RefreshTokenProps {
45
45
  /**
46
46
  * Callback
47
47
  */
48
48
  callback?: (result: RefreshTokenResult, successData?: string) => void;
49
- /**
50
- * Data to pass
51
- */
52
- data?: D;
53
- /**
54
- * Support relogin or not
55
- */
56
- relogin?: boolean;
57
49
  /**
58
50
  * Show loading bar or not
59
51
  */
@@ -478,7 +470,7 @@ export interface IApp {
478
470
  * Refresh token
479
471
  * @param props Props
480
472
  */
481
- refreshToken<D extends object = {}>(props?: RefreshTokenProps<D>): Promise<boolean>;
473
+ refreshToken(props?: RefreshTokenProps): Promise<boolean>;
482
474
  /**
483
475
  * Setup Api error handler
484
476
  * @param api Api
@@ -6,16 +6,4 @@ export type RefreshTokenRQ = {
6
6
  * Device id
7
7
  */
8
8
  deviceId: string;
9
- /**
10
- * Country or region
11
- */
12
- region: string;
13
- /**
14
- * Login password
15
- */
16
- pwd?: string;
17
- /**
18
- * Time zone
19
- */
20
- timezone?: string;
21
9
  };
@@ -4,9 +4,9 @@ import { IState } from './State';
4
4
  */
5
5
  export interface IUserData {
6
6
  /**
7
- * Serverside device id encrypted
7
+ * Serverside device id encrypted, not the same device id of the app
8
8
  */
9
- readonly deviceId: string;
9
+ readonly deviceId?: string;
10
10
  /**
11
11
  * User name
12
12
  * 用户姓名
@@ -83,7 +83,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
83
83
  get region(): string;
84
84
  private _deviceId;
85
85
  /**
86
- * Country or region, like CN
86
+ * Device id, randome string from ServiceBase.InitCallAsync
87
87
  */
88
88
  get deviceId(): string;
89
89
  /**
@@ -550,7 +550,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
550
550
  * Refresh token
551
551
  * @param props Props
552
552
  */
553
- refreshToken<D extends object = {}>(props?: RefreshTokenProps<D>): Promise<boolean>;
553
+ refreshToken(props?: RefreshTokenProps): Promise<boolean>;
554
554
  /**
555
555
  * Setup callback
556
556
  */
@@ -33,7 +33,7 @@ export class CoreApp {
33
33
  return this._region;
34
34
  }
35
35
  /**
36
- * Country or region, like CN
36
+ * Device id, randome string from ServiceBase.InitCallAsync
37
37
  */
38
38
  get deviceId() {
39
39
  return this._deviceId;
@@ -1388,7 +1388,9 @@ export class CoreApp {
1388
1388
  userLogin(user, refreshToken, keep) {
1389
1389
  this.userData = user;
1390
1390
  // Cache the encrypted serverside device id
1391
- this.storage.setData(this.fields.serversideDeviceId, user.deviceId);
1391
+ if (user.deviceId) {
1392
+ this.storage.setData(this.fields.serversideDeviceId, user.deviceId);
1393
+ }
1392
1394
  if (keep) {
1393
1395
  this.authorize(user.token, user.tokenScheme, refreshToken);
1394
1396
  }
@@ -41,19 +41,11 @@ export type FormatResultCustomCallback = ((data: FormatResultCustom) => string |
41
41
  /**
42
42
  * Refresh token props
43
43
  */
44
- export interface RefreshTokenProps<D extends object> {
44
+ export interface RefreshTokenProps {
45
45
  /**
46
46
  * Callback
47
47
  */
48
48
  callback?: (result: RefreshTokenResult, successData?: string) => void;
49
- /**
50
- * Data to pass
51
- */
52
- data?: D;
53
- /**
54
- * Support relogin or not
55
- */
56
- relogin?: boolean;
57
49
  /**
58
50
  * Show loading bar or not
59
51
  */
@@ -478,7 +470,7 @@ export interface IApp {
478
470
  * Refresh token
479
471
  * @param props Props
480
472
  */
481
- refreshToken<D extends object = {}>(props?: RefreshTokenProps<D>): Promise<boolean>;
473
+ refreshToken(props?: RefreshTokenProps): Promise<boolean>;
482
474
  /**
483
475
  * Setup Api error handler
484
476
  * @param api Api
@@ -6,16 +6,4 @@ export type RefreshTokenRQ = {
6
6
  * Device id
7
7
  */
8
8
  deviceId: string;
9
- /**
10
- * Country or region
11
- */
12
- region: string;
13
- /**
14
- * Login password
15
- */
16
- pwd?: string;
17
- /**
18
- * Time zone
19
- */
20
- timezone?: string;
21
9
  };
@@ -4,9 +4,9 @@ import { IState } from './State';
4
4
  */
5
5
  export interface IUserData {
6
6
  /**
7
- * Serverside device id encrypted
7
+ * Serverside device id encrypted, not the same device id of the app
8
8
  */
9
- readonly deviceId: string;
9
+ readonly deviceId?: string;
10
10
  /**
11
11
  * User name
12
12
  * 用户姓名
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.17",
3
+ "version": "1.5.19",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -155,7 +155,7 @@ export abstract class CoreApp<
155
155
 
156
156
  private _deviceId: string;
157
157
  /**
158
- * Country or region, like CN
158
+ * Device id, randome string from ServiceBase.InitCallAsync
159
159
  */
160
160
  get deviceId() {
161
161
  return this._deviceId;
@@ -1813,7 +1813,7 @@ export abstract class CoreApp<
1813
1813
  * Refresh token
1814
1814
  * @param props Props
1815
1815
  */
1816
- async refreshToken<D extends object = {}>(props?: RefreshTokenProps<D>) {
1816
+ async refreshToken(props?: RefreshTokenProps) {
1817
1817
  if (props && props.callback) props.callback(true, undefined);
1818
1818
  return true;
1819
1819
  }
@@ -1891,7 +1891,9 @@ export abstract class CoreApp<
1891
1891
  this.userData = user;
1892
1892
 
1893
1893
  // Cache the encrypted serverside device id
1894
- this.storage.setData(this.fields.serversideDeviceId, user.deviceId);
1894
+ if (user.deviceId) {
1895
+ this.storage.setData(this.fields.serversideDeviceId, user.deviceId);
1896
+ }
1895
1897
 
1896
1898
  if (keep) {
1897
1899
  this.authorize(user.token, user.tokenScheme, refreshToken);
package/src/app/IApp.ts CHANGED
@@ -68,22 +68,12 @@ export type FormatResultCustomCallback =
68
68
  /**
69
69
  * Refresh token props
70
70
  */
71
- export interface RefreshTokenProps<D extends object> {
71
+ export interface RefreshTokenProps {
72
72
  /**
73
73
  * Callback
74
74
  */
75
75
  callback?: (result: RefreshTokenResult, successData?: string) => void;
76
76
 
77
- /**
78
- * Data to pass
79
- */
80
- data?: D;
81
-
82
- /**
83
- * Support relogin or not
84
- */
85
- relogin?: boolean;
86
-
87
77
  /**
88
78
  * Show loading bar or not
89
79
  */
@@ -650,9 +640,7 @@ export interface IApp {
650
640
  * Refresh token
651
641
  * @param props Props
652
642
  */
653
- refreshToken<D extends object = {}>(
654
- props?: RefreshTokenProps<D>
655
- ): Promise<boolean>;
643
+ refreshToken(props?: RefreshTokenProps): Promise<boolean>;
656
644
 
657
645
  /**
658
646
  * Setup Api error handler
@@ -6,19 +6,4 @@ export type RefreshTokenRQ = {
6
6
  * Device id
7
7
  */
8
8
  deviceId: string;
9
-
10
- /**
11
- * Country or region
12
- */
13
- region: string;
14
-
15
- /**
16
- * Login password
17
- */
18
- pwd?: string;
19
-
20
- /**
21
- * Time zone
22
- */
23
- timezone?: string;
24
9
  };
package/src/state/User.ts CHANGED
@@ -5,9 +5,9 @@ import { IState } from './State';
5
5
  */
6
6
  export interface IUserData {
7
7
  /**
8
- * Serverside device id encrypted
8
+ * Serverside device id encrypted, not the same device id of the app
9
9
  */
10
- readonly deviceId: string;
10
+ readonly deviceId?: string;
11
11
 
12
12
  /**
13
13
  * User name