@etsoo/appscript 1.5.28 → 1.5.29
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/app/CoreApp.d.ts +5 -0
- package/lib/cjs/app/CoreApp.js +12 -3
- package/lib/mjs/app/CoreApp.d.ts +5 -0
- package/lib/mjs/app/CoreApp.js +12 -3
- package/package.json +3 -3
- package/src/app/CoreApp.ts +15 -3
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -288,6 +288,11 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
288
288
|
* @param refreshToken Refresh token
|
|
289
289
|
*/
|
|
290
290
|
authorize(token?: string, schema?: string, refreshToken?: string): void;
|
|
291
|
+
/**
|
|
292
|
+
* On authorized or not callback
|
|
293
|
+
* @param success Success or not
|
|
294
|
+
*/
|
|
295
|
+
protected onAuthorized(success: boolean): void;
|
|
291
296
|
/**
|
|
292
297
|
* Change country or region
|
|
293
298
|
* @param regionId New country or region
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -623,7 +623,7 @@ class CoreApp {
|
|
|
623
623
|
*/
|
|
624
624
|
authorize(token, schema, refreshToken) {
|
|
625
625
|
// State, when token is null, means logout
|
|
626
|
-
|
|
626
|
+
const authorized = token != null;
|
|
627
627
|
// Token
|
|
628
628
|
schema ?? (schema = 'Bearer');
|
|
629
629
|
this.api.authorize(schema, token);
|
|
@@ -636,7 +636,7 @@ class CoreApp {
|
|
|
636
636
|
// Reset tryLogin state
|
|
637
637
|
this._isTryingLogin = false;
|
|
638
638
|
// Token countdown
|
|
639
|
-
if (
|
|
639
|
+
if (authorized) {
|
|
640
640
|
this.lastCalled = false;
|
|
641
641
|
if (refreshToken) {
|
|
642
642
|
this.updateApi(this.api.name, refreshToken, this.userData.seconds);
|
|
@@ -647,8 +647,17 @@ class CoreApp {
|
|
|
647
647
|
this.updateApi(this.api.name, undefined, -1);
|
|
648
648
|
}
|
|
649
649
|
// Host notice
|
|
650
|
-
BridgeUtils_1.BridgeUtils.host?.userAuthorization(
|
|
650
|
+
BridgeUtils_1.BridgeUtils.host?.userAuthorization(authorized);
|
|
651
|
+
// Callback
|
|
652
|
+
this.onAuthorized(authorized);
|
|
653
|
+
// Everything is ready, update the state
|
|
654
|
+
this.authorized = authorized;
|
|
651
655
|
}
|
|
656
|
+
/**
|
|
657
|
+
* On authorized or not callback
|
|
658
|
+
* @param success Success or not
|
|
659
|
+
*/
|
|
660
|
+
onAuthorized(success) { }
|
|
652
661
|
/**
|
|
653
662
|
* Change country or region
|
|
654
663
|
* @param regionId New country or region
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -288,6 +288,11 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
288
288
|
* @param refreshToken Refresh token
|
|
289
289
|
*/
|
|
290
290
|
authorize(token?: string, schema?: string, refreshToken?: string): void;
|
|
291
|
+
/**
|
|
292
|
+
* On authorized or not callback
|
|
293
|
+
* @param success Success or not
|
|
294
|
+
*/
|
|
295
|
+
protected onAuthorized(success: boolean): void;
|
|
291
296
|
/**
|
|
292
297
|
* Change country or region
|
|
293
298
|
* @param regionId New country or region
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -620,7 +620,7 @@ export class CoreApp {
|
|
|
620
620
|
*/
|
|
621
621
|
authorize(token, schema, refreshToken) {
|
|
622
622
|
// State, when token is null, means logout
|
|
623
|
-
|
|
623
|
+
const authorized = token != null;
|
|
624
624
|
// Token
|
|
625
625
|
schema ?? (schema = 'Bearer');
|
|
626
626
|
this.api.authorize(schema, token);
|
|
@@ -633,7 +633,7 @@ export class CoreApp {
|
|
|
633
633
|
// Reset tryLogin state
|
|
634
634
|
this._isTryingLogin = false;
|
|
635
635
|
// Token countdown
|
|
636
|
-
if (
|
|
636
|
+
if (authorized) {
|
|
637
637
|
this.lastCalled = false;
|
|
638
638
|
if (refreshToken) {
|
|
639
639
|
this.updateApi(this.api.name, refreshToken, this.userData.seconds);
|
|
@@ -644,8 +644,17 @@ export class CoreApp {
|
|
|
644
644
|
this.updateApi(this.api.name, undefined, -1);
|
|
645
645
|
}
|
|
646
646
|
// Host notice
|
|
647
|
-
BridgeUtils.host?.userAuthorization(
|
|
647
|
+
BridgeUtils.host?.userAuthorization(authorized);
|
|
648
|
+
// Callback
|
|
649
|
+
this.onAuthorized(authorized);
|
|
650
|
+
// Everything is ready, update the state
|
|
651
|
+
this.authorized = authorized;
|
|
648
652
|
}
|
|
653
|
+
/**
|
|
654
|
+
* On authorized or not callback
|
|
655
|
+
* @param success Success or not
|
|
656
|
+
*/
|
|
657
|
+
onAuthorized(success) { }
|
|
649
658
|
/**
|
|
650
659
|
* Change country or region
|
|
651
660
|
* @param regionId New country or region
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.29",
|
|
4
4
|
"description": "Applications shared TypeScript framework",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@babel/cli": "^7.25.7",
|
|
62
|
-
"@babel/core": "^7.25.
|
|
62
|
+
"@babel/core": "^7.25.8",
|
|
63
63
|
"@babel/plugin-transform-runtime": "^7.25.7",
|
|
64
|
-
"@babel/preset-env": "^7.25.
|
|
64
|
+
"@babel/preset-env": "^7.25.8",
|
|
65
65
|
"@babel/runtime-corejs3": "^7.25.7",
|
|
66
66
|
"@types/crypto-js": "^4.2.2",
|
|
67
67
|
"@types/jest": "^29.5.13",
|
package/src/app/CoreApp.ts
CHANGED
|
@@ -985,7 +985,7 @@ export abstract class CoreApp<
|
|
|
985
985
|
*/
|
|
986
986
|
authorize(token?: string, schema?: string, refreshToken?: string) {
|
|
987
987
|
// State, when token is null, means logout
|
|
988
|
-
|
|
988
|
+
const authorized = token != null;
|
|
989
989
|
|
|
990
990
|
// Token
|
|
991
991
|
schema ??= 'Bearer';
|
|
@@ -1001,7 +1001,7 @@ export abstract class CoreApp<
|
|
|
1001
1001
|
this._isTryingLogin = false;
|
|
1002
1002
|
|
|
1003
1003
|
// Token countdown
|
|
1004
|
-
if (
|
|
1004
|
+
if (authorized) {
|
|
1005
1005
|
this.lastCalled = false;
|
|
1006
1006
|
if (refreshToken) {
|
|
1007
1007
|
this.updateApi(
|
|
@@ -1016,9 +1016,21 @@ export abstract class CoreApp<
|
|
|
1016
1016
|
}
|
|
1017
1017
|
|
|
1018
1018
|
// Host notice
|
|
1019
|
-
BridgeUtils.host?.userAuthorization(
|
|
1019
|
+
BridgeUtils.host?.userAuthorization(authorized);
|
|
1020
|
+
|
|
1021
|
+
// Callback
|
|
1022
|
+
this.onAuthorized(authorized);
|
|
1023
|
+
|
|
1024
|
+
// Everything is ready, update the state
|
|
1025
|
+
this.authorized = authorized;
|
|
1020
1026
|
}
|
|
1021
1027
|
|
|
1028
|
+
/**
|
|
1029
|
+
* On authorized or not callback
|
|
1030
|
+
* @param success Success or not
|
|
1031
|
+
*/
|
|
1032
|
+
protected onAuthorized(success: boolean) {}
|
|
1033
|
+
|
|
1022
1034
|
/**
|
|
1023
1035
|
* Change country or region
|
|
1024
1036
|
* @param regionId New country or region
|