@olenbetong/appframe-core 2.1.1 → 2.1.2
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/dist/esm/af.common.js +34 -28
- package/dist/esm/af.common.legacy.js +34 -28
- package/dist/esm/af.common.legacy.min.js +1 -1
- package/dist/esm/af.common.legacy.min.js.map +3 -3
- package/dist/esm/af.common.min.js +1 -1
- package/dist/esm/af.common.min.js.map +2 -2
- package/dist/iife/af.common.js +34 -28
- package/dist/iife/af.common.legacy.js +34 -28
- package/dist/iife/af.common.legacy.min.js +1 -1
- package/dist/iife/af.common.legacy.min.js.map +3 -3
- package/dist/iife/af.common.min.js +1 -1
- package/dist/iife/af.common.min.js.map +2 -2
- package/es/SessionHandler.d.ts +1 -1
- package/es/SessionHandler.js +32 -27
- package/es/index.js +1 -1
- package/package.json +2 -2
- package/src/SessionHandler.ts +10 -5
package/es/SessionHandler.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ declare type SessionHandlerEvent = "onExpired" | "onAuthenticated";
|
|
|
3
3
|
export default class SessionHandler {
|
|
4
4
|
private eventHandler;
|
|
5
5
|
authenticated(): void;
|
|
6
|
-
expired(callback?: (
|
|
6
|
+
expired(callback?: () => void, type?: "RequireTwoFactor"): Promise<void>;
|
|
7
7
|
attachEvent(eventName: SessionHandlerEvent, handler: Handler): void;
|
|
8
8
|
detachEvent(eventName: SessionHandlerEvent, handler: Handler): void;
|
|
9
9
|
}
|
package/es/SessionHandler.js
CHANGED
|
@@ -7,37 +7,42 @@ export default class SessionHandler {
|
|
|
7
7
|
this.eventHandler.emit("onAuthenticated");
|
|
8
8
|
}
|
|
9
9
|
async expired(callback, type) {
|
|
10
|
-
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
10
|
+
try {
|
|
11
|
+
let authPromise = new Promise((resolve) => {
|
|
12
|
+
let eventHandler = () => {
|
|
13
|
+
this.eventHandler.off("onAuthenticated", eventHandler);
|
|
14
|
+
callback?.();
|
|
15
|
+
resolve();
|
|
16
|
+
};
|
|
17
|
+
this.eventHandler.on("onAuthenticated", eventHandler);
|
|
18
|
+
});
|
|
19
|
+
let dialog = document.querySelector("dialog.session-expired-dialog");
|
|
20
|
+
if (!dialog) {
|
|
21
|
+
dialog = document.createElement("dialog");
|
|
22
|
+
dialog.className = "session-expired-dialog";
|
|
23
|
+
dialog.style.display = "flex";
|
|
24
|
+
dialog.style.padding = "0";
|
|
25
|
+
dialog.style.left = "50%";
|
|
26
|
+
dialog.style.transform = "translateX(-50%)";
|
|
27
|
+
let link = "/login?ReturnUrl=%2fapi/sessionexpired/remove";
|
|
28
|
+
if (type !== "RequireTwoFactor") {
|
|
29
|
+
await fetch("/logout", { method: "POST" });
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
link = "/login?RequireTwoFactor=1&ReturnUrl=%2fapi/sessionexpired/remove";
|
|
33
|
+
}
|
|
34
|
+
dialog.innerHTML = `<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="${link}" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>`;
|
|
35
|
+
document.body.append(dialog);
|
|
36
|
+
dialog.showModal();
|
|
37
|
+
await authPromise;
|
|
38
|
+
dialog.remove();
|
|
29
39
|
}
|
|
30
40
|
else {
|
|
31
|
-
|
|
41
|
+
await authPromise;
|
|
32
42
|
}
|
|
33
|
-
dialog.innerHTML = `<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="${link}" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>`;
|
|
34
|
-
document.body.append(dialog);
|
|
35
|
-
dialog.showModal();
|
|
36
|
-
await authPromise;
|
|
37
|
-
dialog.remove();
|
|
38
43
|
}
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
catch (_) {
|
|
45
|
+
window.location.href = `/login?ReturnUrl=${encodeURIComponent(window.location.pathname)}${encodeURIComponent(window.location.search)}`;
|
|
41
46
|
}
|
|
42
47
|
}
|
|
43
48
|
attachEvent(eventName, handler) {
|
package/es/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olenbetong/appframe-core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Javascript libraries to utilize the Appframe framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"chalk": "^5.0.1"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "16ac538bb4913c802543c23671e4169fa7c7607b"
|
|
52
52
|
}
|
package/src/SessionHandler.ts
CHANGED
|
@@ -9,14 +9,15 @@ export default class SessionHandler {
|
|
|
9
9
|
this.eventHandler.emit("onAuthenticated");
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
async expired(callback?: (
|
|
12
|
+
async expired(callback?: () => void, type?: "RequireTwoFactor"): Promise<void> {
|
|
13
|
+
try {
|
|
13
14
|
let authPromise = new Promise<void>((resolve) => {
|
|
14
15
|
let eventHandler = () => {
|
|
15
16
|
this.eventHandler.off("onAuthenticated", eventHandler);
|
|
16
17
|
callback?.();
|
|
17
18
|
resolve();
|
|
18
|
-
}
|
|
19
|
-
|
|
19
|
+
};
|
|
20
|
+
|
|
20
21
|
this.eventHandler.on("onAuthenticated", eventHandler);
|
|
21
22
|
});
|
|
22
23
|
|
|
@@ -28,7 +29,7 @@ export default class SessionHandler {
|
|
|
28
29
|
dialog.style.padding = "0";
|
|
29
30
|
dialog.style.left = "50%";
|
|
30
31
|
dialog.style.transform = "translateX(-50%)";
|
|
31
|
-
|
|
32
|
+
|
|
32
33
|
let link = "/login?ReturnUrl=%2fapi/sessionexpired/remove";
|
|
33
34
|
if (type !== "RequireTwoFactor") {
|
|
34
35
|
await fetch("/logout", { method: "POST" });
|
|
@@ -44,7 +45,11 @@ export default class SessionHandler {
|
|
|
44
45
|
} else {
|
|
45
46
|
await authPromise;
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
+
} catch (_) {
|
|
49
|
+
window.location.href = `/login?ReturnUrl=${encodeURIComponent(window.location.pathname)}${encodeURIComponent(
|
|
50
|
+
window.location.search
|
|
51
|
+
)}`;
|
|
52
|
+
}
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
attachEvent(eventName: SessionHandlerEvent, handler: Handler) {
|