codevdesign 1.0.75 → 1.0.76
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/outils/rafraichisseurToken.ts +28 -10
- package/package.json +1 -1
|
@@ -5,28 +5,47 @@ class RafraichisseurToken {
|
|
|
5
5
|
private popupAffiche = false
|
|
6
6
|
private timerId: number | null = null
|
|
7
7
|
private nomTemoin = 'csqc_jeton_secure_expiration'
|
|
8
|
-
private
|
|
8
|
+
private urlPortailSeConnecter = ''
|
|
9
|
+
private urlPortailRafraichir = ''
|
|
10
|
+
private urlPortailDeconnecte = ''
|
|
9
11
|
private refreshPromise: Promise<void> | null = null
|
|
10
12
|
public loggerTrace = false
|
|
11
13
|
|
|
12
14
|
// Lance une seule fois
|
|
13
|
-
public async demarrer(
|
|
15
|
+
public async demarrer(
|
|
16
|
+
nomTemoin: string,
|
|
17
|
+
urlPortailSeConnecter: string,
|
|
18
|
+
urlPortailRafraichir: string,
|
|
19
|
+
urlPortailDeconnecte: string,
|
|
20
|
+
): Promise<void> {
|
|
14
21
|
window.rafraichisseurToken = this
|
|
15
22
|
if (this.loggerTrace) {
|
|
16
23
|
console.log('Nom témoin', nomTemoin)
|
|
17
|
-
console.log('URL portail',
|
|
24
|
+
console.log('URL portail se connecter', urlPortailSeConnecter)
|
|
25
|
+
console.log('URL portail rafraichir', urlPortailRafraichir)
|
|
26
|
+
console.log('URL portail déconnecte', urlPortailDeconnecte)
|
|
18
27
|
}
|
|
19
28
|
|
|
20
29
|
if (nomTemoin == null || nomTemoin === '') {
|
|
21
30
|
console.warn('[RafraichisseurToken] nomTemoin invalide, rafraichisseur de token désactivé')
|
|
22
31
|
return
|
|
23
32
|
}
|
|
24
|
-
if (
|
|
25
|
-
console.warn('[RafraichisseurToken]
|
|
33
|
+
if (urlPortailSeConnecter == null || urlPortailSeConnecter === '') {
|
|
34
|
+
console.warn('[RafraichisseurToken] urlPortailSeConnecter invalide, rafraichisseur de token désactivé')
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
if (urlPortailRafraichir == null || urlPortailRafraichir === '') {
|
|
38
|
+
console.warn('[RafraichisseurToken] urlPortailRafraichir invalide, rafraichisseur de token désactivé')
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
if (urlPortailDeconnecte == null || urlPortailDeconnecte === '') {
|
|
42
|
+
console.warn('[RafraichisseurToken] urlPortailDeconnecte invalide, rafraichisseur de token désactivé')
|
|
26
43
|
return
|
|
27
44
|
}
|
|
28
45
|
this.nomTemoin = nomTemoin
|
|
29
|
-
this.
|
|
46
|
+
this.urlPortailSeConnecter = urlPortailSeConnecter.replace(/\/+$/, '')
|
|
47
|
+
this.urlPortailRafraichir = urlPortailRafraichir.replace(/\/+$/, '')
|
|
48
|
+
this.urlPortailDeconnecte = urlPortailDeconnecte.replace(/\/+$/, '')
|
|
30
49
|
|
|
31
50
|
await this.verifierJeton()
|
|
32
51
|
if (this.timerId != null) return
|
|
@@ -106,7 +125,6 @@ class RafraichisseurToken {
|
|
|
106
125
|
private async rafraichir(): Promise<void> {
|
|
107
126
|
if (this.loggerTrace) console.log('[RafraichisseurToken] rafraichir() appelé')
|
|
108
127
|
|
|
109
|
-
if (this.urlPortail == null || this.urlPortail == '') return
|
|
110
128
|
this.popupAffiche = true // bloquer tout nouveau tick pendant le refresh
|
|
111
129
|
const url = this.getRefreshUrl()
|
|
112
130
|
const controller = new AbortController()
|
|
@@ -199,12 +217,12 @@ class RafraichisseurToken {
|
|
|
199
217
|
//on envoie au portail, pas le choix
|
|
200
218
|
const retour = encodeURI(window.location.href)
|
|
201
219
|
|
|
202
|
-
window.open(`${this.
|
|
220
|
+
window.open(`${this.urlPortailSeConnecter}?urlRetour=${retour}`, '_self')
|
|
203
221
|
return
|
|
204
222
|
}
|
|
205
223
|
|
|
206
224
|
public deconnecterPortail(): void {
|
|
207
|
-
window.location.replace(`${this.
|
|
225
|
+
window.location.replace(`${this.urlPortailDeconnecte}?urlRetour=${encodeURIComponent(window.location.href)}`)
|
|
208
226
|
}
|
|
209
227
|
|
|
210
228
|
private lireCookie(): string | null {
|
|
@@ -255,7 +273,7 @@ class RafraichisseurToken {
|
|
|
255
273
|
// URL refresh selon env (dev = proxy Vite ; prod = portail)
|
|
256
274
|
private getRefreshUrl(): string {
|
|
257
275
|
if (import.meta.env.MODE === 'development') return '/portail-refresh'
|
|
258
|
-
return this.
|
|
276
|
+
return this.urlPortailRafraichir
|
|
259
277
|
}
|
|
260
278
|
}
|
|
261
279
|
|