vuethenticate 0.1.8 → 0.1.9
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/composables/useAuth.d.ts.map +1 -1
- package/dist/index.esm.js +82 -79
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/composables/useAuth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,UAAU,EACV,sBAAsB,EACtB,aAAa,EAChB,MAAM,eAAe,CAAC;
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/composables/useAuth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,UAAU,EACV,sBAAsB,EACtB,aAAa,EAChB,MAAM,eAAe,CAAC;AAmRvB;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,MAAM,GAAG,OAAO,EACpC,QAAQ,UAAU,KACnB,aAAa,CAAC,MAAM,CA+OtB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GACzB,MAAM,GAAG,OAAO,OACf,sBAAsB,CAAC,MAAM,CAgFjC,CAAC"}
|
package/dist/index.esm.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ref as y, computed as N, watch as j, defineComponent as V, onMounted as z, createElementBlock as
|
1
|
+
import { ref as y, computed as N, watch as j, defineComponent as V, onMounted as z, createElementBlock as _, openBlock as W, Fragment as B, renderSlot as S, createCommentVNode as I, unref as M, createElementVNode as v, toDisplayString as x } from "vue";
|
2
2
|
import { WebStorageStateStore as H, Log as E, UserManager as J } from "oidc-client-ts";
|
3
3
|
var f = /* @__PURE__ */ ((e) => (e[e.NONE = 0] = "NONE", e[e.ERROR = 1] = "ERROR", e[e.WARN = 2] = "WARN", e[e.INFO = 3] = "INFO", e[e.DEBUG = 4] = "DEBUG", e))(f || {});
|
4
4
|
const D = {
|
@@ -45,19 +45,19 @@ function Z(e) {
|
|
45
45
|
}
|
46
46
|
function ee(e) {
|
47
47
|
if (typeof window > "u")
|
48
|
-
return
|
48
|
+
return P();
|
49
49
|
switch (e) {
|
50
50
|
case "localStorage":
|
51
51
|
return window.localStorage;
|
52
52
|
case "sessionStorage":
|
53
53
|
return window.sessionStorage;
|
54
54
|
case "memory":
|
55
|
-
return
|
55
|
+
return P();
|
56
56
|
default:
|
57
57
|
return window.localStorage;
|
58
58
|
}
|
59
59
|
}
|
60
|
-
function
|
60
|
+
function P() {
|
61
61
|
const e = /* @__PURE__ */ new Map();
|
62
62
|
return {
|
63
63
|
getItem: (t) => e.get(t) ?? null,
|
@@ -108,28 +108,28 @@ const te = (e) => {
|
|
108
108
|
} catch (t) {
|
109
109
|
console.warn("Error during UserManager cleanup:", t);
|
110
110
|
}
|
111
|
-
},
|
111
|
+
}, G = (e) => `${e.authority}_${e.clientId}`, ae = () => A.size === 0 ? null : (A.size === 1 || console.warn(
|
112
112
|
"Multiple auth instances detected. Callback components may not work as expected. Consider using a single auth instance or specify config explicitly."
|
113
113
|
), Array.from(A.values())[0] || null), le = (e) => {
|
114
|
-
const t =
|
114
|
+
const t = G(e), r = A.get(t);
|
115
115
|
if (r)
|
116
116
|
return r;
|
117
|
-
const
|
117
|
+
const s = se(e), n = y(!1), c = y(!1), a = y(null), l = y(!1), o = y(null), b = N(() => !!a.value && !a.value.expired), g = N(() => {
|
118
118
|
var m;
|
119
119
|
return ((m = a.value) == null ? void 0 : m.access_token) || null;
|
120
|
-
}),
|
120
|
+
}), i = N(() => {
|
121
121
|
var m;
|
122
122
|
return !!((m = a.value) != null && m.expired);
|
123
123
|
}), d = oe(e), k = {
|
124
|
-
userManager:
|
124
|
+
userManager: s,
|
125
125
|
isInitialized: n,
|
126
126
|
isInitializing: c,
|
127
127
|
user: a,
|
128
128
|
isLoading: l,
|
129
|
-
error:
|
129
|
+
error: o,
|
130
130
|
isAuthenticated: b,
|
131
131
|
accessToken: g,
|
132
|
-
isExpired:
|
132
|
+
isExpired: i,
|
133
133
|
logger: d,
|
134
134
|
eventCallbacks: {}
|
135
135
|
};
|
@@ -142,9 +142,9 @@ const te = (e) => {
|
|
142
142
|
return Q;
|
143
143
|
const t = e.logger ?? D, r = e.logLevel ?? f.NONE;
|
144
144
|
return X(t, r);
|
145
|
-
},
|
145
|
+
}, U = (e, t, r, s) => {
|
146
146
|
const n = e instanceof Error ? e : new Error(t);
|
147
|
-
return r.value = n,
|
147
|
+
return r.value = n, s == null || s(n), n;
|
148
148
|
}, ie = (e) => {
|
149
149
|
var t, r;
|
150
150
|
if (!((t = e.authority) != null && t.trim()))
|
@@ -158,9 +158,9 @@ const te = (e) => {
|
|
158
158
|
}
|
159
159
|
}, T = async (e, t = 1e4) => {
|
160
160
|
if (!e.isInitialized.value)
|
161
|
-
return new Promise((r,
|
161
|
+
return new Promise((r, s) => {
|
162
162
|
const n = setTimeout(() => {
|
163
|
-
|
163
|
+
s(new Error("Authentication initialization timeout"));
|
164
164
|
}, t), c = j(
|
165
165
|
e.isInitialized,
|
166
166
|
(a) => {
|
@@ -169,20 +169,23 @@ const te = (e) => {
|
|
169
169
|
{ immediate: !0 }
|
170
170
|
);
|
171
171
|
});
|
172
|
-
},
|
172
|
+
}, ue = (e) => {
|
173
|
+
const t = window.location.href;
|
174
|
+
return !!(e.silentRedirectUri && t.startsWith(e.silentRedirectUri) || e.redirectUri && t.startsWith(e.redirectUri) || e.postLogoutRedirectUri && t.startsWith(e.postLogoutRedirectUri));
|
175
|
+
}, ge = (e) => {
|
173
176
|
ie(e);
|
174
177
|
const t = le(e), {
|
175
178
|
userManager: r,
|
176
|
-
isInitialized:
|
179
|
+
isInitialized: s,
|
177
180
|
isInitializing: n,
|
178
181
|
user: c,
|
179
182
|
isLoading: a,
|
180
183
|
error: l,
|
181
|
-
isAuthenticated:
|
184
|
+
isAuthenticated: o,
|
182
185
|
accessToken: b,
|
183
186
|
isExpired: g
|
184
|
-
} = t,
|
185
|
-
if (!(n.value ||
|
187
|
+
} = t, i = G(e), d = async () => {
|
188
|
+
if (!(n.value || s.value))
|
186
189
|
try {
|
187
190
|
n.value = !0, a.value = !0, l.value = null;
|
188
191
|
const h = await r.getUser();
|
@@ -197,20 +200,20 @@ const te = (e) => {
|
|
197
200
|
);
|
198
201
|
try {
|
199
202
|
await $();
|
200
|
-
} catch (
|
203
|
+
} catch (u) {
|
201
204
|
t.logger.warn(
|
202
205
|
"[Vuethenticate] useAuth: Silent renewal failed during initialization",
|
203
|
-
|
206
|
+
u
|
204
207
|
), await r.removeUser(), c.value = null;
|
205
208
|
}
|
206
209
|
} else
|
207
210
|
await r.removeUser(), c.value = null;
|
208
|
-
|
211
|
+
s.value = !0;
|
209
212
|
} catch (h) {
|
210
213
|
t.logger.error(
|
211
214
|
"[Vuethenticate] useAuth: Initialization failed",
|
212
215
|
h
|
213
|
-
),
|
216
|
+
), U(
|
214
217
|
h,
|
215
218
|
"Authentication initialization failed",
|
216
219
|
l,
|
@@ -222,8 +225,8 @@ const te = (e) => {
|
|
222
225
|
}, k = async (h) => {
|
223
226
|
try {
|
224
227
|
a.value = !0, l.value = null, t.logger.info("[Vuethenticate] useAuth: Starting sign-in flow"), await r.signinRedirect({ state: h });
|
225
|
-
} catch (
|
226
|
-
t.logger.error("[Vuethenticate] useAuth: Sign-in failed",
|
228
|
+
} catch (u) {
|
229
|
+
t.logger.error("[Vuethenticate] useAuth: Sign-in failed", u), U(u, "Sign in failed", l, e.onError);
|
227
230
|
} finally {
|
228
231
|
a.value = !1;
|
229
232
|
}
|
@@ -232,8 +235,8 @@ const te = (e) => {
|
|
232
235
|
a.value = !0, l.value = null, c.value = null, t.logger.info(
|
233
236
|
"[Vuethenticate] useAuth: Starting sign-out flow"
|
234
237
|
), await r.signoutRedirect({ state: h });
|
235
|
-
} catch (
|
236
|
-
t.logger.error("[Vuethenticate] useAuth: Sign-out failed",
|
238
|
+
} catch (u) {
|
239
|
+
t.logger.error("[Vuethenticate] useAuth: Sign-out failed", u), U(u, "Sign out failed", l, e.onError);
|
237
240
|
} finally {
|
238
241
|
a.value = !1;
|
239
242
|
}
|
@@ -243,7 +246,7 @@ const te = (e) => {
|
|
243
246
|
const h = await r.signinSilent();
|
244
247
|
c.value = h;
|
245
248
|
} catch (h) {
|
246
|
-
throw
|
249
|
+
throw U(
|
247
250
|
h,
|
248
251
|
"Silent renewal failed",
|
249
252
|
l,
|
@@ -252,37 +255,37 @@ const te = (e) => {
|
|
252
255
|
} finally {
|
253
256
|
a.value = !1;
|
254
257
|
}
|
255
|
-
},
|
258
|
+
}, K = () => {
|
256
259
|
l.value = null;
|
257
|
-
},
|
260
|
+
}, F = (h, u) => {
|
258
261
|
const { userManager: C, user: L, error: Y, eventCallbacks: p } = h;
|
259
262
|
p.userLoaded = (w) => {
|
260
|
-
var
|
261
|
-
L.value = w, (
|
263
|
+
var R;
|
264
|
+
L.value = w, (R = u.onUserLoaded) == null || R.call(u, w);
|
262
265
|
}, p.userUnloaded = () => {
|
263
266
|
var w;
|
264
|
-
L.value = null, (w =
|
267
|
+
L.value = null, (w = u.onUserUnloaded) == null || w.call(u);
|
265
268
|
}, p.accessTokenExpired = () => {
|
266
269
|
var w;
|
267
|
-
(w =
|
270
|
+
(w = u.onAccessTokenExpired) == null || w.call(u);
|
268
271
|
}, p.accessTokenExpiring = () => {
|
269
272
|
var w;
|
270
|
-
(w =
|
273
|
+
(w = u.onAccessTokenExpiring) == null || w.call(u);
|
271
274
|
}, p.silentRenewError = async (w) => {
|
272
275
|
console.warn("Silent renewal failed:", w);
|
273
276
|
try {
|
274
277
|
await C.removeUser(), L.value = null;
|
275
|
-
} catch (
|
278
|
+
} catch (R) {
|
276
279
|
console.error(
|
277
280
|
"Failed to remove user after silent renewal error:",
|
278
|
-
|
281
|
+
R
|
279
282
|
);
|
280
283
|
}
|
281
|
-
|
284
|
+
U(
|
282
285
|
w,
|
283
286
|
"Silent renewal failed",
|
284
287
|
Y,
|
285
|
-
|
288
|
+
u.onError
|
286
289
|
);
|
287
290
|
}, C.events.addUserLoaded(p.userLoaded), C.events.addUserUnloaded(p.userUnloaded), C.events.addAccessTokenExpired(
|
288
291
|
p.accessTokenExpired
|
@@ -290,11 +293,11 @@ const te = (e) => {
|
|
290
293
|
p.accessTokenExpiring
|
291
294
|
), C.events.addSilentRenewError(p.silentRenewError);
|
292
295
|
}, q = () => {
|
293
|
-
ne(t), A.delete(
|
296
|
+
ne(t), A.delete(i);
|
294
297
|
};
|
295
|
-
return !
|
298
|
+
return !s.value && !n.value && !ue(e) ? (d(), F(t, e)) : !s.value && !n.value && (F(t, e), s.value = !0), {
|
296
299
|
user: c,
|
297
|
-
isAuthenticated:
|
300
|
+
isAuthenticated: o,
|
298
301
|
isLoading: a,
|
299
302
|
error: l,
|
300
303
|
accessToken: b,
|
@@ -302,7 +305,7 @@ const te = (e) => {
|
|
302
305
|
signIn: k,
|
303
306
|
signOut: m,
|
304
307
|
silentRenew: $,
|
305
|
-
clearError:
|
308
|
+
clearError: K,
|
306
309
|
cleanup: q
|
307
310
|
};
|
308
311
|
}, O = () => {
|
@@ -348,7 +351,7 @@ const te = (e) => {
|
|
348
351
|
isInitializing: e.isInitializing,
|
349
352
|
logger: e.logger
|
350
353
|
};
|
351
|
-
},
|
354
|
+
}, he = /* @__PURE__ */ V({
|
352
355
|
__name: "AuthCallback",
|
353
356
|
props: {
|
354
357
|
onSuccess: { type: Function },
|
@@ -356,8 +359,8 @@ const te = (e) => {
|
|
356
359
|
},
|
357
360
|
emits: ["success", "error"],
|
358
361
|
setup(e, { emit: t }) {
|
359
|
-
const r = e,
|
360
|
-
var g,
|
362
|
+
const r = e, s = t, { processCallback: n, isInitializing: c, logger: a } = O(), l = y(!0), o = y(null), b = async () => {
|
363
|
+
var g, i;
|
361
364
|
try {
|
362
365
|
a.info(
|
363
366
|
"[Vuethenticate] AuthCallback: Processing authentication callback"
|
@@ -365,35 +368,35 @@ const te = (e) => {
|
|
365
368
|
const d = await n();
|
366
369
|
a.info(
|
367
370
|
"[Vuethenticate] AuthCallback: Authentication callback completed successfully"
|
368
|
-
), (g = r.onSuccess) == null || g.call(r, d.user, d.state),
|
371
|
+
), (g = r.onSuccess) == null || g.call(r, d.user, d.state), s("success", d.user, d.state);
|
369
372
|
} catch (d) {
|
370
373
|
const k = d instanceof Error ? d : new Error("Callback processing failed");
|
371
374
|
a.error(
|
372
375
|
"[Vuethenticate] AuthCallback: Authentication callback failed",
|
373
376
|
k
|
374
|
-
),
|
377
|
+
), o.value = k, (i = r.onError) == null || i.call(r, k), s("error", k);
|
375
378
|
} finally {
|
376
379
|
l.value = !1;
|
377
380
|
}
|
378
381
|
};
|
379
382
|
return z(() => {
|
380
383
|
b();
|
381
|
-
}), (g,
|
382
|
-
(M(c) || l.value) && !
|
383
|
-
|
384
|
+
}), (g, i) => (W(), _(B, null, [
|
385
|
+
(M(c) || l.value) && !o.value ? S(g.$slots, "default", { key: 0 }, () => [
|
386
|
+
i[0] || (i[0] = v("p", null, "Processing authentication...", -1))
|
384
387
|
]) : I("", !0),
|
385
|
-
|
388
|
+
o.value ? S(g.$slots, "error", {
|
386
389
|
key: 1,
|
387
|
-
error:
|
390
|
+
error: o.value
|
388
391
|
}, () => [
|
389
392
|
v("div", null, [
|
390
|
-
|
391
|
-
v("p", null, x(
|
393
|
+
i[1] || (i[1] = v("h2", null, "Authentication Error", -1)),
|
394
|
+
v("p", null, x(o.value.message), 1)
|
392
395
|
])
|
393
396
|
]) : I("", !0)
|
394
397
|
], 64));
|
395
398
|
}
|
396
|
-
}),
|
399
|
+
}), ke = /* @__PURE__ */ V({
|
397
400
|
__name: "LogoutCallback",
|
398
401
|
props: {
|
399
402
|
onSuccess: { type: Function },
|
@@ -401,8 +404,8 @@ const te = (e) => {
|
|
401
404
|
},
|
402
405
|
emits: ["success", "error"],
|
403
406
|
setup(e, { emit: t }) {
|
404
|
-
const r = e,
|
405
|
-
var g,
|
407
|
+
const r = e, s = t, { processLogoutCallback: n, isInitializing: c, logger: a } = O(), l = y(!0), o = y(null), b = async () => {
|
408
|
+
var g, i;
|
406
409
|
try {
|
407
410
|
a.info(
|
408
411
|
"[Vuethenticate] LogoutCallback: Processing logout callback"
|
@@ -410,50 +413,50 @@ const te = (e) => {
|
|
410
413
|
const d = await n();
|
411
414
|
a.info(
|
412
415
|
"[Vuethenticate] LogoutCallback: Logout callback completed successfully"
|
413
|
-
), (g = r.onSuccess) == null || g.call(r, d.state),
|
416
|
+
), (g = r.onSuccess) == null || g.call(r, d.state), s("success", d.state);
|
414
417
|
} catch (d) {
|
415
418
|
const k = d instanceof Error ? d : new Error("Logout callback processing failed");
|
416
419
|
a.error(
|
417
420
|
"[Vuethenticate] LogoutCallback: Logout callback failed",
|
418
421
|
k
|
419
|
-
),
|
422
|
+
), o.value = k, (i = r.onError) == null || i.call(r, k), s("error", k);
|
420
423
|
} finally {
|
421
424
|
l.value = !1;
|
422
425
|
}
|
423
426
|
};
|
424
427
|
return z(() => {
|
425
428
|
b();
|
426
|
-
}), (g,
|
427
|
-
|
428
|
-
]) :
|
429
|
+
}), (g, i) => (M(c) || l.value) && !o.value ? S(g.$slots, "default", { key: 0 }, () => [
|
430
|
+
i[0] || (i[0] = v("p", null, "Processing logout...", -1))
|
431
|
+
]) : o.value ? S(g.$slots, "error", {
|
429
432
|
key: 1,
|
430
|
-
error:
|
433
|
+
error: o.value
|
431
434
|
}, () => [
|
432
435
|
v("div", null, [
|
433
|
-
|
434
|
-
v("p", null, x(
|
436
|
+
i[1] || (i[1] = v("h2", null, "Logout Error", -1)),
|
437
|
+
v("p", null, x(o.value.message), 1)
|
435
438
|
])
|
436
439
|
]) : S(g.$slots, "success", { key: 2 }, () => [
|
437
|
-
|
440
|
+
i[2] || (i[2] = v("div", null, [
|
438
441
|
v("h2", null, "Logout Successful"),
|
439
442
|
v("p", null, "You have been logged out successfully.")
|
440
443
|
], -1))
|
441
444
|
]);
|
442
445
|
}
|
443
|
-
}),
|
446
|
+
}), we = /* @__PURE__ */ V({
|
444
447
|
__name: "SilentCallback",
|
445
448
|
props: {
|
446
449
|
onError: { type: Function }
|
447
450
|
},
|
448
451
|
setup(e) {
|
449
|
-
const t = e, { processSilentCallback: r, isInitializing:
|
452
|
+
const t = e, { processSilentCallback: r, isInitializing: s, logger: n } = O(), c = y(null), a = async () => {
|
450
453
|
var l;
|
451
454
|
try {
|
452
455
|
n.debug(
|
453
456
|
"[Vuethenticate] SilentCallback: Processing silent callback"
|
454
457
|
), await r();
|
455
|
-
} catch (
|
456
|
-
const b =
|
458
|
+
} catch (o) {
|
459
|
+
const b = o instanceof Error ? o : new Error("Silent callback processing failed");
|
457
460
|
n.error(
|
458
461
|
"[Vuethenticate] SilentCallback: Silent callback failed",
|
459
462
|
b
|
@@ -462,9 +465,9 @@ const te = (e) => {
|
|
462
465
|
};
|
463
466
|
return z(() => {
|
464
467
|
a();
|
465
|
-
}), (l,
|
466
|
-
M(
|
467
|
-
|
468
|
+
}), (l, o) => (W(), _(B, null, [
|
469
|
+
M(s) && !c.value ? S(l.$slots, "default", { key: 0 }, () => [
|
470
|
+
o[0] || (o[0] = v("p", null, "Processing silent renewal...", -1))
|
468
471
|
]) : I("", !0),
|
469
472
|
c.value ? S(l.$slots, "error", {
|
470
473
|
key: 1,
|
@@ -476,11 +479,11 @@ const te = (e) => {
|
|
476
479
|
}
|
477
480
|
});
|
478
481
|
export {
|
479
|
-
|
482
|
+
he as AuthCallback,
|
480
483
|
f as LogLevel,
|
481
|
-
|
482
|
-
|
484
|
+
ke as LogoutCallback,
|
485
|
+
we as SilentCallback,
|
483
486
|
D as consoleLogger,
|
484
487
|
Q as silentLogger,
|
485
|
-
|
488
|
+
ge as useAuth
|
486
489
|
};
|
package/dist/index.umd.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
(function(f,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue"),require("oidc-client-ts")):typeof define=="function"&&define.amd?define(["exports","vue","oidc-client-ts"],r):(f=typeof globalThis<"u"?globalThis:f||self,r(f.Vuethenticate={},f.Vue,f.OidcClientTs))})(this,function(f,r,y){"use strict";var b=(e=>(e[e.NONE=0]="NONE",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG",e))(b||{});const v={error:(e,...t)=>console.error(e,...t),warn:(e,...t)=>console.warn(e,...t),info:(e,...t)=>console.info(e,...t),debug:(e,...t)=>console.debug(e,...t)},I={error:()=>{},warn:()=>{},info:()=>{},debug:()=>{}},T=(e,t)=>({error:t>=1?e.error:()=>{},warn:t>=2?e.warn:()=>{},info:t>=3?e.info:()=>{},debug:t>=4?e.debug:()=>{}});function x(e){const t=typeof window<"u"?window.location.origin:"";return F(e),{authority:e.authority,client_id:e.clientId,client_secret:e.clientSecret,client_authentication:e.clientAuthentication,redirect_uri:e.redirectUri??`${t}/auth/callback`,scope:e.scope??"openid profile",response_type:e.responseType??"code",userStore:e.storage?new y.WebStorageStateStore({store:$(e.storage)}):void 0,automaticSilentRenew:e.automaticSilentRenew??!0,silent_redirect_uri:e.silentRedirectUri??`${t}/auth/silent-callback`,post_logout_redirect_uri:e.postLogoutRedirectUri??`${t}/auth/logout-callback`,includeIdTokenInSilentRenew:!0,accessTokenExpiringNotificationTimeInSeconds:60}}function $(e){if(typeof window>"u")return M();switch(e){case"localStorage":return window.localStorage;case"sessionStorage":return window.sessionStorage;case"memory":return M();default:return window.localStorage}}function M(){const e=new Map;return{getItem:t=>e.get(t)??null,setItem:(t,n)=>e.set(t,n),removeItem:t=>e.delete(t),clear:()=>e.clear(),get length(){return e.size},key:t=>Array.from(e.keys())[t]??null}}const F=e=>{if(e.logLevel===void 0&&!e.logger)return;const t=e.logger??(e.logLevel!==void 0?v:void 0),n=e.logLevel??b.NONE;t&&(y.Log.setLogger({error:t.error,warn:t.warn,info:t.info,debug:t.debug}),y.Log.setLevel(P(n)))},P=e=>{switch(e){case b.NONE:return y.Log.NONE;case b.ERROR:return y.Log.ERROR;case b.WARN:return y.Log.WARN;case b.INFO:return y.Log.INFO;case b.DEBUG:return y.Log.DEBUG;default:return y.Log.NONE}},S=new Map,_=e=>{try{const{userManager:t,eventCallbacks:n}=e;n.userLoaded&&t.events.removeUserLoaded(n.userLoaded),n.userUnloaded&&t.events.removeUserUnloaded(n.userUnloaded),n.accessTokenExpired&&t.events.removeAccessTokenExpired(n.accessTokenExpired),n.accessTokenExpiring&&t.events.removeAccessTokenExpiring(n.accessTokenExpiring),n.silentRenewError&&t.events.removeSilentRenewError(n.silentRenewError),t.stopSilentRenew(),t.clearStaleState()}catch(t){console.warn("Error during UserManager cleanup:",t)}},z=e=>`${e.authority}_${e.clientId}`,B=()=>S.size===0?null:(S.size===1||console.warn("Multiple auth instances detected. Callback components may not work as expected. Consider using a single auth instance or specify config explicitly."),Array.from(S.values())[0]||null),D=e=>{const t=z(e),n=S.get(t);if(n)return n;const u=W(e),a=r.ref(!1),d=r.ref(!1),l=r.ref(null),o=r.ref(!1),s=r.ref(null),E=r.computed(()=>!!l.value&&!l.value.expired),h=r.computed(()=>{var A;return((A=l.value)==null?void 0:A.access_token)||null}),i=r.computed(()=>{var A;return!!((A=l.value)!=null&&A.expired)}),g=q(e),m={userManager:u,isInitialized:a,isInitializing:d,user:l,isLoading:o,error:s,isAuthenticated:E,accessToken:h,isExpired:i,logger:g,eventCallbacks:{}};return S.set(t,m),m},W=e=>{const t=x(e);return new y.UserManager(t)},q=e=>{if(!e.logger&&!e.logLevel)return I;const t=e.logger??v,n=e.logLevel??b.NONE;return T(t,n)},V=(e,t,n,u)=>{const a=e instanceof Error?e:new Error(t);return n.value=a,u==null||u(a),a},G=e=>{var t,n;if(!((t=e.authority)!=null&&t.trim()))throw new Error("AuthConfig: authority is required");if(!((n=e.clientId)!=null&&n.trim()))throw new Error("AuthConfig: clientId is required");try{new URL(e.authority)}catch{throw new Error("AuthConfig: authority must be a valid URL")}},L=async(e,t=1e4)=>{if(!e.isInitialized.value)return new Promise((n,u)=>{const a=setTimeout(()=>{u(new Error("Authentication initialization timeout"))},t),d=r.watch(e.isInitialized,l=>{l&&(clearTimeout(a),d(),n())},{immediate:!0})})},K=e=>{G(e);const t=D(e),{userManager:n,isInitialized:u,isInitializing:a,user:d,isLoading:l,error:o,isAuthenticated:s,accessToken:E,isExpired:h}=t,i=z(e),g=async()=>{if(!(a.value||u.value))try{a.value=!0,l.value=!0,o.value=null;const k=await n.getUser();if(k)if(!k.expired)d.value=k,t.logger.info("[Vuethenticate] useAuth: User restored from storage");else if(e.automaticSilentRenew!==!1){t.logger.info("[Vuethenticate] useAuth: Token expired, attempting silent renewal");try{await O()}catch(c){t.logger.warn("[Vuethenticate] useAuth: Silent renewal failed during initialization",c),await n.removeUser(),d.value=null}}else await n.removeUser(),d.value=null;u.value=!0}catch(k){t.logger.error("[Vuethenticate] useAuth: Initialization failed",k),V(k,"Authentication initialization failed",o,e.onError)}finally{a.value=!1,l.value=!1}},m=async k=>{try{l.value=!0,o.value=null,t.logger.info("[Vuethenticate] useAuth: Starting sign-in flow"),await n.signinRedirect({state:k})}catch(c){t.logger.error("[Vuethenticate] useAuth: Sign-in failed",c),V(c,"Sign in failed",o,e.onError)}finally{l.value=!1}},A=async k=>{try{l.value=!0,o.value=null,d.value=null,t.logger.info("[Vuethenticate] useAuth: Starting sign-out flow"),await n.signoutRedirect({state:k})}catch(c){t.logger.error("[Vuethenticate] useAuth: Sign-out failed",c),V(c,"Sign out failed",o,e.onError)}finally{l.value=!1}},O=async()=>{try{l.value=!0,o.value=null;const k=await n.signinSilent();d.value=k}catch(k){throw V(k,"Silent renewal failed",o,e.onError)}finally{l.value=!1}},J=()=>{o.value=null},Q=(k,c)=>{const{userManager:C,user:U,error:Z,eventCallbacks:p}=k;p.userLoaded=w=>{var N;U.value=w,(N=c.onUserLoaded)==null||N.call(c,w)},p.userUnloaded=()=>{var w;U.value=null,(w=c.onUserUnloaded)==null||w.call(c)},p.accessTokenExpired=()=>{var w;(w=c.onAccessTokenExpired)==null||w.call(c)},p.accessTokenExpiring=()=>{var w;(w=c.onAccessTokenExpiring)==null||w.call(c)},p.silentRenewError=async w=>{console.warn("Silent renewal failed:",w);try{await C.removeUser(),U.value=null}catch(N){console.error("Failed to remove user after silent renewal error:",N)}V(w,"Silent renewal failed",Z,c.onError)},C.events.addUserLoaded(p.userLoaded),C.events.addUserUnloaded(p.userUnloaded),C.events.addAccessTokenExpired(p.accessTokenExpired),C.events.addAccessTokenExpiring(p.accessTokenExpiring),C.events.addSilentRenewError(p.silentRenewError)},X=()=>{_(t),S.delete(i)};return!u.value&&!a.value&&(g(),Q(t,e)),{user:d,isAuthenticated:s,isLoading:l,error:o,accessToken:E,isExpired:h,signIn:m,signOut:A,silentRenew:O,clearError:J,cleanup:X}},R=()=>{const e=B();if(!e)throw new Error("Authentication not initialized. Make sure useAuth() is called in a parent component first.");return{processCallback:async()=>{await L(e),e.logger.info("[Vuethenticate] useAuthCallbacks: Processing authentication callback");const a=await e.userManager.signinCallback();if(!a)throw new Error("Authentication callback failed: no user returned");return e.logger.info("[Vuethenticate] useAuthCallbacks: Authentication callback successful"),{user:a,state:a.state}},processLogoutCallback:async()=>{await L(e),e.logger.debug("[Vuethenticate] useAuthCallbacks: Processing logout callback");const a=await e.userManager.signoutCallback();return e.logger.info("[Vuethenticate] useAuthCallbacks: Logout callback completed successfully"),{state:a==null?void 0:a.userState}},processSilentCallback:async()=>{await L(e),e.logger.debug("[Vuethenticate] useAuthCallbacks: Processing silent callback"),await e.userManager.signinCallback(),e.logger.debug("[Vuethenticate] useAuthCallbacks: Silent callback completed successfully")},isInitialized:e.isInitialized,isInitializing:e.isInitializing,logger:e.logger}},j=r.defineComponent({__name:"AuthCallback",props:{onSuccess:{type:Function},onError:{type:Function}},emits:["success","error"],setup(e,{emit:t}){const n=e,u=t,{processCallback:a,isInitializing:d,logger:l}=R(),o=r.ref(!0),s=r.ref(null),E=async()=>{var h,i;try{l.info("[Vuethenticate] AuthCallback: Processing authentication callback");const g=await a();l.info("[Vuethenticate] AuthCallback: Authentication callback completed successfully"),(h=n.onSuccess)==null||h.call(n,g.user,g.state),u("success",g.user,g.state)}catch(g){const m=g instanceof Error?g:new Error("Callback processing failed");l.error("[Vuethenticate] AuthCallback: Authentication callback failed",m),s.value=m,(i=n.onError)==null||i.call(n,m),u("error",m)}finally{o.value=!1}};return r.onMounted(()=>{E()}),(h,i)=>(r.openBlock(),r.createElementBlock(r.Fragment,null,[(r.unref(d)||o.value)&&!s.value?r.renderSlot(h.$slots,"default",{key:0},()=>[i[0]||(i[0]=r.createElementVNode("p",null,"Processing authentication...",-1))]):r.createCommentVNode("",!0),s.value?r.renderSlot(h.$slots,"error",{key:1,error:s.value},()=>[r.createElementVNode("div",null,[i[1]||(i[1]=r.createElementVNode("h2",null,"Authentication Error",-1)),r.createElementVNode("p",null,r.toDisplayString(s.value.message),1)])]):r.createCommentVNode("",!0)],64))}}),Y=r.defineComponent({__name:"LogoutCallback",props:{onSuccess:{type:Function},onError:{type:Function}},emits:["success","error"],setup(e,{emit:t}){const n=e,u=t,{processLogoutCallback:a,isInitializing:d,logger:l}=R(),o=r.ref(!0),s=r.ref(null),E=async()=>{var h,i;try{l.info("[Vuethenticate] LogoutCallback: Processing logout callback");const g=await a();l.info("[Vuethenticate] LogoutCallback: Logout callback completed successfully"),(h=n.onSuccess)==null||h.call(n,g.state),u("success",g.state)}catch(g){const m=g instanceof Error?g:new Error("Logout callback processing failed");l.error("[Vuethenticate] LogoutCallback: Logout callback failed",m),s.value=m,(i=n.onError)==null||i.call(n,m),u("error",m)}finally{o.value=!1}};return r.onMounted(()=>{E()}),(h,i)=>(r.unref(d)||o.value)&&!s.value?r.renderSlot(h.$slots,"default",{key:0},()=>[i[0]||(i[0]=r.createElementVNode("p",null,"Processing logout...",-1))]):s.value?r.renderSlot(h.$slots,"error",{key:1,error:s.value},()=>[r.createElementVNode("div",null,[i[1]||(i[1]=r.createElementVNode("h2",null,"Logout Error",-1)),r.createElementVNode("p",null,r.toDisplayString(s.value.message),1)])]):r.renderSlot(h.$slots,"success",{key:2},()=>[i[2]||(i[2]=r.createElementVNode("div",null,[r.createElementVNode("h2",null,"Logout Successful"),r.createElementVNode("p",null,"You have been logged out successfully.")],-1))])}}),H=r.defineComponent({__name:"SilentCallback",props:{onError:{type:Function}},setup(e){const t=e,{processSilentCallback:n,isInitializing:u,logger:a}=R(),d=r.ref(null),l=async()=>{var o;try{a.debug("[Vuethenticate] SilentCallback: Processing silent callback"),await n()}catch(s){const E=s instanceof Error?s:new Error("Silent callback processing failed");a.error("[Vuethenticate] SilentCallback: Silent callback failed",E),d.value=E,(o=t.onError)==null||o.call(t,E)}};return r.onMounted(()=>{l()}),(o,s)=>(r.openBlock(),r.createElementBlock(r.Fragment,null,[r.unref(u)&&!d.value?r.renderSlot(o.$slots,"default",{key:0},()=>[s[0]||(s[0]=r.createElementVNode("p",null,"Processing silent renewal...",-1))]):r.createCommentVNode("",!0),d.value?r.renderSlot(o.$slots,"error",{key:1,error:d.value},()=>[r.createElementVNode("p",null,"Silent renewal error: "+r.toDisplayString(d.value.message),1)]):r.createCommentVNode("",!0)],64))}});f.AuthCallback=j,f.LogLevel=b,f.LogoutCallback=Y,f.SilentCallback=H,f.consoleLogger=v,f.silentLogger=I,f.useAuth=K,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
|
1
|
+
(function(f,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue"),require("oidc-client-ts")):typeof define=="function"&&define.amd?define(["exports","vue","oidc-client-ts"],r):(f=typeof globalThis<"u"?globalThis:f||self,r(f.Vuethenticate={},f.Vue,f.OidcClientTs))})(this,function(f,r,p){"use strict";var b=(e=>(e[e.NONE=0]="NONE",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG",e))(b||{});const V={error:(e,...t)=>console.error(e,...t),warn:(e,...t)=>console.warn(e,...t),info:(e,...t)=>console.info(e,...t),debug:(e,...t)=>console.debug(e,...t)},I={error:()=>{},warn:()=>{},info:()=>{},debug:()=>{}},x=(e,t)=>({error:t>=1?e.error:()=>{},warn:t>=2?e.warn:()=>{},info:t>=3?e.info:()=>{},debug:t>=4?e.debug:()=>{}});function $(e){const t=typeof window<"u"?window.location.origin:"";return P(e),{authority:e.authority,client_id:e.clientId,client_secret:e.clientSecret,client_authentication:e.clientAuthentication,redirect_uri:e.redirectUri??`${t}/auth/callback`,scope:e.scope??"openid profile",response_type:e.responseType??"code",userStore:e.storage?new p.WebStorageStateStore({store:F(e.storage)}):void 0,automaticSilentRenew:e.automaticSilentRenew??!0,silent_redirect_uri:e.silentRedirectUri??`${t}/auth/silent-callback`,post_logout_redirect_uri:e.postLogoutRedirectUri??`${t}/auth/logout-callback`,includeIdTokenInSilentRenew:!0,accessTokenExpiringNotificationTimeInSeconds:60}}function F(e){if(typeof window>"u")return M();switch(e){case"localStorage":return window.localStorage;case"sessionStorage":return window.sessionStorage;case"memory":return M();default:return window.localStorage}}function M(){const e=new Map;return{getItem:t=>e.get(t)??null,setItem:(t,n)=>e.set(t,n),removeItem:t=>e.delete(t),clear:()=>e.clear(),get length(){return e.size},key:t=>Array.from(e.keys())[t]??null}}const P=e=>{if(e.logLevel===void 0&&!e.logger)return;const t=e.logger??(e.logLevel!==void 0?V:void 0),n=e.logLevel??b.NONE;t&&(p.Log.setLogger({error:t.error,warn:t.warn,info:t.info,debug:t.debug}),p.Log.setLevel(_(n)))},_=e=>{switch(e){case b.NONE:return p.Log.NONE;case b.ERROR:return p.Log.ERROR;case b.WARN:return p.Log.WARN;case b.INFO:return p.Log.INFO;case b.DEBUG:return p.Log.DEBUG;default:return p.Log.NONE}},S=new Map,B=e=>{try{const{userManager:t,eventCallbacks:n}=e;n.userLoaded&&t.events.removeUserLoaded(n.userLoaded),n.userUnloaded&&t.events.removeUserUnloaded(n.userUnloaded),n.accessTokenExpired&&t.events.removeAccessTokenExpired(n.accessTokenExpired),n.accessTokenExpiring&&t.events.removeAccessTokenExpiring(n.accessTokenExpiring),n.silentRenewError&&t.events.removeSilentRenewError(n.silentRenewError),t.stopSilentRenew(),t.clearStaleState()}catch(t){console.warn("Error during UserManager cleanup:",t)}},z=e=>`${e.authority}_${e.clientId}`,W=()=>S.size===0?null:(S.size===1||console.warn("Multiple auth instances detected. Callback components may not work as expected. Consider using a single auth instance or specify config explicitly."),Array.from(S.values())[0]||null),D=e=>{const t=z(e),n=S.get(t);if(n)return n;const s=q(e),a=r.ref(!1),d=r.ref(!1),l=r.ref(null),o=r.ref(!1),i=r.ref(null),E=r.computed(()=>!!l.value&&!l.value.expired),h=r.computed(()=>{var A;return((A=l.value)==null?void 0:A.access_token)||null}),c=r.computed(()=>{var A;return!!((A=l.value)!=null&&A.expired)}),g=G(e),w={userManager:s,isInitialized:a,isInitializing:d,user:l,isLoading:o,error:i,isAuthenticated:E,accessToken:h,isExpired:c,logger:g,eventCallbacks:{}};return S.set(t,w),w},q=e=>{const t=$(e);return new p.UserManager(t)},G=e=>{if(!e.logger&&!e.logLevel)return I;const t=e.logger??V,n=e.logLevel??b.NONE;return x(t,n)},U=(e,t,n,s)=>{const a=e instanceof Error?e:new Error(t);return n.value=a,s==null||s(a),a},K=e=>{var t,n;if(!((t=e.authority)!=null&&t.trim()))throw new Error("AuthConfig: authority is required");if(!((n=e.clientId)!=null&&n.trim()))throw new Error("AuthConfig: clientId is required");try{new URL(e.authority)}catch{throw new Error("AuthConfig: authority must be a valid URL")}},N=async(e,t=1e4)=>{if(!e.isInitialized.value)return new Promise((n,s)=>{const a=setTimeout(()=>{s(new Error("Authentication initialization timeout"))},t),d=r.watch(e.isInitialized,l=>{l&&(clearTimeout(a),d(),n())},{immediate:!0})})},j=e=>{const t=window.location.href;return!!(e.silentRedirectUri&&t.startsWith(e.silentRedirectUri)||e.redirectUri&&t.startsWith(e.redirectUri)||e.postLogoutRedirectUri&&t.startsWith(e.postLogoutRedirectUri))},Y=e=>{K(e);const t=D(e),{userManager:n,isInitialized:s,isInitializing:a,user:d,isLoading:l,error:o,isAuthenticated:i,accessToken:E,isExpired:h}=t,c=z(e),g=async()=>{if(!(a.value||s.value))try{a.value=!0,l.value=!0,o.value=null;const k=await n.getUser();if(k)if(!k.expired)d.value=k,t.logger.info("[Vuethenticate] useAuth: User restored from storage");else if(e.automaticSilentRenew!==!1){t.logger.info("[Vuethenticate] useAuth: Token expired, attempting silent renewal");try{await O()}catch(u){t.logger.warn("[Vuethenticate] useAuth: Silent renewal failed during initialization",u),await n.removeUser(),d.value=null}}else await n.removeUser(),d.value=null;s.value=!0}catch(k){t.logger.error("[Vuethenticate] useAuth: Initialization failed",k),U(k,"Authentication initialization failed",o,e.onError)}finally{a.value=!1,l.value=!1}},w=async k=>{try{l.value=!0,o.value=null,t.logger.info("[Vuethenticate] useAuth: Starting sign-in flow"),await n.signinRedirect({state:k})}catch(u){t.logger.error("[Vuethenticate] useAuth: Sign-in failed",u),U(u,"Sign in failed",o,e.onError)}finally{l.value=!1}},A=async k=>{try{l.value=!0,o.value=null,d.value=null,t.logger.info("[Vuethenticate] useAuth: Starting sign-out flow"),await n.signoutRedirect({state:k})}catch(u){t.logger.error("[Vuethenticate] useAuth: Sign-out failed",u),U(u,"Sign out failed",o,e.onError)}finally{l.value=!1}},O=async()=>{try{l.value=!0,o.value=null;const k=await n.signinSilent();d.value=k}catch(k){throw U(k,"Silent renewal failed",o,e.onError)}finally{l.value=!1}},X=()=>{o.value=null},T=(k,u)=>{const{userManager:C,user:R,error:ee,eventCallbacks:y}=k;y.userLoaded=m=>{var v;R.value=m,(v=u.onUserLoaded)==null||v.call(u,m)},y.userUnloaded=()=>{var m;R.value=null,(m=u.onUserUnloaded)==null||m.call(u)},y.accessTokenExpired=()=>{var m;(m=u.onAccessTokenExpired)==null||m.call(u)},y.accessTokenExpiring=()=>{var m;(m=u.onAccessTokenExpiring)==null||m.call(u)},y.silentRenewError=async m=>{console.warn("Silent renewal failed:",m);try{await C.removeUser(),R.value=null}catch(v){console.error("Failed to remove user after silent renewal error:",v)}U(m,"Silent renewal failed",ee,u.onError)},C.events.addUserLoaded(y.userLoaded),C.events.addUserUnloaded(y.userUnloaded),C.events.addAccessTokenExpired(y.accessTokenExpired),C.events.addAccessTokenExpiring(y.accessTokenExpiring),C.events.addSilentRenewError(y.silentRenewError)},Z=()=>{B(t),S.delete(c)};return!s.value&&!a.value&&!j(e)?(g(),T(t,e)):!s.value&&!a.value&&(T(t,e),s.value=!0),{user:d,isAuthenticated:i,isLoading:l,error:o,accessToken:E,isExpired:h,signIn:w,signOut:A,silentRenew:O,clearError:X,cleanup:Z}},L=()=>{const e=W();if(!e)throw new Error("Authentication not initialized. Make sure useAuth() is called in a parent component first.");return{processCallback:async()=>{await N(e),e.logger.info("[Vuethenticate] useAuthCallbacks: Processing authentication callback");const a=await e.userManager.signinCallback();if(!a)throw new Error("Authentication callback failed: no user returned");return e.logger.info("[Vuethenticate] useAuthCallbacks: Authentication callback successful"),{user:a,state:a.state}},processLogoutCallback:async()=>{await N(e),e.logger.debug("[Vuethenticate] useAuthCallbacks: Processing logout callback");const a=await e.userManager.signoutCallback();return e.logger.info("[Vuethenticate] useAuthCallbacks: Logout callback completed successfully"),{state:a==null?void 0:a.userState}},processSilentCallback:async()=>{await N(e),e.logger.debug("[Vuethenticate] useAuthCallbacks: Processing silent callback"),await e.userManager.signinCallback(),e.logger.debug("[Vuethenticate] useAuthCallbacks: Silent callback completed successfully")},isInitialized:e.isInitialized,isInitializing:e.isInitializing,logger:e.logger}},H=r.defineComponent({__name:"AuthCallback",props:{onSuccess:{type:Function},onError:{type:Function}},emits:["success","error"],setup(e,{emit:t}){const n=e,s=t,{processCallback:a,isInitializing:d,logger:l}=L(),o=r.ref(!0),i=r.ref(null),E=async()=>{var h,c;try{l.info("[Vuethenticate] AuthCallback: Processing authentication callback");const g=await a();l.info("[Vuethenticate] AuthCallback: Authentication callback completed successfully"),(h=n.onSuccess)==null||h.call(n,g.user,g.state),s("success",g.user,g.state)}catch(g){const w=g instanceof Error?g:new Error("Callback processing failed");l.error("[Vuethenticate] AuthCallback: Authentication callback failed",w),i.value=w,(c=n.onError)==null||c.call(n,w),s("error",w)}finally{o.value=!1}};return r.onMounted(()=>{E()}),(h,c)=>(r.openBlock(),r.createElementBlock(r.Fragment,null,[(r.unref(d)||o.value)&&!i.value?r.renderSlot(h.$slots,"default",{key:0},()=>[c[0]||(c[0]=r.createElementVNode("p",null,"Processing authentication...",-1))]):r.createCommentVNode("",!0),i.value?r.renderSlot(h.$slots,"error",{key:1,error:i.value},()=>[r.createElementVNode("div",null,[c[1]||(c[1]=r.createElementVNode("h2",null,"Authentication Error",-1)),r.createElementVNode("p",null,r.toDisplayString(i.value.message),1)])]):r.createCommentVNode("",!0)],64))}}),J=r.defineComponent({__name:"LogoutCallback",props:{onSuccess:{type:Function},onError:{type:Function}},emits:["success","error"],setup(e,{emit:t}){const n=e,s=t,{processLogoutCallback:a,isInitializing:d,logger:l}=L(),o=r.ref(!0),i=r.ref(null),E=async()=>{var h,c;try{l.info("[Vuethenticate] LogoutCallback: Processing logout callback");const g=await a();l.info("[Vuethenticate] LogoutCallback: Logout callback completed successfully"),(h=n.onSuccess)==null||h.call(n,g.state),s("success",g.state)}catch(g){const w=g instanceof Error?g:new Error("Logout callback processing failed");l.error("[Vuethenticate] LogoutCallback: Logout callback failed",w),i.value=w,(c=n.onError)==null||c.call(n,w),s("error",w)}finally{o.value=!1}};return r.onMounted(()=>{E()}),(h,c)=>(r.unref(d)||o.value)&&!i.value?r.renderSlot(h.$slots,"default",{key:0},()=>[c[0]||(c[0]=r.createElementVNode("p",null,"Processing logout...",-1))]):i.value?r.renderSlot(h.$slots,"error",{key:1,error:i.value},()=>[r.createElementVNode("div",null,[c[1]||(c[1]=r.createElementVNode("h2",null,"Logout Error",-1)),r.createElementVNode("p",null,r.toDisplayString(i.value.message),1)])]):r.renderSlot(h.$slots,"success",{key:2},()=>[c[2]||(c[2]=r.createElementVNode("div",null,[r.createElementVNode("h2",null,"Logout Successful"),r.createElementVNode("p",null,"You have been logged out successfully.")],-1))])}}),Q=r.defineComponent({__name:"SilentCallback",props:{onError:{type:Function}},setup(e){const t=e,{processSilentCallback:n,isInitializing:s,logger:a}=L(),d=r.ref(null),l=async()=>{var o;try{a.debug("[Vuethenticate] SilentCallback: Processing silent callback"),await n()}catch(i){const E=i instanceof Error?i:new Error("Silent callback processing failed");a.error("[Vuethenticate] SilentCallback: Silent callback failed",E),d.value=E,(o=t.onError)==null||o.call(t,E)}};return r.onMounted(()=>{l()}),(o,i)=>(r.openBlock(),r.createElementBlock(r.Fragment,null,[r.unref(s)&&!d.value?r.renderSlot(o.$slots,"default",{key:0},()=>[i[0]||(i[0]=r.createElementVNode("p",null,"Processing silent renewal...",-1))]):r.createCommentVNode("",!0),d.value?r.renderSlot(o.$slots,"error",{key:1,error:d.value},()=>[r.createElementVNode("p",null,"Silent renewal error: "+r.toDisplayString(d.value.message),1)]):r.createCommentVNode("",!0)],64))}});f.AuthCallback=H,f.LogLevel=b,f.LogoutCallback=J,f.SilentCallback=Q,f.consoleLogger=V,f.silentLogger=I,f.useAuth=Y,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
|