@etsoo/appscript 1.5.12 → 1.5.14
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 +0 -3
- package/lib/cjs/app/AppSettings.d.ts +0 -5
- package/lib/cjs/app/CoreApp.d.ts +3 -2
- package/lib/cjs/app/CoreApp.js +8 -6
- package/lib/cjs/app/IApp.d.ts +3 -2
- package/lib/cjs/i18n/en.json +1 -0
- package/lib/cjs/i18n/zh-Hans.json +1 -0
- package/lib/cjs/i18n/zh-Hant.json +1 -0
- package/lib/cjs/state/User.d.ts +15 -0
- package/lib/mjs/app/AppSettings.d.ts +0 -5
- package/lib/mjs/app/CoreApp.d.ts +3 -2
- package/lib/mjs/app/CoreApp.js +8 -6
- package/lib/mjs/app/IApp.d.ts +3 -2
- package/lib/mjs/i18n/en.json +1 -0
- package/lib/mjs/i18n/zh-Hans.json +1 -0
- package/lib/mjs/i18n/zh-Hant.json +1 -0
- package/lib/mjs/state/User.d.ts +15 -0
- package/package.json +1 -1
- package/src/app/AppSettings.ts +0 -6
- package/src/app/CoreApp.ts +8 -6
- package/src/app/IApp.ts +3 -2
- package/src/i18n/en.json +1 -0
- package/src/i18n/zh-Hans.json +1 -0
- package/src/i18n/zh-Hant.json +1 -0
- package/src/state/User.ts +18 -0
package/__tests__/app/CoreApp.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ApiAuthorizationScheme } from '@etsoo/restclient';
|
|
2
1
|
import { DataTypes } from '@etsoo/shared';
|
|
3
2
|
import { AddressRegion } from '../address/AddressRegion';
|
|
4
3
|
import { IExternalSettings } from './ExternalSettings';
|
|
@@ -6,10 +5,6 @@ import { IExternalSettings } from './ExternalSettings';
|
|
|
6
5
|
* App settings interface
|
|
7
6
|
*/
|
|
8
7
|
export interface IAppSettings extends IExternalSettings {
|
|
9
|
-
/**
|
|
10
|
-
* Authorization scheme
|
|
11
|
-
*/
|
|
12
|
-
readonly authScheme: ApiAuthorizationScheme | string;
|
|
13
8
|
/**
|
|
14
9
|
* Supported country/region ids
|
|
15
10
|
*/
|
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -249,10 +249,11 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
249
249
|
alertResult(result: IActionResult, callback?: NotificationReturn<void>, forceToLocal?: FormatResultCustomCallback): void;
|
|
250
250
|
/**
|
|
251
251
|
* Authorize
|
|
252
|
-
* @param token New token
|
|
252
|
+
* @param token New access token
|
|
253
|
+
* @param schema Access token schema
|
|
253
254
|
* @param refreshToken Refresh token
|
|
254
255
|
*/
|
|
255
|
-
authorize(token?: string, refreshToken?: string): void;
|
|
256
|
+
authorize(token?: string, schema?: string, refreshToken?: string): void;
|
|
256
257
|
/**
|
|
257
258
|
* Change country or region
|
|
258
259
|
* @param regionId New country or region
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -534,14 +534,16 @@ class CoreApp {
|
|
|
534
534
|
}
|
|
535
535
|
/**
|
|
536
536
|
* Authorize
|
|
537
|
-
* @param token New token
|
|
537
|
+
* @param token New access token
|
|
538
|
+
* @param schema Access token schema
|
|
538
539
|
* @param refreshToken Refresh token
|
|
539
540
|
*/
|
|
540
|
-
authorize(token, refreshToken) {
|
|
541
|
+
authorize(token, schema, refreshToken) {
|
|
541
542
|
// State, when token is null, means logout
|
|
542
543
|
this.authorized = token != null;
|
|
543
544
|
// Token
|
|
544
|
-
|
|
545
|
+
schema ?? (schema = 'Bearer');
|
|
546
|
+
this.api.authorize(schema, token);
|
|
545
547
|
// Overwrite the current value
|
|
546
548
|
if (refreshToken !== '') {
|
|
547
549
|
if (refreshToken != null)
|
|
@@ -1391,11 +1393,11 @@ class CoreApp {
|
|
|
1391
1393
|
// Cache the encrypted serverside device id
|
|
1392
1394
|
this.storage.setData(this.fields.serversideDeviceId, user.deviceId);
|
|
1393
1395
|
if (keep) {
|
|
1394
|
-
this.authorize(user.token, refreshToken);
|
|
1396
|
+
this.authorize(user.token, user.tokenScheme, refreshToken);
|
|
1395
1397
|
}
|
|
1396
1398
|
else {
|
|
1397
1399
|
this.cachedRefreshToken = this.encrypt(refreshToken);
|
|
1398
|
-
this.authorize(user.token, undefined);
|
|
1400
|
+
this.authorize(user.token, user.tokenScheme, undefined);
|
|
1399
1401
|
}
|
|
1400
1402
|
}
|
|
1401
1403
|
/**
|
|
@@ -1404,7 +1406,7 @@ class CoreApp {
|
|
|
1404
1406
|
* @param noTrigger No trigger for state change
|
|
1405
1407
|
*/
|
|
1406
1408
|
userLogout(clearToken = true, noTrigger = false) {
|
|
1407
|
-
this.authorize(undefined, clearToken ? undefined : '');
|
|
1409
|
+
this.authorize(undefined, undefined, clearToken ? undefined : '');
|
|
1408
1410
|
}
|
|
1409
1411
|
/**
|
|
1410
1412
|
* User unauthorized
|
package/lib/cjs/app/IApp.d.ts
CHANGED
|
@@ -178,10 +178,11 @@ export interface IApp {
|
|
|
178
178
|
alertResult(result: IActionResult, callback?: NotificationReturn<void>, forceToLocal?: FormatResultCustomCallback): void;
|
|
179
179
|
/**
|
|
180
180
|
* Authorize
|
|
181
|
-
* @param token New token
|
|
181
|
+
* @param token New access token
|
|
182
|
+
* @param schema Access token schema
|
|
182
183
|
* @param refreshToken Refresh token
|
|
183
184
|
*/
|
|
184
|
-
authorize(token?: string, refreshToken?: string): void;
|
|
185
|
+
authorize(token?: string, schema?: string, refreshToken?: string): void;
|
|
185
186
|
/**
|
|
186
187
|
* Change country or region
|
|
187
188
|
* @param region New country or region
|
package/lib/cjs/i18n/en.json
CHANGED
package/lib/cjs/state/User.d.ts
CHANGED
|
@@ -22,6 +22,16 @@ export interface IUserData {
|
|
|
22
22
|
* 机构编号
|
|
23
23
|
*/
|
|
24
24
|
readonly organization?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Is from the channel organization
|
|
27
|
+
* 是否来自渠道机构
|
|
28
|
+
*/
|
|
29
|
+
readonly isChannel?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Is from the parent organization
|
|
32
|
+
* 是否来自父级机构
|
|
33
|
+
*/
|
|
34
|
+
readonly isParent?: boolean;
|
|
25
35
|
/**
|
|
26
36
|
* User role value
|
|
27
37
|
* 用户角色值
|
|
@@ -37,6 +47,11 @@ export interface IUserData {
|
|
|
37
47
|
* 访问令牌
|
|
38
48
|
*/
|
|
39
49
|
readonly token: string;
|
|
50
|
+
/**
|
|
51
|
+
* Access token scheme
|
|
52
|
+
* 访问令牌方案
|
|
53
|
+
*/
|
|
54
|
+
readonly tokenScheme?: string;
|
|
40
55
|
}
|
|
41
56
|
/**
|
|
42
57
|
* User data property keys
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ApiAuthorizationScheme } from '@etsoo/restclient';
|
|
2
1
|
import { DataTypes } from '@etsoo/shared';
|
|
3
2
|
import { AddressRegion } from '../address/AddressRegion';
|
|
4
3
|
import { IExternalSettings } from './ExternalSettings';
|
|
@@ -6,10 +5,6 @@ import { IExternalSettings } from './ExternalSettings';
|
|
|
6
5
|
* App settings interface
|
|
7
6
|
*/
|
|
8
7
|
export interface IAppSettings extends IExternalSettings {
|
|
9
|
-
/**
|
|
10
|
-
* Authorization scheme
|
|
11
|
-
*/
|
|
12
|
-
readonly authScheme: ApiAuthorizationScheme | string;
|
|
13
8
|
/**
|
|
14
9
|
* Supported country/region ids
|
|
15
10
|
*/
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -249,10 +249,11 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
249
249
|
alertResult(result: IActionResult, callback?: NotificationReturn<void>, forceToLocal?: FormatResultCustomCallback): void;
|
|
250
250
|
/**
|
|
251
251
|
* Authorize
|
|
252
|
-
* @param token New token
|
|
252
|
+
* @param token New access token
|
|
253
|
+
* @param schema Access token schema
|
|
253
254
|
* @param refreshToken Refresh token
|
|
254
255
|
*/
|
|
255
|
-
authorize(token?: string, refreshToken?: string): void;
|
|
256
|
+
authorize(token?: string, schema?: string, refreshToken?: string): void;
|
|
256
257
|
/**
|
|
257
258
|
* Change country or region
|
|
258
259
|
* @param regionId New country or region
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -531,14 +531,16 @@ export class CoreApp {
|
|
|
531
531
|
}
|
|
532
532
|
/**
|
|
533
533
|
* Authorize
|
|
534
|
-
* @param token New token
|
|
534
|
+
* @param token New access token
|
|
535
|
+
* @param schema Access token schema
|
|
535
536
|
* @param refreshToken Refresh token
|
|
536
537
|
*/
|
|
537
|
-
authorize(token, refreshToken) {
|
|
538
|
+
authorize(token, schema, refreshToken) {
|
|
538
539
|
// State, when token is null, means logout
|
|
539
540
|
this.authorized = token != null;
|
|
540
541
|
// Token
|
|
541
|
-
|
|
542
|
+
schema ?? (schema = 'Bearer');
|
|
543
|
+
this.api.authorize(schema, token);
|
|
542
544
|
// Overwrite the current value
|
|
543
545
|
if (refreshToken !== '') {
|
|
544
546
|
if (refreshToken != null)
|
|
@@ -1388,11 +1390,11 @@ export class CoreApp {
|
|
|
1388
1390
|
// Cache the encrypted serverside device id
|
|
1389
1391
|
this.storage.setData(this.fields.serversideDeviceId, user.deviceId);
|
|
1390
1392
|
if (keep) {
|
|
1391
|
-
this.authorize(user.token, refreshToken);
|
|
1393
|
+
this.authorize(user.token, user.tokenScheme, refreshToken);
|
|
1392
1394
|
}
|
|
1393
1395
|
else {
|
|
1394
1396
|
this.cachedRefreshToken = this.encrypt(refreshToken);
|
|
1395
|
-
this.authorize(user.token, undefined);
|
|
1397
|
+
this.authorize(user.token, user.tokenScheme, undefined);
|
|
1396
1398
|
}
|
|
1397
1399
|
}
|
|
1398
1400
|
/**
|
|
@@ -1401,7 +1403,7 @@ export class CoreApp {
|
|
|
1401
1403
|
* @param noTrigger No trigger for state change
|
|
1402
1404
|
*/
|
|
1403
1405
|
userLogout(clearToken = true, noTrigger = false) {
|
|
1404
|
-
this.authorize(undefined, clearToken ? undefined : '');
|
|
1406
|
+
this.authorize(undefined, undefined, clearToken ? undefined : '');
|
|
1405
1407
|
}
|
|
1406
1408
|
/**
|
|
1407
1409
|
* User unauthorized
|
package/lib/mjs/app/IApp.d.ts
CHANGED
|
@@ -178,10 +178,11 @@ export interface IApp {
|
|
|
178
178
|
alertResult(result: IActionResult, callback?: NotificationReturn<void>, forceToLocal?: FormatResultCustomCallback): void;
|
|
179
179
|
/**
|
|
180
180
|
* Authorize
|
|
181
|
-
* @param token New token
|
|
181
|
+
* @param token New access token
|
|
182
|
+
* @param schema Access token schema
|
|
182
183
|
* @param refreshToken Refresh token
|
|
183
184
|
*/
|
|
184
|
-
authorize(token?: string, refreshToken?: string): void;
|
|
185
|
+
authorize(token?: string, schema?: string, refreshToken?: string): void;
|
|
185
186
|
/**
|
|
186
187
|
* Change country or region
|
|
187
188
|
* @param region New country or region
|
package/lib/mjs/i18n/en.json
CHANGED
package/lib/mjs/state/User.d.ts
CHANGED
|
@@ -22,6 +22,16 @@ export interface IUserData {
|
|
|
22
22
|
* 机构编号
|
|
23
23
|
*/
|
|
24
24
|
readonly organization?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Is from the channel organization
|
|
27
|
+
* 是否来自渠道机构
|
|
28
|
+
*/
|
|
29
|
+
readonly isChannel?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Is from the parent organization
|
|
32
|
+
* 是否来自父级机构
|
|
33
|
+
*/
|
|
34
|
+
readonly isParent?: boolean;
|
|
25
35
|
/**
|
|
26
36
|
* User role value
|
|
27
37
|
* 用户角色值
|
|
@@ -37,6 +47,11 @@ export interface IUserData {
|
|
|
37
47
|
* 访问令牌
|
|
38
48
|
*/
|
|
39
49
|
readonly token: string;
|
|
50
|
+
/**
|
|
51
|
+
* Access token scheme
|
|
52
|
+
* 访问令牌方案
|
|
53
|
+
*/
|
|
54
|
+
readonly tokenScheme?: string;
|
|
40
55
|
}
|
|
41
56
|
/**
|
|
42
57
|
* User data property keys
|
package/package.json
CHANGED
package/src/app/AppSettings.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ApiAuthorizationScheme } from '@etsoo/restclient';
|
|
2
1
|
import { DataTypes } from '@etsoo/shared';
|
|
3
2
|
import { AddressRegion } from '../address/AddressRegion';
|
|
4
3
|
import { IExternalSettings } from './ExternalSettings';
|
|
@@ -7,11 +6,6 @@ import { IExternalSettings } from './ExternalSettings';
|
|
|
7
6
|
* App settings interface
|
|
8
7
|
*/
|
|
9
8
|
export interface IAppSettings extends IExternalSettings {
|
|
10
|
-
/**
|
|
11
|
-
* Authorization scheme
|
|
12
|
-
*/
|
|
13
|
-
readonly authScheme: ApiAuthorizationScheme | string;
|
|
14
|
-
|
|
15
9
|
/**
|
|
16
10
|
* Supported country/region ids
|
|
17
11
|
*/
|
package/src/app/CoreApp.ts
CHANGED
|
@@ -847,15 +847,17 @@ export abstract class CoreApp<
|
|
|
847
847
|
|
|
848
848
|
/**
|
|
849
849
|
* Authorize
|
|
850
|
-
* @param token New token
|
|
850
|
+
* @param token New access token
|
|
851
|
+
* @param schema Access token schema
|
|
851
852
|
* @param refreshToken Refresh token
|
|
852
853
|
*/
|
|
853
|
-
authorize(token?: string, refreshToken?: string) {
|
|
854
|
+
authorize(token?: string, schema?: string, refreshToken?: string) {
|
|
854
855
|
// State, when token is null, means logout
|
|
855
856
|
this.authorized = token != null;
|
|
856
857
|
|
|
857
858
|
// Token
|
|
858
|
-
|
|
859
|
+
schema ??= 'Bearer';
|
|
860
|
+
this.api.authorize(schema, token);
|
|
859
861
|
|
|
860
862
|
// Overwrite the current value
|
|
861
863
|
if (refreshToken !== '') {
|
|
@@ -1892,10 +1894,10 @@ export abstract class CoreApp<
|
|
|
1892
1894
|
this.storage.setData(this.fields.serversideDeviceId, user.deviceId);
|
|
1893
1895
|
|
|
1894
1896
|
if (keep) {
|
|
1895
|
-
this.authorize(user.token, refreshToken);
|
|
1897
|
+
this.authorize(user.token, user.tokenScheme, refreshToken);
|
|
1896
1898
|
} else {
|
|
1897
1899
|
this.cachedRefreshToken = this.encrypt(refreshToken);
|
|
1898
|
-
this.authorize(user.token, undefined);
|
|
1900
|
+
this.authorize(user.token, user.tokenScheme, undefined);
|
|
1899
1901
|
}
|
|
1900
1902
|
}
|
|
1901
1903
|
|
|
@@ -1905,7 +1907,7 @@ export abstract class CoreApp<
|
|
|
1905
1907
|
* @param noTrigger No trigger for state change
|
|
1906
1908
|
*/
|
|
1907
1909
|
userLogout(clearToken: boolean = true, noTrigger: boolean = false) {
|
|
1908
|
-
this.authorize(undefined, clearToken ? undefined : '');
|
|
1910
|
+
this.authorize(undefined, undefined, clearToken ? undefined : '');
|
|
1909
1911
|
}
|
|
1910
1912
|
|
|
1911
1913
|
/**
|
package/src/app/IApp.ts
CHANGED
|
@@ -243,10 +243,11 @@ export interface IApp {
|
|
|
243
243
|
|
|
244
244
|
/**
|
|
245
245
|
* Authorize
|
|
246
|
-
* @param token New token
|
|
246
|
+
* @param token New access token
|
|
247
|
+
* @param schema Access token schema
|
|
247
248
|
* @param refreshToken Refresh token
|
|
248
249
|
*/
|
|
249
|
-
authorize(token?: string, refreshToken?: string): void;
|
|
250
|
+
authorize(token?: string, schema?: string, refreshToken?: string): void;
|
|
250
251
|
|
|
251
252
|
/**
|
|
252
253
|
* Change country or region
|
package/src/i18n/en.json
CHANGED
package/src/i18n/zh-Hans.json
CHANGED
package/src/i18n/zh-Hant.json
CHANGED
package/src/state/User.ts
CHANGED
|
@@ -27,6 +27,18 @@ export interface IUserData {
|
|
|
27
27
|
*/
|
|
28
28
|
readonly organization?: number;
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Is from the channel organization
|
|
32
|
+
* 是否来自渠道机构
|
|
33
|
+
*/
|
|
34
|
+
readonly isChannel?: boolean;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Is from the parent organization
|
|
38
|
+
* 是否来自父级机构
|
|
39
|
+
*/
|
|
40
|
+
readonly isParent?: boolean;
|
|
41
|
+
|
|
30
42
|
/**
|
|
31
43
|
* User role value
|
|
32
44
|
* 用户角色值
|
|
@@ -44,6 +56,12 @@ export interface IUserData {
|
|
|
44
56
|
* 访问令牌
|
|
45
57
|
*/
|
|
46
58
|
readonly token: string;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Access token scheme
|
|
62
|
+
* 访问令牌方案
|
|
63
|
+
*/
|
|
64
|
+
readonly tokenScheme?: string;
|
|
47
65
|
}
|
|
48
66
|
|
|
49
67
|
/**
|