@etsoo/appscript 1.5.96 → 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/lib/cjs/api/AuthApi.js +4 -2
- 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 +0 -4
- package/lib/cjs/api/rq/RefreshTokenRQ.d.ts +4 -0
- package/lib/cjs/api/rq/TokenRQ.d.ts +4 -0
- package/lib/cjs/app/CoreApp.js +8 -4
- package/lib/cjs/app/IApp.d.ts +4 -0
- package/lib/mjs/api/AuthApi.js +4 -2
- 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 +0 -4
- package/lib/mjs/api/rq/RefreshTokenRQ.d.ts +4 -0
- package/lib/mjs/api/rq/TokenRQ.d.ts +4 -0
- package/lib/mjs/app/CoreApp.js +8 -4
- package/lib/mjs/app/IApp.d.ts +4 -0
- package/package.json +1 -1
- package/src/api/AuthApi.ts +4 -2
- package/src/api/rq/ApiRefreshTokenRQ.ts +4 -7
- package/src/api/rq/LoginIdRQ.ts +5 -0
- package/src/api/rq/LoginRQ.ts +0 -5
- package/src/api/rq/RefreshTokenRQ.ts +5 -0
- package/src/api/rq/TokenRQ.ts +5 -0
- package/src/app/CoreApp.ts +11 -5
- package/src/app/IApp.ts +5 -0
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 = {
|
|
@@ -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
|
};
|
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);
|
|
@@ -1420,7 +1420,7 @@ class CoreApp {
|
|
|
1420
1420
|
*/
|
|
1421
1421
|
async refreshToken(props, callback) {
|
|
1422
1422
|
// Check props
|
|
1423
|
-
props ?? (props = {});
|
|
1423
|
+
props ?? (props = { timeZone: this.getTimeZone() });
|
|
1424
1424
|
props.token ?? (props.token = this.getCacheToken());
|
|
1425
1425
|
// Call refresh token API
|
|
1426
1426
|
let data = await this.createAuthApi().refreshToken(props);
|
|
@@ -1519,7 +1519,7 @@ class CoreApp {
|
|
|
1519
1519
|
throw new Error("System API is not allowed to exchange token");
|
|
1520
1520
|
}
|
|
1521
1521
|
// Call the API quietly, no loading bar and no error popup
|
|
1522
|
-
const data = await this.createAuthApi().exchangeToken({ token }, {
|
|
1522
|
+
const data = await this.createAuthApi().exchangeToken({ token, timeZone: this.getTimeZone() }, {
|
|
1523
1523
|
showLoading: false,
|
|
1524
1524
|
onError: (error) => {
|
|
1525
1525
|
console.error(`CoreApp.${api.name}.ExchangeToken error`, error);
|
|
@@ -1608,6 +1608,10 @@ class CoreApp {
|
|
|
1608
1608
|
// Exit when not authorized
|
|
1609
1609
|
if (!this.authorized)
|
|
1610
1610
|
return;
|
|
1611
|
+
// App id
|
|
1612
|
+
const appId = this.settings.appId;
|
|
1613
|
+
// Timezone
|
|
1614
|
+
const timeZone = this.getTimeZone();
|
|
1611
1615
|
// APIs
|
|
1612
1616
|
for (const name in this.apis) {
|
|
1613
1617
|
// Get the API
|
|
@@ -1620,7 +1624,7 @@ class CoreApp {
|
|
|
1620
1624
|
// Ready to trigger
|
|
1621
1625
|
if (api[2] === 0) {
|
|
1622
1626
|
// Refresh token
|
|
1623
|
-
api[3](api[0], { token: api[4] }).then((data) => {
|
|
1627
|
+
api[3](api[0], { appId, token: api[4], timeZone }).then((data) => {
|
|
1624
1628
|
if (data == null) {
|
|
1625
1629
|
// Failed, try it again in 2 seconds
|
|
1626
1630
|
api[2] = 2;
|
package/lib/cjs/app/IApp.d.ts
CHANGED
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 = {
|
|
@@ -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
|
};
|
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);
|
|
@@ -1417,7 +1417,7 @@ export class CoreApp {
|
|
|
1417
1417
|
*/
|
|
1418
1418
|
async refreshToken(props, callback) {
|
|
1419
1419
|
// Check props
|
|
1420
|
-
props ?? (props = {});
|
|
1420
|
+
props ?? (props = { timeZone: this.getTimeZone() });
|
|
1421
1421
|
props.token ?? (props.token = this.getCacheToken());
|
|
1422
1422
|
// Call refresh token API
|
|
1423
1423
|
let data = await this.createAuthApi().refreshToken(props);
|
|
@@ -1516,7 +1516,7 @@ export class CoreApp {
|
|
|
1516
1516
|
throw new Error("System API is not allowed to exchange token");
|
|
1517
1517
|
}
|
|
1518
1518
|
// Call the API quietly, no loading bar and no error popup
|
|
1519
|
-
const data = await this.createAuthApi().exchangeToken({ token }, {
|
|
1519
|
+
const data = await this.createAuthApi().exchangeToken({ token, timeZone: this.getTimeZone() }, {
|
|
1520
1520
|
showLoading: false,
|
|
1521
1521
|
onError: (error) => {
|
|
1522
1522
|
console.error(`CoreApp.${api.name}.ExchangeToken error`, error);
|
|
@@ -1605,6 +1605,10 @@ export class CoreApp {
|
|
|
1605
1605
|
// Exit when not authorized
|
|
1606
1606
|
if (!this.authorized)
|
|
1607
1607
|
return;
|
|
1608
|
+
// App id
|
|
1609
|
+
const appId = this.settings.appId;
|
|
1610
|
+
// Timezone
|
|
1611
|
+
const timeZone = this.getTimeZone();
|
|
1608
1612
|
// APIs
|
|
1609
1613
|
for (const name in this.apis) {
|
|
1610
1614
|
// Get the API
|
|
@@ -1617,7 +1621,7 @@ export class CoreApp {
|
|
|
1617
1621
|
// Ready to trigger
|
|
1618
1622
|
if (api[2] === 0) {
|
|
1619
1623
|
// Refresh token
|
|
1620
|
-
api[3](api[0], { token: api[4] }).then((data) => {
|
|
1624
|
+
api[3](api[0], { appId, token: api[4], timeZone }).then((data) => {
|
|
1621
1625
|
if (data == null) {
|
|
1622
1626
|
// Failed, try it again in 2 seconds
|
|
1623
1627
|
api[2] = 2;
|
package/lib/mjs/app/IApp.d.ts
CHANGED
package/package.json
CHANGED
package/src/api/AuthApi.ts
CHANGED
|
@@ -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
|
|
@@ -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
package/src/api/rq/TokenRQ.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);
|
|
@@ -1938,7 +1938,7 @@ export abstract class CoreApp<
|
|
|
1938
1938
|
callback?: (result?: boolean | IActionResult) => boolean | void
|
|
1939
1939
|
) {
|
|
1940
1940
|
// Check props
|
|
1941
|
-
props ??= {};
|
|
1941
|
+
props ??= { timeZone: this.getTimeZone() };
|
|
1942
1942
|
props.token ??= this.getCacheToken();
|
|
1943
1943
|
|
|
1944
1944
|
// Call refresh token API
|
|
@@ -2052,7 +2052,7 @@ export abstract class CoreApp<
|
|
|
2052
2052
|
|
|
2053
2053
|
// Call the API quietly, no loading bar and no error popup
|
|
2054
2054
|
const data = await this.createAuthApi().exchangeToken(
|
|
2055
|
-
{ token },
|
|
2055
|
+
{ token, timeZone: this.getTimeZone() },
|
|
2056
2056
|
{
|
|
2057
2057
|
showLoading: false,
|
|
2058
2058
|
onError: (error) => {
|
|
@@ -2162,6 +2162,12 @@ export abstract class CoreApp<
|
|
|
2162
2162
|
// Exit when not authorized
|
|
2163
2163
|
if (!this.authorized) return;
|
|
2164
2164
|
|
|
2165
|
+
// App id
|
|
2166
|
+
const appId = this.settings.appId;
|
|
2167
|
+
|
|
2168
|
+
// Timezone
|
|
2169
|
+
const timeZone = this.getTimeZone();
|
|
2170
|
+
|
|
2165
2171
|
// APIs
|
|
2166
2172
|
for (const name in this.apis) {
|
|
2167
2173
|
// Get the API
|
|
@@ -2176,7 +2182,7 @@ export abstract class CoreApp<
|
|
|
2176
2182
|
// Ready to trigger
|
|
2177
2183
|
if (api[2] === 0) {
|
|
2178
2184
|
// Refresh token
|
|
2179
|
-
api[3](api[0], { token: api[4] }).then((data) => {
|
|
2185
|
+
api[3](api[0], { appId, token: api[4], timeZone }).then((data) => {
|
|
2180
2186
|
if (data == null) {
|
|
2181
2187
|
// Failed, try it again in 2 seconds
|
|
2182
2188
|
api[2] = 2;
|