@etsoo/appscript 1.5.95 → 1.5.97
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/__tests__/app/CoreApp.ts +2 -1
- package/__tests__/app/TestApp.ts +0 -3
- package/__tests__/tsconfig.json +2 -2
- package/lib/cjs/api/AuthApi.d.ts +2 -2
- package/lib/cjs/api/AuthApi.js +11 -3
- package/lib/cjs/api/rq/ApiRefreshTokenRQ.d.ts +3 -6
- package/lib/cjs/api/rq/LoginIdRQ.d.ts +4 -0
- package/lib/cjs/api/rq/LoginRQ.d.ts +4 -4
- package/lib/cjs/api/rq/RefreshTokenRQ.d.ts +4 -0
- package/lib/cjs/api/rq/ResetPasswordRQ.d.ts +8 -0
- package/lib/cjs/api/rq/TokenRQ.d.ts +4 -0
- package/lib/cjs/app/AppSettings.d.ts +1 -1
- package/lib/cjs/app/CoreApp.d.ts +1 -1
- package/lib/cjs/app/CoreApp.js +11 -8
- package/lib/cjs/app/IApp.d.ts +5 -1
- package/lib/mjs/api/AuthApi.d.ts +2 -2
- package/lib/mjs/api/AuthApi.js +11 -3
- package/lib/mjs/api/rq/ApiRefreshTokenRQ.d.ts +3 -6
- package/lib/mjs/api/rq/LoginIdRQ.d.ts +4 -0
- package/lib/mjs/api/rq/LoginRQ.d.ts +4 -4
- package/lib/mjs/api/rq/RefreshTokenRQ.d.ts +4 -0
- package/lib/mjs/api/rq/ResetPasswordRQ.d.ts +8 -0
- package/lib/mjs/api/rq/TokenRQ.d.ts +4 -0
- package/lib/mjs/app/AppSettings.d.ts +1 -1
- package/lib/mjs/app/CoreApp.d.ts +1 -1
- package/lib/mjs/app/CoreApp.js +11 -8
- package/lib/mjs/app/IApp.d.ts +5 -1
- package/package.json +4 -4
- package/src/api/AuthApi.ts +13 -5
- package/src/api/rq/ApiRefreshTokenRQ.ts +4 -7
- package/src/api/rq/LoginIdRQ.ts +5 -0
- package/src/api/rq/LoginRQ.ts +5 -5
- package/src/api/rq/RefreshTokenRQ.ts +5 -0
- package/src/api/rq/ResetPasswordRQ.ts +10 -0
- package/src/api/rq/TokenRQ.ts +5 -0
- package/src/app/AppSettings.ts +1 -1
- package/src/app/CoreApp.ts +15 -10
- package/src/app/IApp.ts +6 -1
package/__tests__/app/CoreApp.ts
CHANGED
|
@@ -13,7 +13,8 @@ function EnhanceApp<TBase extends DataTypes.MConstructor<TestApp>>(
|
|
|
13
13
|
|
|
14
14
|
const appClass = EnhanceApp(TestApp);
|
|
15
15
|
const app = new appClass();
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
await app.changeCulture(app.settings.cultures[0]);
|
|
17
18
|
|
|
18
19
|
test("Test for domain replacement", () => {
|
|
19
20
|
expect(app.settings.endpoint).toBe("http://localhost:9000/api/");
|
package/__tests__/app/TestApp.ts
CHANGED
|
@@ -104,9 +104,6 @@ export class TestApp extends CoreApp<
|
|
|
104
104
|
// Supported regions
|
|
105
105
|
regions: supportedRegions,
|
|
106
106
|
|
|
107
|
-
// Browser's time zone
|
|
108
|
-
timeZone: Utils.getTimeZone(),
|
|
109
|
-
|
|
110
107
|
// Current country or region
|
|
111
108
|
currentRegion: AddressUtils.getRegion(
|
|
112
109
|
supportedRegions,
|
package/__tests__/tsconfig.json
CHANGED
package/lib/cjs/api/AuthApi.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { TokenRQ } from "./rq/TokenRQ";
|
|
|
8
8
|
import { ApiRefreshTokenDto } from "./dto/ApiRefreshTokenDto";
|
|
9
9
|
import { GetLogInUrlRQ } from "./rq/GetLogInUrlRQ";
|
|
10
10
|
import { LoginRQ } from "./rq/LoginRQ";
|
|
11
|
-
import {
|
|
11
|
+
import { ResetPasswordInputRQ } from "./rq/ResetPasswordRQ";
|
|
12
12
|
import { SignoutRQ } from "./rq/SignoutRQ";
|
|
13
13
|
import { SwitchOrgRQ } from "./rq/SwitchOrgRQ";
|
|
14
14
|
import { AuthRequest } from "./rq/AuthRequest";
|
|
@@ -91,7 +91,7 @@ export declare class AuthApi extends BaseApi {
|
|
|
91
91
|
* @param payload Payload
|
|
92
92
|
* @returns Result
|
|
93
93
|
*/
|
|
94
|
-
resetPassword(rq:
|
|
94
|
+
resetPassword(rq: ResetPasswordInputRQ, payload?: ResultPayload): Promise<IActionResult<{}> | undefined>;
|
|
95
95
|
/**
|
|
96
96
|
* Signout
|
|
97
97
|
* @param rq Request data
|
package/lib/cjs/api/AuthApi.js
CHANGED
|
@@ -106,7 +106,8 @@ class AuthApi extends BaseApi_1.BaseApi {
|
|
|
106
106
|
const rq = {
|
|
107
107
|
id,
|
|
108
108
|
deviceId,
|
|
109
|
-
region
|
|
109
|
+
region,
|
|
110
|
+
timeZone: this.app.getTimeZone()
|
|
110
111
|
};
|
|
111
112
|
return this.api.post("Auth/LoginId", rq, payload);
|
|
112
113
|
}
|
|
@@ -129,7 +130,8 @@ class AuthApi extends BaseApi_1.BaseApi {
|
|
|
129
130
|
}
|
|
130
131
|
// Reqest data
|
|
131
132
|
const rq = {
|
|
132
|
-
deviceId: this.app.deviceId
|
|
133
|
+
deviceId: this.app.deviceId,
|
|
134
|
+
timeZone: this.app.getTimeZone()
|
|
133
135
|
};
|
|
134
136
|
// Payload
|
|
135
137
|
const payload = {
|
|
@@ -165,7 +167,13 @@ class AuthApi extends BaseApi_1.BaseApi {
|
|
|
165
167
|
* @returns Result
|
|
166
168
|
*/
|
|
167
169
|
resetPassword(rq, payload) {
|
|
168
|
-
|
|
170
|
+
const data = {
|
|
171
|
+
...rq,
|
|
172
|
+
deviceId: this.app.deviceId,
|
|
173
|
+
region: this.app.region,
|
|
174
|
+
timezone: this.app.getTimeZone()
|
|
175
|
+
};
|
|
176
|
+
return this.api.put("Auth/ResetPassword", data, payload);
|
|
169
177
|
}
|
|
170
178
|
/**
|
|
171
179
|
* Signout
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
+
import { TokenRQ } from "./TokenRQ";
|
|
1
2
|
/**
|
|
2
3
|
* API Refresh Token Request data
|
|
3
4
|
*/
|
|
4
|
-
export type ApiRefreshTokenRQ = {
|
|
5
|
-
/**
|
|
6
|
-
* Refresh token
|
|
7
|
-
*/
|
|
8
|
-
token: string;
|
|
5
|
+
export type ApiRefreshTokenRQ = TokenRQ & {
|
|
9
6
|
/**
|
|
10
7
|
* Application ID, 0 for core system
|
|
11
8
|
*/
|
|
12
|
-
appId
|
|
9
|
+
appId: number;
|
|
13
10
|
};
|
|
@@ -12,12 +12,12 @@ export type LoginRQ = LoginIdRQ & {
|
|
|
12
12
|
* Organization
|
|
13
13
|
*/
|
|
14
14
|
org?: number;
|
|
15
|
-
/**
|
|
16
|
-
* Time zone
|
|
17
|
-
*/
|
|
18
|
-
timezone?: string;
|
|
19
15
|
/**
|
|
20
16
|
* Authorization request data
|
|
21
17
|
*/
|
|
22
18
|
auth?: AuthRequest;
|
|
23
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Login input request data
|
|
22
|
+
*/
|
|
23
|
+
export type LoginInputRQ = Pick<LoginRQ, "id" | "pwd" | "org" | "auth">;
|
|
@@ -15,4 +15,12 @@ export type ResetPasswordRQ = {
|
|
|
15
15
|
* Country or region
|
|
16
16
|
*/
|
|
17
17
|
region: string;
|
|
18
|
+
/**
|
|
19
|
+
* Time zone
|
|
20
|
+
*/
|
|
21
|
+
timezone: string;
|
|
18
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Reset password input request data
|
|
25
|
+
*/
|
|
26
|
+
export type ResetPasswordInputRQ = Pick<ResetPasswordRQ, "id" | "password">;
|
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -543,7 +543,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
543
543
|
* Get time zone
|
|
544
544
|
* @returns Time zone
|
|
545
545
|
*/
|
|
546
|
-
getTimeZone(): string
|
|
546
|
+
getTimeZone(): string;
|
|
547
547
|
/**
|
|
548
548
|
* Hash message, SHA3 or HmacSHA512, 512 as Base64
|
|
549
549
|
* https://cryptojs.gitbook.io/docs/
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -177,7 +177,7 @@ class CoreApp {
|
|
|
177
177
|
const refresh = async (api, rq) => {
|
|
178
178
|
if (this.lastCalled) {
|
|
179
179
|
// Call refreshToken to update access token
|
|
180
|
-
await this.refreshToken({ token: rq.token, showLoading: false }, (result) => {
|
|
180
|
+
await this.refreshToken({ token: rq.token, timeZone: rq.timeZone, showLoading: false }, (result) => {
|
|
181
181
|
if (result === true)
|
|
182
182
|
return;
|
|
183
183
|
console.log(`CoreApp.${this.name}.RefreshToken`, result);
|
|
@@ -1021,8 +1021,8 @@ class CoreApp {
|
|
|
1021
1021
|
* @returns string
|
|
1022
1022
|
*/
|
|
1023
1023
|
formatDate(input, options, timeZone) {
|
|
1024
|
-
const { currentCulture
|
|
1025
|
-
timeZone ?? (timeZone =
|
|
1024
|
+
const { currentCulture } = this.settings;
|
|
1025
|
+
timeZone ?? (timeZone = this.getTimeZone());
|
|
1026
1026
|
return shared_1.DateUtils.format(input, currentCulture.name, options, timeZone);
|
|
1027
1027
|
}
|
|
1028
1028
|
/**
|
|
@@ -1295,8 +1295,7 @@ class CoreApp {
|
|
|
1295
1295
|
* @returns Time zone
|
|
1296
1296
|
*/
|
|
1297
1297
|
getTimeZone() {
|
|
1298
|
-
|
|
1299
|
-
return this.settings.timeZone ?? this.ipData?.timezone;
|
|
1298
|
+
return this.settings.timeZone ?? shared_1.Utils.getTimeZone(this.ipData?.timezone);
|
|
1300
1299
|
}
|
|
1301
1300
|
/**
|
|
1302
1301
|
* Hash message, SHA3 or HmacSHA512, 512 as Base64
|
|
@@ -1421,7 +1420,7 @@ class CoreApp {
|
|
|
1421
1420
|
*/
|
|
1422
1421
|
async refreshToken(props, callback) {
|
|
1423
1422
|
// Check props
|
|
1424
|
-
props ?? (props = {});
|
|
1423
|
+
props ?? (props = { timeZone: this.getTimeZone() });
|
|
1425
1424
|
props.token ?? (props.token = this.getCacheToken());
|
|
1426
1425
|
// Call refresh token API
|
|
1427
1426
|
let data = await this.createAuthApi().refreshToken(props);
|
|
@@ -1520,7 +1519,7 @@ class CoreApp {
|
|
|
1520
1519
|
throw new Error("System API is not allowed to exchange token");
|
|
1521
1520
|
}
|
|
1522
1521
|
// Call the API quietly, no loading bar and no error popup
|
|
1523
|
-
const data = await this.createAuthApi().exchangeToken({ token }, {
|
|
1522
|
+
const data = await this.createAuthApi().exchangeToken({ token, timeZone: this.getTimeZone() }, {
|
|
1524
1523
|
showLoading: false,
|
|
1525
1524
|
onError: (error) => {
|
|
1526
1525
|
console.error(`CoreApp.${api.name}.ExchangeToken error`, error);
|
|
@@ -1609,6 +1608,10 @@ class CoreApp {
|
|
|
1609
1608
|
// Exit when not authorized
|
|
1610
1609
|
if (!this.authorized)
|
|
1611
1610
|
return;
|
|
1611
|
+
// App id
|
|
1612
|
+
const appId = this.settings.appId;
|
|
1613
|
+
// Timezone
|
|
1614
|
+
const timeZone = this.getTimeZone();
|
|
1612
1615
|
// APIs
|
|
1613
1616
|
for (const name in this.apis) {
|
|
1614
1617
|
// Get the API
|
|
@@ -1621,7 +1624,7 @@ class CoreApp {
|
|
|
1621
1624
|
// Ready to trigger
|
|
1622
1625
|
if (api[2] === 0) {
|
|
1623
1626
|
// Refresh token
|
|
1624
|
-
api[3](api[0], { token: api[4] }).then((data) => {
|
|
1627
|
+
api[3](api[0], { appId, token: api[4], timeZone }).then((data) => {
|
|
1625
1628
|
if (data == null) {
|
|
1626
1629
|
// Failed, try it again in 2 seconds
|
|
1627
1630
|
api[2] = 2;
|
package/lib/cjs/app/IApp.d.ts
CHANGED
|
@@ -85,6 +85,10 @@ export interface RefreshTokenProps {
|
|
|
85
85
|
* Refresh token
|
|
86
86
|
*/
|
|
87
87
|
token?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Time zone
|
|
90
|
+
*/
|
|
91
|
+
timeZone: string;
|
|
88
92
|
/**
|
|
89
93
|
* API URL
|
|
90
94
|
*/
|
|
@@ -489,7 +493,7 @@ export interface IApp {
|
|
|
489
493
|
* Get time zone
|
|
490
494
|
* @returns Time zone
|
|
491
495
|
*/
|
|
492
|
-
getTimeZone(): string
|
|
496
|
+
getTimeZone(): string;
|
|
493
497
|
/**
|
|
494
498
|
* Hash message, SHA3 or HmacSHA512, 512 as Base64
|
|
495
499
|
* https://cryptojs.gitbook.io/docs/
|
package/lib/mjs/api/AuthApi.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { TokenRQ } from "./rq/TokenRQ";
|
|
|
8
8
|
import { ApiRefreshTokenDto } from "./dto/ApiRefreshTokenDto";
|
|
9
9
|
import { GetLogInUrlRQ } from "./rq/GetLogInUrlRQ";
|
|
10
10
|
import { LoginRQ } from "./rq/LoginRQ";
|
|
11
|
-
import {
|
|
11
|
+
import { ResetPasswordInputRQ } from "./rq/ResetPasswordRQ";
|
|
12
12
|
import { SignoutRQ } from "./rq/SignoutRQ";
|
|
13
13
|
import { SwitchOrgRQ } from "./rq/SwitchOrgRQ";
|
|
14
14
|
import { AuthRequest } from "./rq/AuthRequest";
|
|
@@ -91,7 +91,7 @@ export declare class AuthApi extends BaseApi {
|
|
|
91
91
|
* @param payload Payload
|
|
92
92
|
* @returns Result
|
|
93
93
|
*/
|
|
94
|
-
resetPassword(rq:
|
|
94
|
+
resetPassword(rq: ResetPasswordInputRQ, payload?: ResultPayload): Promise<IActionResult<{}> | undefined>;
|
|
95
95
|
/**
|
|
96
96
|
* Signout
|
|
97
97
|
* @param rq Request data
|
package/lib/mjs/api/AuthApi.js
CHANGED
|
@@ -103,7 +103,8 @@ export class AuthApi extends BaseApi {
|
|
|
103
103
|
const rq = {
|
|
104
104
|
id,
|
|
105
105
|
deviceId,
|
|
106
|
-
region
|
|
106
|
+
region,
|
|
107
|
+
timeZone: this.app.getTimeZone()
|
|
107
108
|
};
|
|
108
109
|
return this.api.post("Auth/LoginId", rq, payload);
|
|
109
110
|
}
|
|
@@ -126,7 +127,8 @@ export class AuthApi extends BaseApi {
|
|
|
126
127
|
}
|
|
127
128
|
// Reqest data
|
|
128
129
|
const rq = {
|
|
129
|
-
deviceId: this.app.deviceId
|
|
130
|
+
deviceId: this.app.deviceId,
|
|
131
|
+
timeZone: this.app.getTimeZone()
|
|
130
132
|
};
|
|
131
133
|
// Payload
|
|
132
134
|
const payload = {
|
|
@@ -162,7 +164,13 @@ export class AuthApi extends BaseApi {
|
|
|
162
164
|
* @returns Result
|
|
163
165
|
*/
|
|
164
166
|
resetPassword(rq, payload) {
|
|
165
|
-
|
|
167
|
+
const data = {
|
|
168
|
+
...rq,
|
|
169
|
+
deviceId: this.app.deviceId,
|
|
170
|
+
region: this.app.region,
|
|
171
|
+
timezone: this.app.getTimeZone()
|
|
172
|
+
};
|
|
173
|
+
return this.api.put("Auth/ResetPassword", data, payload);
|
|
166
174
|
}
|
|
167
175
|
/**
|
|
168
176
|
* Signout
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
+
import { TokenRQ } from "./TokenRQ";
|
|
1
2
|
/**
|
|
2
3
|
* API Refresh Token Request data
|
|
3
4
|
*/
|
|
4
|
-
export type ApiRefreshTokenRQ = {
|
|
5
|
-
/**
|
|
6
|
-
* Refresh token
|
|
7
|
-
*/
|
|
8
|
-
token: string;
|
|
5
|
+
export type ApiRefreshTokenRQ = TokenRQ & {
|
|
9
6
|
/**
|
|
10
7
|
* Application ID, 0 for core system
|
|
11
8
|
*/
|
|
12
|
-
appId
|
|
9
|
+
appId: number;
|
|
13
10
|
};
|
|
@@ -12,12 +12,12 @@ export type LoginRQ = LoginIdRQ & {
|
|
|
12
12
|
* Organization
|
|
13
13
|
*/
|
|
14
14
|
org?: number;
|
|
15
|
-
/**
|
|
16
|
-
* Time zone
|
|
17
|
-
*/
|
|
18
|
-
timezone?: string;
|
|
19
15
|
/**
|
|
20
16
|
* Authorization request data
|
|
21
17
|
*/
|
|
22
18
|
auth?: AuthRequest;
|
|
23
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Login input request data
|
|
22
|
+
*/
|
|
23
|
+
export type LoginInputRQ = Pick<LoginRQ, "id" | "pwd" | "org" | "auth">;
|
|
@@ -15,4 +15,12 @@ export type ResetPasswordRQ = {
|
|
|
15
15
|
* Country or region
|
|
16
16
|
*/
|
|
17
17
|
region: string;
|
|
18
|
+
/**
|
|
19
|
+
* Time zone
|
|
20
|
+
*/
|
|
21
|
+
timezone: string;
|
|
18
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Reset password input request data
|
|
25
|
+
*/
|
|
26
|
+
export type ResetPasswordInputRQ = Pick<ResetPasswordRQ, "id" | "password">;
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -543,7 +543,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
543
543
|
* Get time zone
|
|
544
544
|
* @returns Time zone
|
|
545
545
|
*/
|
|
546
|
-
getTimeZone(): string
|
|
546
|
+
getTimeZone(): string;
|
|
547
547
|
/**
|
|
548
548
|
* Hash message, SHA3 or HmacSHA512, 512 as Base64
|
|
549
549
|
* https://cryptojs.gitbook.io/docs/
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -174,7 +174,7 @@ export class CoreApp {
|
|
|
174
174
|
const refresh = async (api, rq) => {
|
|
175
175
|
if (this.lastCalled) {
|
|
176
176
|
// Call refreshToken to update access token
|
|
177
|
-
await this.refreshToken({ token: rq.token, showLoading: false }, (result) => {
|
|
177
|
+
await this.refreshToken({ token: rq.token, timeZone: rq.timeZone, showLoading: false }, (result) => {
|
|
178
178
|
if (result === true)
|
|
179
179
|
return;
|
|
180
180
|
console.log(`CoreApp.${this.name}.RefreshToken`, result);
|
|
@@ -1018,8 +1018,8 @@ export class CoreApp {
|
|
|
1018
1018
|
* @returns string
|
|
1019
1019
|
*/
|
|
1020
1020
|
formatDate(input, options, timeZone) {
|
|
1021
|
-
const { currentCulture
|
|
1022
|
-
timeZone ?? (timeZone =
|
|
1021
|
+
const { currentCulture } = this.settings;
|
|
1022
|
+
timeZone ?? (timeZone = this.getTimeZone());
|
|
1023
1023
|
return DateUtils.format(input, currentCulture.name, options, timeZone);
|
|
1024
1024
|
}
|
|
1025
1025
|
/**
|
|
@@ -1292,8 +1292,7 @@ export class CoreApp {
|
|
|
1292
1292
|
* @returns Time zone
|
|
1293
1293
|
*/
|
|
1294
1294
|
getTimeZone() {
|
|
1295
|
-
|
|
1296
|
-
return this.settings.timeZone ?? this.ipData?.timezone;
|
|
1295
|
+
return this.settings.timeZone ?? Utils.getTimeZone(this.ipData?.timezone);
|
|
1297
1296
|
}
|
|
1298
1297
|
/**
|
|
1299
1298
|
* Hash message, SHA3 or HmacSHA512, 512 as Base64
|
|
@@ -1418,7 +1417,7 @@ export class CoreApp {
|
|
|
1418
1417
|
*/
|
|
1419
1418
|
async refreshToken(props, callback) {
|
|
1420
1419
|
// Check props
|
|
1421
|
-
props ?? (props = {});
|
|
1420
|
+
props ?? (props = { timeZone: this.getTimeZone() });
|
|
1422
1421
|
props.token ?? (props.token = this.getCacheToken());
|
|
1423
1422
|
// Call refresh token API
|
|
1424
1423
|
let data = await this.createAuthApi().refreshToken(props);
|
|
@@ -1517,7 +1516,7 @@ export class CoreApp {
|
|
|
1517
1516
|
throw new Error("System API is not allowed to exchange token");
|
|
1518
1517
|
}
|
|
1519
1518
|
// Call the API quietly, no loading bar and no error popup
|
|
1520
|
-
const data = await this.createAuthApi().exchangeToken({ token }, {
|
|
1519
|
+
const data = await this.createAuthApi().exchangeToken({ token, timeZone: this.getTimeZone() }, {
|
|
1521
1520
|
showLoading: false,
|
|
1522
1521
|
onError: (error) => {
|
|
1523
1522
|
console.error(`CoreApp.${api.name}.ExchangeToken error`, error);
|
|
@@ -1606,6 +1605,10 @@ export class CoreApp {
|
|
|
1606
1605
|
// Exit when not authorized
|
|
1607
1606
|
if (!this.authorized)
|
|
1608
1607
|
return;
|
|
1608
|
+
// App id
|
|
1609
|
+
const appId = this.settings.appId;
|
|
1610
|
+
// Timezone
|
|
1611
|
+
const timeZone = this.getTimeZone();
|
|
1609
1612
|
// APIs
|
|
1610
1613
|
for (const name in this.apis) {
|
|
1611
1614
|
// Get the API
|
|
@@ -1618,7 +1621,7 @@ export class CoreApp {
|
|
|
1618
1621
|
// Ready to trigger
|
|
1619
1622
|
if (api[2] === 0) {
|
|
1620
1623
|
// Refresh token
|
|
1621
|
-
api[3](api[0], { token: api[4] }).then((data) => {
|
|
1624
|
+
api[3](api[0], { appId, token: api[4], timeZone }).then((data) => {
|
|
1622
1625
|
if (data == null) {
|
|
1623
1626
|
// Failed, try it again in 2 seconds
|
|
1624
1627
|
api[2] = 2;
|
package/lib/mjs/app/IApp.d.ts
CHANGED
|
@@ -85,6 +85,10 @@ export interface RefreshTokenProps {
|
|
|
85
85
|
* Refresh token
|
|
86
86
|
*/
|
|
87
87
|
token?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Time zone
|
|
90
|
+
*/
|
|
91
|
+
timeZone: string;
|
|
88
92
|
/**
|
|
89
93
|
* API URL
|
|
90
94
|
*/
|
|
@@ -489,7 +493,7 @@ export interface IApp {
|
|
|
489
493
|
* Get time zone
|
|
490
494
|
* @returns Time zone
|
|
491
495
|
*/
|
|
492
|
-
getTimeZone(): string
|
|
496
|
+
getTimeZone(): string;
|
|
493
497
|
/**
|
|
494
498
|
* Hash message, SHA3 or HmacSHA512, 512 as Base64
|
|
495
499
|
* https://cryptojs.gitbook.io/docs/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.97",
|
|
4
4
|
"description": "Applications shared TypeScript framework",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/ETSOO/AppScript#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@etsoo/notificationbase": "^1.1.
|
|
39
|
-
"@etsoo/restclient": "^1.1.
|
|
40
|
-
"@etsoo/shared": "^1.2.
|
|
38
|
+
"@etsoo/notificationbase": "^1.1.58",
|
|
39
|
+
"@etsoo/restclient": "^1.1.23",
|
|
40
|
+
"@etsoo/shared": "^1.2.60",
|
|
41
41
|
"crypto-js": "^4.2.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
package/src/api/AuthApi.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { GetLogInUrlRQ } from "./rq/GetLogInUrlRQ";
|
|
|
10
10
|
import { LoginRQ } from "./rq/LoginRQ";
|
|
11
11
|
import { LoginIdRQ } from "./rq/LoginIdRQ";
|
|
12
12
|
import { RefreshTokenRQ } from "./rq/RefreshTokenRQ";
|
|
13
|
-
import { ResetPasswordRQ } from "./rq/ResetPasswordRQ";
|
|
13
|
+
import { ResetPasswordInputRQ, ResetPasswordRQ } from "./rq/ResetPasswordRQ";
|
|
14
14
|
import { SignoutRQ } from "./rq/SignoutRQ";
|
|
15
15
|
import { SwitchOrgRQ } from "./rq/SwitchOrgRQ";
|
|
16
16
|
import { AuthRequest } from "./rq/AuthRequest";
|
|
@@ -147,7 +147,8 @@ export class AuthApi extends BaseApi {
|
|
|
147
147
|
const rq: LoginIdRQ = {
|
|
148
148
|
id,
|
|
149
149
|
deviceId,
|
|
150
|
-
region
|
|
150
|
+
region,
|
|
151
|
+
timeZone: this.app.getTimeZone()
|
|
151
152
|
};
|
|
152
153
|
return this.api.post("Auth/LoginId", rq, payload);
|
|
153
154
|
}
|
|
@@ -180,7 +181,8 @@ export class AuthApi extends BaseApi {
|
|
|
180
181
|
|
|
181
182
|
// Reqest data
|
|
182
183
|
const rq: RefreshTokenRQ = {
|
|
183
|
-
deviceId: this.app.deviceId
|
|
184
|
+
deviceId: this.app.deviceId,
|
|
185
|
+
timeZone: this.app.getTimeZone()
|
|
184
186
|
};
|
|
185
187
|
|
|
186
188
|
// Payload
|
|
@@ -223,8 +225,14 @@ export class AuthApi extends BaseApi {
|
|
|
223
225
|
* @param payload Payload
|
|
224
226
|
* @returns Result
|
|
225
227
|
*/
|
|
226
|
-
resetPassword(rq:
|
|
227
|
-
|
|
228
|
+
resetPassword(rq: ResetPasswordInputRQ, payload?: ResultPayload) {
|
|
229
|
+
const data: ResetPasswordRQ = {
|
|
230
|
+
...rq,
|
|
231
|
+
deviceId: this.app.deviceId,
|
|
232
|
+
region: this.app.region,
|
|
233
|
+
timezone: this.app.getTimeZone()
|
|
234
|
+
};
|
|
235
|
+
return this.api.put("Auth/ResetPassword", data, payload);
|
|
228
236
|
}
|
|
229
237
|
|
|
230
238
|
/**
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
+
import { TokenRQ } from "./TokenRQ";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* API Refresh Token Request data
|
|
3
5
|
*/
|
|
4
|
-
export type ApiRefreshTokenRQ = {
|
|
5
|
-
/**
|
|
6
|
-
* Refresh token
|
|
7
|
-
*/
|
|
8
|
-
token: string;
|
|
9
|
-
|
|
6
|
+
export type ApiRefreshTokenRQ = TokenRQ & {
|
|
10
7
|
/**
|
|
11
8
|
* Application ID, 0 for core system
|
|
12
9
|
*/
|
|
13
|
-
appId
|
|
10
|
+
appId: number;
|
|
14
11
|
};
|
package/src/api/rq/LoginIdRQ.ts
CHANGED
package/src/api/rq/LoginRQ.ts
CHANGED
|
@@ -15,13 +15,13 @@ export type LoginRQ = LoginIdRQ & {
|
|
|
15
15
|
*/
|
|
16
16
|
org?: number;
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* Time zone
|
|
20
|
-
*/
|
|
21
|
-
timezone?: string;
|
|
22
|
-
|
|
23
18
|
/**
|
|
24
19
|
* Authorization request data
|
|
25
20
|
*/
|
|
26
21
|
auth?: AuthRequest;
|
|
27
22
|
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Login input request data
|
|
26
|
+
*/
|
|
27
|
+
export type LoginInputRQ = Pick<LoginRQ, "id" | "pwd" | "org" | "auth">;
|
|
@@ -18,4 +18,14 @@ export type ResetPasswordRQ = {
|
|
|
18
18
|
* Country or region
|
|
19
19
|
*/
|
|
20
20
|
region: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Time zone
|
|
24
|
+
*/
|
|
25
|
+
timezone: string;
|
|
21
26
|
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Reset password input request data
|
|
30
|
+
*/
|
|
31
|
+
export type ResetPasswordInputRQ = Pick<ResetPasswordRQ, "id" | "password">;
|
package/src/api/rq/TokenRQ.ts
CHANGED
package/src/app/AppSettings.ts
CHANGED
package/src/app/CoreApp.ts
CHANGED
|
@@ -61,7 +61,7 @@ type ApiRefreshTokenFunction = (
|
|
|
61
61
|
rq: ApiRefreshTokenRQ
|
|
62
62
|
) => Promise<[string, number] | undefined>;
|
|
63
63
|
|
|
64
|
-
// API task data
|
|
64
|
+
// API task data, [api, token expires in seconds, token expires countdown seconds, app id, refresh token function, token]
|
|
65
65
|
type ApiTaskData = [IApi, number, number, ApiRefreshTokenFunction, string?];
|
|
66
66
|
|
|
67
67
|
// System API name
|
|
@@ -352,7 +352,7 @@ export abstract class CoreApp<
|
|
|
352
352
|
if (this.lastCalled) {
|
|
353
353
|
// Call refreshToken to update access token
|
|
354
354
|
await this.refreshToken(
|
|
355
|
-
{ token: rq.token, showLoading: false },
|
|
355
|
+
{ token: rq.token, timeZone: rq.timeZone, showLoading: false },
|
|
356
356
|
(result) => {
|
|
357
357
|
if (result === true) return;
|
|
358
358
|
console.log(`CoreApp.${this.name}.RefreshToken`, result);
|
|
@@ -1473,8 +1473,8 @@ export abstract class CoreApp<
|
|
|
1473
1473
|
options?: DateUtils.FormatOptions,
|
|
1474
1474
|
timeZone?: string
|
|
1475
1475
|
) {
|
|
1476
|
-
const { currentCulture
|
|
1477
|
-
timeZone ??=
|
|
1476
|
+
const { currentCulture } = this.settings;
|
|
1477
|
+
timeZone ??= this.getTimeZone();
|
|
1478
1478
|
return DateUtils.format(input, currentCulture.name, options, timeZone);
|
|
1479
1479
|
}
|
|
1480
1480
|
|
|
@@ -1796,9 +1796,8 @@ export abstract class CoreApp<
|
|
|
1796
1796
|
* Get time zone
|
|
1797
1797
|
* @returns Time zone
|
|
1798
1798
|
*/
|
|
1799
|
-
getTimeZone()
|
|
1800
|
-
|
|
1801
|
-
return this.settings.timeZone ?? this.ipData?.timezone;
|
|
1799
|
+
getTimeZone() {
|
|
1800
|
+
return this.settings.timeZone ?? Utils.getTimeZone(this.ipData?.timezone);
|
|
1802
1801
|
}
|
|
1803
1802
|
|
|
1804
1803
|
/**
|
|
@@ -1939,7 +1938,7 @@ export abstract class CoreApp<
|
|
|
1939
1938
|
callback?: (result?: boolean | IActionResult) => boolean | void
|
|
1940
1939
|
) {
|
|
1941
1940
|
// Check props
|
|
1942
|
-
props ??= {};
|
|
1941
|
+
props ??= { timeZone: this.getTimeZone() };
|
|
1943
1942
|
props.token ??= this.getCacheToken();
|
|
1944
1943
|
|
|
1945
1944
|
// Call refresh token API
|
|
@@ -2053,7 +2052,7 @@ export abstract class CoreApp<
|
|
|
2053
2052
|
|
|
2054
2053
|
// Call the API quietly, no loading bar and no error popup
|
|
2055
2054
|
const data = await this.createAuthApi().exchangeToken(
|
|
2056
|
-
{ token },
|
|
2055
|
+
{ token, timeZone: this.getTimeZone() },
|
|
2057
2056
|
{
|
|
2058
2057
|
showLoading: false,
|
|
2059
2058
|
onError: (error) => {
|
|
@@ -2163,6 +2162,12 @@ export abstract class CoreApp<
|
|
|
2163
2162
|
// Exit when not authorized
|
|
2164
2163
|
if (!this.authorized) return;
|
|
2165
2164
|
|
|
2165
|
+
// App id
|
|
2166
|
+
const appId = this.settings.appId;
|
|
2167
|
+
|
|
2168
|
+
// Timezone
|
|
2169
|
+
const timeZone = this.getTimeZone();
|
|
2170
|
+
|
|
2166
2171
|
// APIs
|
|
2167
2172
|
for (const name in this.apis) {
|
|
2168
2173
|
// Get the API
|
|
@@ -2177,7 +2182,7 @@ export abstract class CoreApp<
|
|
|
2177
2182
|
// Ready to trigger
|
|
2178
2183
|
if (api[2] === 0) {
|
|
2179
2184
|
// Refresh token
|
|
2180
|
-
api[3](api[0], { token: api[4] }).then((data) => {
|
|
2185
|
+
api[3](api[0], { appId, token: api[4], timeZone }).then((data) => {
|
|
2181
2186
|
if (data == null) {
|
|
2182
2187
|
// Failed, try it again in 2 seconds
|
|
2183
2188
|
api[2] = 2;
|
package/src/app/IApp.ts
CHANGED
|
@@ -114,6 +114,11 @@ export interface RefreshTokenProps {
|
|
|
114
114
|
*/
|
|
115
115
|
token?: string;
|
|
116
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Time zone
|
|
119
|
+
*/
|
|
120
|
+
timeZone: string;
|
|
121
|
+
|
|
117
122
|
/**
|
|
118
123
|
* API URL
|
|
119
124
|
*/
|
|
@@ -649,7 +654,7 @@ export interface IApp {
|
|
|
649
654
|
* Get time zone
|
|
650
655
|
* @returns Time zone
|
|
651
656
|
*/
|
|
652
|
-
getTimeZone(): string
|
|
657
|
+
getTimeZone(): string;
|
|
653
658
|
|
|
654
659
|
/**
|
|
655
660
|
* Hash message, SHA3 or HmacSHA512, 512 as Base64
|