@etsoo/appscript 1.5.46 → 1.5.47

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.
@@ -576,7 +576,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
576
576
  * @param props Props
577
577
  * @param callback Callback
578
578
  */
579
- refreshToken(props: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
579
+ refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
580
580
  /**
581
581
  * Setup callback
582
582
  */
@@ -618,7 +618,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
618
618
  signout(): Promise<void>;
619
619
  /**
620
620
  * Go to the login page
621
- * params Login parameters
621
+ * @params Login parameters
622
622
  */
623
623
  toLoginPage(params?: AppLoginParams): void;
624
624
  /**
@@ -1357,6 +1357,9 @@ class CoreApp {
1357
1357
  * @param callback Callback
1358
1358
  */
1359
1359
  async refreshToken(props, callback) {
1360
+ // Check props
1361
+ props ?? (props = {});
1362
+ props.token ?? (props.token = this.getCacheToken());
1360
1363
  // Call refresh token API
1361
1364
  let data = await new AuthApi_1.AuthApi(this).refreshToken(props);
1362
1365
  let r;
@@ -1592,7 +1595,7 @@ class CoreApp {
1592
1595
  }
1593
1596
  /**
1594
1597
  * Go to the login page
1595
- * params Login parameters
1598
+ * @params Login parameters
1596
1599
  */
1597
1600
  toLoginPage(params) {
1598
1601
  // Destruct
@@ -64,9 +64,9 @@ export interface RefreshTokenProps {
64
64
  /**
65
65
  * Refresh token
66
66
  */
67
- token: string;
67
+ token?: string;
68
68
  /**
69
- * API name
69
+ * API URL
70
70
  */
71
71
  api?: string;
72
72
  /**
@@ -524,7 +524,7 @@ export interface IApp {
524
524
  * @param callback Callback
525
525
  * @param api API
526
526
  */
527
- refreshToken(props: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
527
+ refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
528
528
  /**
529
529
  * Setup Api error handler
530
530
  * @param api Api
@@ -73,6 +73,15 @@ class AuthApi extends BaseApi_1.BaseApi {
73
73
  async refreshToken(props) {
74
74
  // Destruct
75
75
  const { api = 'Auth/RefreshToken', showLoading = false, token, tokenField = AuthApi.HeaderTokenField } = props ?? {};
76
+ // Check the token
77
+ if (!token) {
78
+ return {
79
+ ok: false,
80
+ type: 'noData',
81
+ field: 'token',
82
+ title: this.app.get('noData')
83
+ };
84
+ }
76
85
  // Reqest data
77
86
  const rq = {
78
87
  deviceId: this.app.deviceId
@@ -576,7 +576,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
576
576
  * @param props Props
577
577
  * @param callback Callback
578
578
  */
579
- refreshToken(props: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
579
+ refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
580
580
  /**
581
581
  * Setup callback
582
582
  */
@@ -618,7 +618,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
618
618
  signout(): Promise<void>;
619
619
  /**
620
620
  * Go to the login page
621
- * params Login parameters
621
+ * @params Login parameters
622
622
  */
623
623
  toLoginPage(params?: AppLoginParams): void;
624
624
  /**
@@ -1354,6 +1354,9 @@ export class CoreApp {
1354
1354
  * @param callback Callback
1355
1355
  */
1356
1356
  async refreshToken(props, callback) {
1357
+ // Check props
1358
+ props ?? (props = {});
1359
+ props.token ?? (props.token = this.getCacheToken());
1357
1360
  // Call refresh token API
1358
1361
  let data = await new AuthApi(this).refreshToken(props);
1359
1362
  let r;
@@ -1589,7 +1592,7 @@ export class CoreApp {
1589
1592
  }
1590
1593
  /**
1591
1594
  * Go to the login page
1592
- * params Login parameters
1595
+ * @params Login parameters
1593
1596
  */
1594
1597
  toLoginPage(params) {
1595
1598
  // Destruct
@@ -64,9 +64,9 @@ export interface RefreshTokenProps {
64
64
  /**
65
65
  * Refresh token
66
66
  */
67
- token: string;
67
+ token?: string;
68
68
  /**
69
- * API name
69
+ * API URL
70
70
  */
71
71
  api?: string;
72
72
  /**
@@ -524,7 +524,7 @@ export interface IApp {
524
524
  * @param callback Callback
525
525
  * @param api API
526
526
  */
527
- refreshToken(props: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
527
+ refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
528
528
  /**
529
529
  * Setup Api error handler
530
530
  * @param api Api
@@ -70,6 +70,15 @@ export class AuthApi extends BaseApi {
70
70
  async refreshToken(props) {
71
71
  // Destruct
72
72
  const { api = 'Auth/RefreshToken', showLoading = false, token, tokenField = AuthApi.HeaderTokenField } = props ?? {};
73
+ // Check the token
74
+ if (!token) {
75
+ return {
76
+ ok: false,
77
+ type: 'noData',
78
+ field: 'token',
79
+ title: this.app.get('noData')
80
+ };
81
+ }
73
82
  // Reqest data
74
83
  const rq = {
75
84
  deviceId: this.app.deviceId
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.46",
3
+ "version": "1.5.47",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -1888,9 +1888,13 @@ export abstract class CoreApp<
1888
1888
  * @param callback Callback
1889
1889
  */
1890
1890
  async refreshToken(
1891
- props: RefreshTokenProps,
1891
+ props?: RefreshTokenProps,
1892
1892
  callback?: (result?: boolean | IActionResult) => boolean | void
1893
1893
  ) {
1894
+ // Check props
1895
+ props ??= {};
1896
+ props.token ??= this.getCacheToken();
1897
+
1894
1898
  // Call refresh token API
1895
1899
  let data = await new AuthApi(this).refreshToken<IActionResult<U>>(
1896
1900
  props
@@ -2175,7 +2179,7 @@ export abstract class CoreApp<
2175
2179
 
2176
2180
  /**
2177
2181
  * Go to the login page
2178
- * params Login parameters
2182
+ * @params Login parameters
2179
2183
  */
2180
2184
  toLoginPage(params?: AppLoginParams) {
2181
2185
  // Destruct
package/src/app/IApp.ts CHANGED
@@ -90,10 +90,10 @@ export interface RefreshTokenProps {
90
90
  /**
91
91
  * Refresh token
92
92
  */
93
- token: string;
93
+ token?: string;
94
94
 
95
95
  /**
96
- * API name
96
+ * API URL
97
97
  */
98
98
  api?: string;
99
99
 
@@ -706,7 +706,7 @@ export interface IApp {
706
706
  * @param api API
707
707
  */
708
708
  refreshToken(
709
- props: RefreshTokenProps,
709
+ props?: RefreshTokenProps,
710
710
  callback?: (result?: boolean | IActionResult) => boolean | void
711
711
  ): Promise<void>;
712
712
 
@@ -106,6 +106,16 @@ export class AuthApi extends BaseApi {
106
106
  tokenField = AuthApi.HeaderTokenField
107
107
  } = props ?? {};
108
108
 
109
+ // Check the token
110
+ if (!token) {
111
+ return {
112
+ ok: false,
113
+ type: 'noData',
114
+ field: 'token',
115
+ title: this.app.get('noData')
116
+ };
117
+ }
118
+
109
119
  // Reqest data
110
120
  const rq: RefreshTokenRQ = {
111
121
  deviceId: this.app.deviceId