vuethenticate 0.1.8 → 0.1.10

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.
@@ -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;AAsPvB;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,MAAM,GAAG,OAAO,EACpC,QAAQ,UAAU,KACnB,aAAa,CAAC,MAAM,CAwOtB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GACzB,MAAM,GAAG,OAAO,OACf,sBAAsB,CAAC,MAAM,CAgFjC,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,CAgPtB,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 P, openBlock as _, Fragment as B, renderSlot as S, createCommentVNode as I, unref as M, createElementVNode as v, toDisplayString as x } from "vue";
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 F();
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 F();
55
+ return P();
56
56
  default:
57
57
  return window.localStorage;
58
58
  }
59
59
  }
60
- function F() {
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
- }, W = (e) => `${e.authority}_${e.clientId}`, ae = () => A.size === 0 ? null : (A.size === 1 || console.warn(
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 = W(e), r = A.get(t);
114
+ const t = G(e), r = A.get(t);
115
115
  if (r)
116
116
  return r;
117
- const u = se(e), n = y(!1), c = y(!1), a = y(null), l = y(!1), s = y(null), b = N(() => !!a.value && !a.value.expired), g = N(() => {
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
- }), o = N(() => {
120
+ }), i = N(() => {
121
121
  var m;
122
122
  return !!((m = a.value) != null && m.expired);
123
123
  }), d = oe(e), k = {
124
- userManager: u,
124
+ userManager: s,
125
125
  isInitialized: n,
126
126
  isInitializing: c,
127
127
  user: a,
128
128
  isLoading: l,
129
- error: s,
129
+ error: o,
130
130
  isAuthenticated: b,
131
131
  accessToken: g,
132
- isExpired: o,
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
- }, R = (e, t, r, u) => {
145
+ }, U = (e, t, r, s) => {
146
146
  const n = e instanceof Error ? e : new Error(t);
147
- return r.value = n, u == null || u(n), 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, u) => {
161
+ return new Promise((r, s) => {
162
162
  const n = setTimeout(() => {
163
- u(new Error("Authentication initialization timeout"));
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
- }, de = (e) => {
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: u,
179
+ isInitialized: s,
177
180
  isInitializing: n,
178
181
  user: c,
179
182
  isLoading: a,
180
183
  error: l,
181
- isAuthenticated: s,
184
+ isAuthenticated: o,
182
185
  accessToken: b,
183
186
  isExpired: g
184
- } = t, o = W(e), d = async () => {
185
- if (!(n.value || u.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 (i) {
203
+ } catch (u) {
201
204
  t.logger.warn(
202
205
  "[Vuethenticate] useAuth: Silent renewal failed during initialization",
203
- i
206
+ u
204
207
  ), await r.removeUser(), c.value = null;
205
208
  }
206
209
  } else
207
210
  await r.removeUser(), c.value = null;
208
- u.value = !0;
211
+ s.value = !0;
209
212
  } catch (h) {
210
213
  t.logger.error(
211
214
  "[Vuethenticate] useAuth: Initialization failed",
212
215
  h
213
- ), R(
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 (i) {
226
- t.logger.error("[Vuethenticate] useAuth: Sign-in failed", i), R(i, "Sign in failed", l, e.onError);
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 (i) {
236
- t.logger.error("[Vuethenticate] useAuth: Sign-out failed", i), R(i, "Sign out failed", l, e.onError);
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 R(
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
- }, G = () => {
258
+ }, K = () => {
256
259
  l.value = null;
257
- }, K = (h, i) => {
260
+ }, F = (h, u) => {
258
261
  const { userManager: C, user: L, error: Y, eventCallbacks: p } = h;
259
262
  p.userLoaded = (w) => {
260
- var U;
261
- L.value = w, (U = i.onUserLoaded) == null || U.call(i, 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 = i.onUserUnloaded) == null || w.call(i);
267
+ L.value = null, (w = u.onUserUnloaded) == null || w.call(u);
265
268
  }, p.accessTokenExpired = () => {
266
269
  var w;
267
- (w = i.onAccessTokenExpired) == null || w.call(i);
270
+ (w = u.onAccessTokenExpired) == null || w.call(u);
268
271
  }, p.accessTokenExpiring = () => {
269
272
  var w;
270
- (w = i.onAccessTokenExpiring) == null || w.call(i);
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 (U) {
278
+ } catch (R) {
276
279
  console.error(
277
280
  "Failed to remove user after silent renewal error:",
278
- U
281
+ R
279
282
  );
280
283
  }
281
- R(
284
+ U(
282
285
  w,
283
286
  "Silent renewal failed",
284
287
  Y,
285
- i.onError
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,19 +293,20 @@ const te = (e) => {
290
293
  p.accessTokenExpiring
291
294
  ), C.events.addSilentRenewError(p.silentRenewError);
292
295
  }, q = () => {
293
- ne(t), A.delete(o);
296
+ ne(t), A.delete(i);
294
297
  };
295
- return !u.value && !n.value && (d(), K(t, e)), {
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: s,
300
+ isAuthenticated: o,
298
301
  isLoading: a,
302
+ isInitialized: s,
299
303
  error: l,
300
304
  accessToken: b,
301
305
  isExpired: g,
302
306
  signIn: k,
303
307
  signOut: m,
304
308
  silentRenew: $,
305
- clearError: G,
309
+ clearError: K,
306
310
  cleanup: q
307
311
  };
308
312
  }, O = () => {
@@ -348,7 +352,7 @@ const te = (e) => {
348
352
  isInitializing: e.isInitializing,
349
353
  logger: e.logger
350
354
  };
351
- }, ge = /* @__PURE__ */ V({
355
+ }, he = /* @__PURE__ */ V({
352
356
  __name: "AuthCallback",
353
357
  props: {
354
358
  onSuccess: { type: Function },
@@ -356,8 +360,8 @@ const te = (e) => {
356
360
  },
357
361
  emits: ["success", "error"],
358
362
  setup(e, { emit: t }) {
359
- const r = e, u = t, { processCallback: n, isInitializing: c, logger: a } = O(), l = y(!0), s = y(null), b = async () => {
360
- var g, o;
363
+ const r = e, s = t, { processCallback: n, isInitializing: c, logger: a } = O(), l = y(!0), o = y(null), b = async () => {
364
+ var g, i;
361
365
  try {
362
366
  a.info(
363
367
  "[Vuethenticate] AuthCallback: Processing authentication callback"
@@ -365,35 +369,35 @@ const te = (e) => {
365
369
  const d = await n();
366
370
  a.info(
367
371
  "[Vuethenticate] AuthCallback: Authentication callback completed successfully"
368
- ), (g = r.onSuccess) == null || g.call(r, d.user, d.state), u("success", d.user, d.state);
372
+ ), (g = r.onSuccess) == null || g.call(r, d.user, d.state), s("success", d.user, d.state);
369
373
  } catch (d) {
370
374
  const k = d instanceof Error ? d : new Error("Callback processing failed");
371
375
  a.error(
372
376
  "[Vuethenticate] AuthCallback: Authentication callback failed",
373
377
  k
374
- ), s.value = k, (o = r.onError) == null || o.call(r, k), u("error", k);
378
+ ), o.value = k, (i = r.onError) == null || i.call(r, k), s("error", k);
375
379
  } finally {
376
380
  l.value = !1;
377
381
  }
378
382
  };
379
383
  return z(() => {
380
384
  b();
381
- }), (g, o) => (_(), P(B, null, [
382
- (M(c) || l.value) && !s.value ? S(g.$slots, "default", { key: 0 }, () => [
383
- o[0] || (o[0] = v("p", null, "Processing authentication...", -1))
385
+ }), (g, i) => (W(), _(B, null, [
386
+ (M(c) || l.value) && !o.value ? S(g.$slots, "default", { key: 0 }, () => [
387
+ i[0] || (i[0] = v("p", null, "Processing authentication...", -1))
384
388
  ]) : I("", !0),
385
- s.value ? S(g.$slots, "error", {
389
+ o.value ? S(g.$slots, "error", {
386
390
  key: 1,
387
- error: s.value
391
+ error: o.value
388
392
  }, () => [
389
393
  v("div", null, [
390
- o[1] || (o[1] = v("h2", null, "Authentication Error", -1)),
391
- v("p", null, x(s.value.message), 1)
394
+ i[1] || (i[1] = v("h2", null, "Authentication Error", -1)),
395
+ v("p", null, x(o.value.message), 1)
392
396
  ])
393
397
  ]) : I("", !0)
394
398
  ], 64));
395
399
  }
396
- }), he = /* @__PURE__ */ V({
400
+ }), ke = /* @__PURE__ */ V({
397
401
  __name: "LogoutCallback",
398
402
  props: {
399
403
  onSuccess: { type: Function },
@@ -401,8 +405,8 @@ const te = (e) => {
401
405
  },
402
406
  emits: ["success", "error"],
403
407
  setup(e, { emit: t }) {
404
- const r = e, u = t, { processLogoutCallback: n, isInitializing: c, logger: a } = O(), l = y(!0), s = y(null), b = async () => {
405
- var g, o;
408
+ const r = e, s = t, { processLogoutCallback: n, isInitializing: c, logger: a } = O(), l = y(!0), o = y(null), b = async () => {
409
+ var g, i;
406
410
  try {
407
411
  a.info(
408
412
  "[Vuethenticate] LogoutCallback: Processing logout callback"
@@ -410,50 +414,50 @@ const te = (e) => {
410
414
  const d = await n();
411
415
  a.info(
412
416
  "[Vuethenticate] LogoutCallback: Logout callback completed successfully"
413
- ), (g = r.onSuccess) == null || g.call(r, d.state), u("success", d.state);
417
+ ), (g = r.onSuccess) == null || g.call(r, d.state), s("success", d.state);
414
418
  } catch (d) {
415
419
  const k = d instanceof Error ? d : new Error("Logout callback processing failed");
416
420
  a.error(
417
421
  "[Vuethenticate] LogoutCallback: Logout callback failed",
418
422
  k
419
- ), s.value = k, (o = r.onError) == null || o.call(r, k), u("error", k);
423
+ ), o.value = k, (i = r.onError) == null || i.call(r, k), s("error", k);
420
424
  } finally {
421
425
  l.value = !1;
422
426
  }
423
427
  };
424
428
  return z(() => {
425
429
  b();
426
- }), (g, o) => (M(c) || l.value) && !s.value ? S(g.$slots, "default", { key: 0 }, () => [
427
- o[0] || (o[0] = v("p", null, "Processing logout...", -1))
428
- ]) : s.value ? S(g.$slots, "error", {
430
+ }), (g, i) => (M(c) || l.value) && !o.value ? S(g.$slots, "default", { key: 0 }, () => [
431
+ i[0] || (i[0] = v("p", null, "Processing logout...", -1))
432
+ ]) : o.value ? S(g.$slots, "error", {
429
433
  key: 1,
430
- error: s.value
434
+ error: o.value
431
435
  }, () => [
432
436
  v("div", null, [
433
- o[1] || (o[1] = v("h2", null, "Logout Error", -1)),
434
- v("p", null, x(s.value.message), 1)
437
+ i[1] || (i[1] = v("h2", null, "Logout Error", -1)),
438
+ v("p", null, x(o.value.message), 1)
435
439
  ])
436
440
  ]) : S(g.$slots, "success", { key: 2 }, () => [
437
- o[2] || (o[2] = v("div", null, [
441
+ i[2] || (i[2] = v("div", null, [
438
442
  v("h2", null, "Logout Successful"),
439
443
  v("p", null, "You have been logged out successfully.")
440
444
  ], -1))
441
445
  ]);
442
446
  }
443
- }), ke = /* @__PURE__ */ V({
447
+ }), we = /* @__PURE__ */ V({
444
448
  __name: "SilentCallback",
445
449
  props: {
446
450
  onError: { type: Function }
447
451
  },
448
452
  setup(e) {
449
- const t = e, { processSilentCallback: r, isInitializing: u, logger: n } = O(), c = y(null), a = async () => {
453
+ const t = e, { processSilentCallback: r, isInitializing: s, logger: n } = O(), c = y(null), a = async () => {
450
454
  var l;
451
455
  try {
452
456
  n.debug(
453
457
  "[Vuethenticate] SilentCallback: Processing silent callback"
454
458
  ), await r();
455
- } catch (s) {
456
- const b = s instanceof Error ? s : new Error("Silent callback processing failed");
459
+ } catch (o) {
460
+ const b = o instanceof Error ? o : new Error("Silent callback processing failed");
457
461
  n.error(
458
462
  "[Vuethenticate] SilentCallback: Silent callback failed",
459
463
  b
@@ -462,9 +466,9 @@ const te = (e) => {
462
466
  };
463
467
  return z(() => {
464
468
  a();
465
- }), (l, s) => (_(), P(B, null, [
466
- M(u) && !c.value ? S(l.$slots, "default", { key: 0 }, () => [
467
- s[0] || (s[0] = v("p", null, "Processing silent renewal...", -1))
469
+ }), (l, o) => (W(), _(B, null, [
470
+ M(s) && !c.value ? S(l.$slots, "default", { key: 0 }, () => [
471
+ o[0] || (o[0] = v("p", null, "Processing silent renewal...", -1))
468
472
  ]) : I("", !0),
469
473
  c.value ? S(l.$slots, "error", {
470
474
  key: 1,
@@ -476,11 +480,11 @@ const te = (e) => {
476
480
  }
477
481
  });
478
482
  export {
479
- ge as AuthCallback,
483
+ he as AuthCallback,
480
484
  f as LogLevel,
481
- he as LogoutCallback,
482
- ke as SilentCallback,
485
+ ke as LogoutCallback,
486
+ we as SilentCallback,
483
487
  D as consoleLogger,
484
488
  Q as silentLogger,
485
- de as useAuth
489
+ ge as useAuth
486
490
  };
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,isInitialized:s,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"})});
@@ -24,6 +24,7 @@ export interface AuthConfig {
24
24
  export interface AuthState {
25
25
  user: Ref<User | null>;
26
26
  isLoading: Ref<boolean>;
27
+ isInitialized: Ref<boolean>;
27
28
  error: Ref<Error | null>;
28
29
  isAuthenticated: ComputedRef<boolean>;
29
30
  accessToken: ComputedRef<string | null>;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/types/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,WAAW,UAAU;IAEvB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,qBAAqB,GAAG,oBAAoB,CAAC;IAEpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,OAAO,CAAC,EAAE,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BAAqB,EAAE,MAAM,OAAO,CAAC;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACzD,qBAAqB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,aAAa,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5B,cAAc,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,aAAa,CAAC,MAAM,GAAG,OAAO,IAAI,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AAE9E,MAAM,WAAW,iBAAiB,CAAC,MAAM,GAAG,OAAO;IAC/C,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,mBAAmB;IAChC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,mBAAmB,CAAC,MAAM,GAAG,OAAO;IACjD,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACpC;AAED,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vuethenticate",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "A Vue 3 authentication state management library using oidc-client-ts",
5
5
  "keywords": [
6
6
  "vue",