vuethenticate 0.1.5 → 0.1.6

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.
@@ -0,0 +1,24 @@
1
+ import { LogoutCallbackProps } from '../types/auth';
2
+ declare const _default: <TState = unknown>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
4
+ readonly onError?: ((error: Error) => any) | undefined;
5
+ readonly onSuccess?: ((state?: TState | undefined) => any) | undefined;
6
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onError" | "onSuccess"> & LogoutCallbackProps<TState> & Partial<{}>> & import('vue').PublicProps;
7
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
8
+ attrs: any;
9
+ slots: {
10
+ default?(_: {}): any;
11
+ error?(_: {
12
+ error: Error;
13
+ }): any;
14
+ success?(_: {}): any;
15
+ };
16
+ emit: ((evt: "error", error: Error) => void) & ((evt: "success", state?: TState | undefined) => void);
17
+ }>) => import('vue').VNode & {
18
+ __ctx?: Awaited<typeof __VLS_setup>;
19
+ };
20
+ export default _default;
21
+ type __VLS_PrettifyLocal<T> = {
22
+ [K in keyof T]: T[K];
23
+ } & {};
24
+ //# sourceMappingURL=LogoutCallback.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LogoutCallback.vue.d.ts","sourceRoot":"","sources":["../../src/components/LogoutCallback.vue"],"names":[],"mappings":"AAyBA;AAiFA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;yBAGxC,MAAM,GAAG,OAAO,EAChC,aAAa,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,EAC9D,YAAY,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,EAC3G,eAAe,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EACjE;WA4HO,mBAAmB,CAAC;;;yLAAkE,CAAC,4BAA2B;oBACzG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;yBAjCkB,GAAG;;;YACL,GAAG;yBACD,GAAG;;;EAmC5B,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AAvIzE,wBAuI4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { default as AuthCallback } from './AuthCallback.vue';
2
+ export { default as LogoutCallback } from './LogoutCallback.vue';
2
3
  export { default as SilentCallback } from './SilentCallback.vue';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { useAuth } from './composables/useAuth';
2
- export { AuthCallback, SilentCallback } from './components';
3
- export type { AuthConfig, AuthState, AuthMethods, AuthCallbackMethods, UseAuthReturn, AuthCallbackProps, SilentCallbackProps, User, } from './types/auth';
2
+ export { AuthCallback, LogoutCallback, SilentCallback } from './components';
3
+ export type { AuthConfig, AuthState, AuthMethods, AuthCallbackMethods, UseAuthReturn, AuthCallbackProps, SilentCallbackProps, LogoutCallbackProps, User, } from './types/auth';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG5D,YAAY,EACR,UAAU,EACV,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,IAAI,GACP,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG5E,YAAY,EACR,UAAU,EACV,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,IAAI,GACP,MAAM,cAAc,CAAC"}
package/dist/index.esm.js CHANGED
@@ -1,252 +1,252 @@
1
- import { ref as m, computed as I, watch as W, defineComponent as z, onMounted as R, createElementBlock as L, openBlock as _, Fragment as $, renderSlot as C, createCommentVNode as U, unref as F, createElementVNode as S, toDisplayString as P } from "vue";
2
- import { WebStorageStateStore as j, UserManager as G } from "oidc-client-ts";
3
- function H(e) {
4
- const r = typeof window < "u" ? window.location.origin : "";
1
+ import { ref as m, computed as I, watch as W, defineComponent as M, onMounted as T, createElementBlock as F, openBlock as P, Fragment as K, renderSlot as S, createCommentVNode as U, unref as L, createElementVNode as y, toDisplayString as x } from "vue";
2
+ import { WebStorageStateStore as Y, UserManager as j } from "oidc-client-ts";
3
+ function G(e) {
4
+ const t = typeof window < "u" ? window.location.origin : "";
5
5
  return {
6
6
  authority: e.authority,
7
7
  client_id: e.clientId,
8
8
  client_secret: e.clientSecret,
9
9
  client_authentication: e.clientAuthentication,
10
- redirect_uri: e.redirectUri ?? `${r}/auth/callback`,
10
+ redirect_uri: e.redirectUri ?? `${t}/auth/callback`,
11
11
  scope: e.scope ?? "openid profile",
12
12
  response_type: e.responseType ?? "code",
13
- userStore: e.storage ? new j({ store: J(e.storage) }) : void 0,
13
+ userStore: e.storage ? new Y({ store: H(e.storage) }) : void 0,
14
14
  automaticSilentRenew: e.automaticSilentRenew ?? !0,
15
- silent_redirect_uri: e.silentRedirectUri ?? `${r}/auth/silent-callback`,
16
- post_logout_redirect_uri: e.postLogoutRedirectUri ?? `${r}/auth/logout-callback`,
15
+ silent_redirect_uri: e.silentRedirectUri ?? `${t}/auth/silent-callback`,
16
+ post_logout_redirect_uri: e.postLogoutRedirectUri ?? `${t}/auth/logout-callback`,
17
17
  includeIdTokenInSilentRenew: !0,
18
18
  accessTokenExpiringNotificationTimeInSeconds: 60
19
19
  };
20
20
  }
21
- function J(e) {
21
+ function H(e) {
22
22
  if (typeof window > "u")
23
- return T();
23
+ return _();
24
24
  switch (e) {
25
25
  case "localStorage":
26
26
  return window.localStorage;
27
27
  case "sessionStorage":
28
28
  return window.sessionStorage;
29
29
  case "memory":
30
- return T();
30
+ return _();
31
31
  default:
32
32
  return window.localStorage;
33
33
  }
34
34
  }
35
- function T() {
35
+ function _() {
36
36
  const e = /* @__PURE__ */ new Map();
37
37
  return {
38
- getItem: (r) => e.get(r) ?? null,
39
- setItem: (r, t) => e.set(r, t),
40
- removeItem: (r) => e.delete(r),
38
+ getItem: (t) => e.get(t) ?? null,
39
+ setItem: (t, r) => e.set(t, r),
40
+ removeItem: (t) => e.delete(t),
41
41
  clear: () => e.clear(),
42
42
  get length() {
43
43
  return e.size;
44
44
  },
45
- key: (r) => Array.from(e.keys())[r] ?? null
45
+ key: (t) => Array.from(e.keys())[t] ?? null
46
46
  };
47
47
  }
48
- const E = /* @__PURE__ */ new Map(), Q = (e) => {
48
+ const h = /* @__PURE__ */ new Map(), J = (e) => {
49
49
  try {
50
- const { userManager: r, eventCallbacks: t } = e;
51
- t.userLoaded && r.events.removeUserLoaded(t.userLoaded), t.userUnloaded && r.events.removeUserUnloaded(t.userUnloaded), t.accessTokenExpired && r.events.removeAccessTokenExpired(
52
- t.accessTokenExpired
53
- ), t.accessTokenExpiring && r.events.removeAccessTokenExpiring(
54
- t.accessTokenExpiring
55
- ), t.silentRenewError && r.events.removeSilentRenewError(
56
- t.silentRenewError
57
- ), r.stopSilentRenew(), r.clearStaleState();
58
- } catch (r) {
59
- console.warn("Error during UserManager cleanup:", r);
50
+ const { userManager: t, eventCallbacks: r } = e;
51
+ r.userLoaded && t.events.removeUserLoaded(r.userLoaded), r.userUnloaded && t.events.removeUserUnloaded(r.userUnloaded), r.accessTokenExpired && t.events.removeAccessTokenExpired(
52
+ r.accessTokenExpired
53
+ ), r.accessTokenExpiring && t.events.removeAccessTokenExpiring(
54
+ r.accessTokenExpiring
55
+ ), r.silentRenewError && t.events.removeSilentRenewError(
56
+ r.silentRenewError
57
+ ), t.stopSilentRenew(), t.clearStaleState();
58
+ } catch (t) {
59
+ console.warn("Error during UserManager cleanup:", t);
60
60
  }
61
- }, K = (e) => `${e.authority}_${e.clientId}`, X = () => E.size === 0 ? null : (E.size === 1 || console.warn(
61
+ }, N = (e) => `${e.authority}_${e.clientId}`, Q = () => h.size === 0 ? null : (h.size === 1 || console.warn(
62
62
  "Multiple auth instances detected. Callback components may not work as expected. Consider using a single auth instance or specify config explicitly."
63
- ), Array.from(E.values())[0] || null), Y = (e) => {
64
- const r = K(e), t = E.get(r);
65
- if (t)
66
- return t;
67
- const i = Z(e), n = m(!1), u = m(!1), a = m(null), s = m(!1), p = m(null), y = I(() => !!a.value && !a.value.expired), d = I(() => {
68
- var h;
69
- return ((h = a.value) == null ? void 0 : h.access_token) || null;
70
- }), w = I(() => {
71
- var h;
72
- return !!((h = a.value) != null && h.expired);
63
+ ), Array.from(h.values())[0] || null), X = (e) => {
64
+ const t = N(e), r = h.get(t);
65
+ if (r)
66
+ return r;
67
+ const o = Z(e), n = m(!1), c = m(!1), s = m(null), a = m(!1), p = m(null), d = I(() => !!s.value && !s.value.expired), l = I(() => {
68
+ var E;
69
+ return ((E = s.value) == null ? void 0 : E.access_token) || null;
70
+ }), u = I(() => {
71
+ var E;
72
+ return !!((E = s.value) != null && E.expired);
73
73
  }), k = {
74
- userManager: i,
74
+ userManager: o,
75
75
  isInitialized: n,
76
- isInitializing: u,
77
- user: a,
78
- isLoading: s,
76
+ isInitializing: c,
77
+ user: s,
78
+ isLoading: a,
79
79
  error: p,
80
- isAuthenticated: y,
81
- accessToken: d,
82
- isExpired: w,
80
+ isAuthenticated: d,
81
+ accessToken: l,
82
+ isExpired: u,
83
83
  eventCallbacks: {}
84
84
  };
85
- return E.set(r, k), k;
85
+ return h.set(t, k), k;
86
86
  }, Z = (e) => {
87
- const r = H(e);
88
- return new G(r);
89
- }, f = (e, r, t, i) => {
90
- const n = e instanceof Error ? e : new Error(r);
91
- return t.value = n, i == null || i(n), n;
87
+ const t = G(e);
88
+ return new j(t);
89
+ }, b = (e, t, r, o) => {
90
+ const n = e instanceof Error ? e : new Error(t);
91
+ return r.value = n, o == null || o(n), n;
92
92
  }, ee = (e) => {
93
- var r, t;
94
- if (!((r = e.authority) != null && r.trim()))
93
+ var t, r;
94
+ if (!((t = e.authority) != null && t.trim()))
95
95
  throw new Error("AuthConfig: authority is required");
96
- if (!((t = e.clientId) != null && t.trim()))
96
+ if (!((r = e.clientId) != null && r.trim()))
97
97
  throw new Error("AuthConfig: clientId is required");
98
98
  try {
99
99
  new URL(e.authority);
100
100
  } catch {
101
101
  throw new Error("AuthConfig: authority must be a valid URL");
102
102
  }
103
- }, x = async (e, r = 1e4) => {
103
+ }, z = async (e, t = 1e4) => {
104
104
  if (!e.isInitialized.value)
105
- return new Promise((t, i) => {
105
+ return new Promise((r, o) => {
106
106
  const n = setTimeout(() => {
107
- i(new Error("Authentication initialization timeout"));
108
- }, r), u = W(
107
+ o(new Error("Authentication initialization timeout"));
108
+ }, t), c = W(
109
109
  e.isInitialized,
110
- (a) => {
111
- a && (clearTimeout(n), u(), t());
110
+ (s) => {
111
+ s && (clearTimeout(n), c(), r());
112
112
  },
113
113
  { immediate: !0 }
114
114
  );
115
115
  });
116
116
  }, ne = (e) => {
117
117
  ee(e);
118
- const r = Y(e), {
119
- userManager: t,
120
- isInitialized: i,
118
+ const t = X(e), {
119
+ userManager: r,
120
+ isInitialized: o,
121
121
  isInitializing: n,
122
- user: u,
123
- isLoading: a,
124
- error: s,
122
+ user: c,
123
+ isLoading: s,
124
+ error: a,
125
125
  isAuthenticated: p,
126
- accessToken: y,
127
- isExpired: d
128
- } = r, w = K(e), k = async () => {
129
- if (!(n.value || i.value))
126
+ accessToken: d,
127
+ isExpired: l
128
+ } = t, u = N(e), k = async () => {
129
+ if (!(n.value || o.value))
130
130
  try {
131
- n.value = !0, a.value = !0, s.value = null;
132
- const o = await t.getUser();
133
- if (o)
134
- if (!o.expired)
135
- u.value = o;
131
+ n.value = !0, s.value = !0, a.value = null;
132
+ const v = await r.getUser();
133
+ if (v)
134
+ if (!v.expired)
135
+ c.value = v;
136
136
  else if (e.automaticSilentRenew !== !1)
137
137
  try {
138
- await M();
139
- } catch (l) {
138
+ await $();
139
+ } catch (i) {
140
140
  console.warn(
141
141
  "Silent renewal failed during initialization:",
142
- l
143
- ), await t.removeUser(), u.value = null;
142
+ i
143
+ ), await r.removeUser(), c.value = null;
144
144
  }
145
145
  else
146
- await t.removeUser(), u.value = null;
147
- } catch (o) {
148
- f(
149
- o,
146
+ await r.removeUser(), c.value = null;
147
+ } catch (v) {
148
+ b(
149
+ v,
150
150
  "Failed to initialize authentication",
151
- s,
151
+ a,
152
152
  e.onError
153
153
  );
154
154
  } finally {
155
- a.value = !1, n.value = !1, i.value = !0;
155
+ s.value = !1, n.value = !1, o.value = !0;
156
156
  }
157
- }, h = async (o) => {
157
+ }, E = async (v) => {
158
158
  try {
159
- a.value = !0, s.value = null, await t.signinRedirect({ state: o });
160
- } catch (l) {
161
- f(l, "Sign in failed", s, e.onError);
159
+ s.value = !0, a.value = null, await r.signinRedirect({ state: v });
160
+ } catch (i) {
161
+ b(i, "Sign in failed", a, e.onError);
162
162
  } finally {
163
- a.value = !1;
163
+ s.value = !1;
164
164
  }
165
- }, q = async (o) => {
165
+ }, q = async (v) => {
166
166
  try {
167
- a.value = !0, s.value = null, u.value = null, await t.signoutRedirect({ state: o });
168
- } catch (l) {
169
- f(l, "Sign out failed", s, e.onError);
167
+ s.value = !0, a.value = null, c.value = null, await r.signoutRedirect({ state: v });
168
+ } catch (i) {
169
+ b(i, "Sign out failed", a, e.onError);
170
170
  } finally {
171
- a.value = !1;
171
+ s.value = !1;
172
172
  }
173
- }, M = async () => {
173
+ }, $ = async () => {
174
174
  try {
175
- a.value = !0, s.value = null;
176
- const o = await t.signinSilent();
177
- u.value = o;
178
- } catch (o) {
179
- throw f(
180
- o,
175
+ s.value = !0, a.value = null;
176
+ const v = await r.signinSilent();
177
+ c.value = v;
178
+ } catch (v) {
179
+ throw b(
180
+ v,
181
181
  "Silent renewal failed",
182
- s,
182
+ a,
183
183
  e.onError
184
184
  );
185
185
  } finally {
186
- a.value = !1;
186
+ s.value = !1;
187
187
  }
188
188
  }, B = () => {
189
- s.value = null;
190
- }, O = (o, l) => {
191
- const { userManager: g, user: A, error: D, eventCallbacks: v } = o;
192
- v.userLoaded = (c) => {
193
- var b;
194
- A.value = c, (b = l.onUserLoaded) == null || b.call(l, c);
195
- }, v.userUnloaded = () => {
196
- var c;
197
- A.value = null, (c = l.onUserUnloaded) == null || c.call(l);
198
- }, v.accessTokenExpired = () => {
199
- var c;
200
- (c = l.onAccessTokenExpired) == null || c.call(l);
201
- }, v.accessTokenExpiring = () => {
202
- var c;
203
- (c = l.onAccessTokenExpiring) == null || c.call(l);
204
- }, v.silentRenewError = async (c) => {
205
- console.warn("Silent renewal failed:", c);
189
+ a.value = null;
190
+ }, O = (v, i) => {
191
+ const { userManager: f, user: A, error: D, eventCallbacks: g } = v;
192
+ g.userLoaded = (w) => {
193
+ var C;
194
+ A.value = w, (C = i.onUserLoaded) == null || C.call(i, w);
195
+ }, g.userUnloaded = () => {
196
+ var w;
197
+ A.value = null, (w = i.onUserUnloaded) == null || w.call(i);
198
+ }, g.accessTokenExpired = () => {
199
+ var w;
200
+ (w = i.onAccessTokenExpired) == null || w.call(i);
201
+ }, g.accessTokenExpiring = () => {
202
+ var w;
203
+ (w = i.onAccessTokenExpiring) == null || w.call(i);
204
+ }, g.silentRenewError = async (w) => {
205
+ console.warn("Silent renewal failed:", w);
206
206
  try {
207
- await g.removeUser(), A.value = null;
208
- } catch (b) {
207
+ await f.removeUser(), A.value = null;
208
+ } catch (C) {
209
209
  console.error(
210
210
  "Failed to remove user after silent renewal error:",
211
- b
211
+ C
212
212
  );
213
213
  }
214
- f(
215
- c,
214
+ b(
215
+ w,
216
216
  "Silent renewal failed",
217
217
  D,
218
- l.onError
218
+ i.onError
219
219
  );
220
- }, g.events.addUserLoaded(v.userLoaded), g.events.addUserUnloaded(v.userUnloaded), g.events.addAccessTokenExpired(
221
- v.accessTokenExpired
222
- ), g.events.addAccessTokenExpiring(
223
- v.accessTokenExpiring
224
- ), g.events.addSilentRenewError(v.silentRenewError);
220
+ }, f.events.addUserLoaded(g.userLoaded), f.events.addUserUnloaded(g.userUnloaded), f.events.addAccessTokenExpired(
221
+ g.accessTokenExpired
222
+ ), f.events.addAccessTokenExpiring(
223
+ g.accessTokenExpiring
224
+ ), f.events.addSilentRenewError(g.silentRenewError);
225
225
  }, V = () => {
226
- Q(r), E.delete(w);
226
+ J(t), h.delete(u);
227
227
  };
228
- return !i.value && !n.value && (k(), O(r, e)), {
229
- user: u,
228
+ return !o.value && !n.value && (k(), O(t, e)), {
229
+ user: c,
230
230
  isAuthenticated: p,
231
- isLoading: a,
232
- error: s,
233
- accessToken: y,
234
- isExpired: d,
235
- signIn: h,
231
+ isLoading: s,
232
+ error: a,
233
+ accessToken: d,
234
+ isExpired: l,
235
+ signIn: E,
236
236
  signOut: q,
237
- silentRenew: M,
237
+ silentRenew: $,
238
238
  clearError: B,
239
239
  cleanup: V
240
240
  };
241
- }, N = () => {
242
- const e = X();
241
+ }, R = () => {
242
+ const e = Q();
243
243
  if (!e)
244
244
  throw new Error(
245
245
  "Authentication not initialized. Make sure useAuth() is called in a parent component first."
246
246
  );
247
247
  return {
248
248
  processCallback: async () => {
249
- await x(e);
249
+ await z(e);
250
250
  const n = await e.userManager.signinCallback();
251
251
  if (!n)
252
252
  throw new Error("Authentication callback failed: no user returned");
@@ -256,87 +256,127 @@ const E = /* @__PURE__ */ new Map(), Q = (e) => {
256
256
  };
257
257
  },
258
258
  processLogoutCallback: async () => {
259
- await x(e);
259
+ await z(e);
260
260
  const n = await e.userManager.signoutCallback();
261
261
  return {
262
262
  state: n == null ? void 0 : n.state
263
263
  };
264
264
  },
265
265
  processSilentCallback: async () => {
266
- await x(e), await e.userManager.signinCallback();
266
+ await z(e), await e.userManager.signinCallback();
267
267
  },
268
268
  isInitialized: e.isInitialized,
269
269
  isInitializing: e.isInitializing
270
270
  };
271
- }, ae = /* @__PURE__ */ z({
271
+ }, ae = /* @__PURE__ */ M({
272
272
  __name: "AuthCallback",
273
273
  props: {
274
274
  onSuccess: { type: Function },
275
275
  onError: { type: Function }
276
276
  },
277
277
  emits: ["success", "error"],
278
- setup(e, { emit: r }) {
279
- const t = e, i = r, { processCallback: n, isInitializing: u } = N(), a = m(!0), s = m(null), p = async () => {
280
- var y, d;
278
+ setup(e, { emit: t }) {
279
+ const r = e, o = t, { processCallback: n, isInitializing: c } = R(), s = m(!0), a = m(null), p = async () => {
280
+ var d, l;
281
281
  try {
282
- const w = await n();
283
- (y = t.onSuccess) == null || y.call(t, w.user, w.state), i("success", w.user, w.state);
284
- } catch (w) {
285
- const k = w instanceof Error ? w : new Error("Callback processing failed");
286
- s.value = k, (d = t.onError) == null || d.call(t, k), i("error", k);
282
+ const u = await n();
283
+ (d = r.onSuccess) == null || d.call(r, u.user, u.state), o("success", u.user, u.state);
284
+ } catch (u) {
285
+ const k = u instanceof Error ? u : new Error("Callback processing failed");
286
+ a.value = k, (l = r.onError) == null || l.call(r, k), o("error", k);
287
287
  } finally {
288
- a.value = !1;
288
+ s.value = !1;
289
289
  }
290
290
  };
291
- return R(() => {
291
+ return T(() => {
292
292
  p();
293
- }), (y, d) => (_(), L($, null, [
294
- (F(u) || a.value) && !s.value ? C(y.$slots, "default", { key: 0 }, () => [
295
- d[0] || (d[0] = S("p", null, "Processing authentication...", -1))
293
+ }), (d, l) => (P(), F(K, null, [
294
+ (L(c) || s.value) && !a.value ? S(d.$slots, "default", { key: 0 }, () => [
295
+ l[0] || (l[0] = y("p", null, "Processing authentication...", -1))
296
296
  ]) : U("", !0),
297
- s.value ? C(y.$slots, "error", {
297
+ a.value ? S(d.$slots, "error", {
298
298
  key: 1,
299
- error: s.value
299
+ error: a.value
300
300
  }, () => [
301
- S("div", null, [
302
- d[1] || (d[1] = S("h2", null, "Authentication Error", -1)),
303
- S("p", null, P(s.value.message), 1)
301
+ y("div", null, [
302
+ l[1] || (l[1] = y("h2", null, "Authentication Error", -1)),
303
+ y("p", null, x(a.value.message), 1)
304
304
  ])
305
305
  ]) : U("", !0)
306
306
  ], 64));
307
307
  }
308
- }), se = /* @__PURE__ */ z({
308
+ }), se = /* @__PURE__ */ M({
309
+ __name: "LogoutCallback",
310
+ props: {
311
+ onSuccess: { type: Function },
312
+ onError: { type: Function }
313
+ },
314
+ emits: ["success", "error"],
315
+ setup(e, { emit: t }) {
316
+ const r = e, o = t, { processLogoutCallback: n, isInitializing: c } = R(), s = m(!0), a = m(null), p = async () => {
317
+ var d, l;
318
+ try {
319
+ const u = await n();
320
+ (d = r.onSuccess) == null || d.call(r, u.state), o("success", u.state);
321
+ } catch (u) {
322
+ const k = u instanceof Error ? u : new Error("Logout callback processing failed");
323
+ a.value = k, (l = r.onError) == null || l.call(r, k), o("error", k);
324
+ } finally {
325
+ s.value = !1;
326
+ }
327
+ };
328
+ return T(() => {
329
+ p();
330
+ }), (d, l) => (L(c) || s.value) && !a.value ? S(d.$slots, "default", { key: 0 }, () => [
331
+ l[0] || (l[0] = y("p", null, "Processing logout...", -1))
332
+ ]) : a.value ? S(d.$slots, "error", {
333
+ key: 1,
334
+ error: a.value
335
+ }, () => [
336
+ y("div", null, [
337
+ l[1] || (l[1] = y("h2", null, "Logout Error", -1)),
338
+ y("p", null, x(a.value.message), 1)
339
+ ])
340
+ ]) : S(d.$slots, "success", { key: 2 }, () => [
341
+ l[2] || (l[2] = y("div", null, [
342
+ y("h2", null, "Logout Successful"),
343
+ y("p", null, "You have been logged out successfully.")
344
+ ], -1))
345
+ ]);
346
+ }
347
+ }), le = /* @__PURE__ */ M({
309
348
  __name: "SilentCallback",
310
349
  props: {
311
350
  onError: { type: Function }
312
351
  },
313
352
  setup(e) {
314
- const r = e, { processSilentCallback: t, isInitializing: i } = N(), n = m(null), u = async () => {
315
- var a;
353
+ const t = e, { processSilentCallback: r, isInitializing: o } = R(), n = m(null), c = async () => {
354
+ var s;
316
355
  try {
317
- await t();
318
- } catch (s) {
319
- const p = s instanceof Error ? s : new Error("Silent callback processing failed");
320
- n.value = p, (a = r.onError) == null || a.call(r, p), console.error("Silent callback error:", p);
356
+ await r();
357
+ } catch (a) {
358
+ const p = a instanceof Error ? a : new Error("Silent callback processing failed");
359
+ n.value = p, (s = t.onError) == null || s.call(t, p), console.error("Silent callback error:", p);
321
360
  }
322
361
  };
323
- return R(() => {
324
- u();
325
- }), (a, s) => (_(), L($, null, [
326
- F(i) && !n.value ? C(a.$slots, "default", { key: 0 }, () => [
327
- s[0] || (s[0] = S("p", null, "Processing silent renewal...", -1))
362
+ return T(() => {
363
+ c();
364
+ }), (s, a) => (P(), F(K, null, [
365
+ L(o) && !n.value ? S(s.$slots, "default", { key: 0 }, () => [
366
+ a[0] || (a[0] = y("p", null, "Processing silent renewal...", -1))
328
367
  ]) : U("", !0),
329
- n.value ? C(a.$slots, "error", {
368
+ n.value ? S(s.$slots, "error", {
330
369
  key: 1,
331
370
  error: n.value
332
371
  }, () => [
333
- S("p", null, "Silent renewal error: " + P(n.value.message), 1)
372
+ y("p", null, "Silent renewal error: " + x(n.value.message), 1)
334
373
  ]) : U("", !0)
335
374
  ], 64));
336
375
  }
337
376
  });
338
377
  export {
339
378
  ae as AuthCallback,
340
- se as SilentCallback,
379
+ se as LogoutCallback,
380
+ le as SilentCallback,
341
381
  ne as useAuth
342
382
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(m,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("oidc-client-ts")):typeof define=="function"&&define.amd?define(["exports","vue","oidc-client-ts"],t):(m=typeof globalThis<"u"?globalThis:m||self,t(m.Vuethenticate={},m.Vue,m.OidcClientTs))})(this,function(m,t,A){"use strict";function z(e){const r=typeof window<"u"?window.location.origin:"";return{authority:e.authority,client_id:e.clientId,client_secret:e.clientSecret,client_authentication:e.clientAuthentication,redirect_uri:e.redirectUri??`${r}/auth/callback`,scope:e.scope??"openid profile",response_type:e.responseType??"code",userStore:e.storage?new A.WebStorageStateStore({store:R(e.storage)}):void 0,automaticSilentRenew:e.automaticSilentRenew??!0,silent_redirect_uri:e.silentRedirectUri??`${r}/auth/silent-callback`,post_logout_redirect_uri:e.postLogoutRedirectUri??`${r}/auth/logout-callback`,includeIdTokenInSilentRenew:!0,accessTokenExpiringNotificationTimeInSeconds:60}}function R(e){if(typeof window>"u")return T();switch(e){case"localStorage":return window.localStorage;case"sessionStorage":return window.sessionStorage;case"memory":return T();default:return window.localStorage}}function T(){const e=new Map;return{getItem:r=>e.get(r)??null,setItem:(r,n)=>e.set(r,n),removeItem:r=>e.delete(r),clear:()=>e.clear(),get length(){return e.size},key:r=>Array.from(e.keys())[r]??null}}const f=new Map,L=e=>{try{const{userManager:r,eventCallbacks:n}=e;n.userLoaded&&r.events.removeUserLoaded(n.userLoaded),n.userUnloaded&&r.events.removeUserUnloaded(n.userUnloaded),n.accessTokenExpired&&r.events.removeAccessTokenExpired(n.accessTokenExpired),n.accessTokenExpiring&&r.events.removeAccessTokenExpiring(n.accessTokenExpiring),n.silentRenewError&&r.events.removeSilentRenewError(n.silentRenewError),r.stopSilentRenew(),r.clearStaleState()}catch(r){console.warn("Error during UserManager cleanup:",r)}},I=e=>`${e.authority}_${e.clientId}`,_=()=>f.size===0?null:(f.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(f.values())[0]||null),V=e=>{const r=I(e),n=f.get(r);if(n)return n;const o=N(e),a=t.ref(!1),u=t.ref(!1),s=t.ref(null),i=t.ref(!1),k=t.ref(null),E=t.computed(()=>!!s.value&&!s.value.expired),w=t.computed(()=>{var g;return((g=s.value)==null?void 0:g.access_token)||null}),p=t.computed(()=>{var g;return!!((g=s.value)!=null&&g.expired)}),h={userManager:o,isInitialized:a,isInitializing:u,user:s,isLoading:i,error:k,isAuthenticated:E,accessToken:w,isExpired:p,eventCallbacks:{}};return f.set(r,h),h},N=e=>{const r=z(e);return new A.UserManager(r)},v=(e,r,n,o)=>{const a=e instanceof Error?e:new Error(r);return n.value=a,o==null||o(a),a},$=e=>{var r,n;if(!((r=e.authority)!=null&&r.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")}},b=async(e,r=1e4)=>{if(!e.isInitialized.value)return new Promise((n,o)=>{const a=setTimeout(()=>{o(new Error("Authentication initialization timeout"))},r),u=t.watch(e.isInitialized,s=>{s&&(clearTimeout(a),u(),n())},{immediate:!0})})},F=e=>{$(e);const r=V(e),{userManager:n,isInitialized:o,isInitializing:a,user:u,isLoading:s,error:i,isAuthenticated:k,accessToken:E,isExpired:w}=r,p=I(e),h=async()=>{if(!(a.value||o.value))try{a.value=!0,s.value=!0,i.value=null;const c=await n.getUser();if(c)if(!c.expired)u.value=c;else if(e.automaticSilentRenew!==!1)try{await x()}catch(l){console.warn("Silent renewal failed during initialization:",l),await n.removeUser(),u.value=null}else await n.removeUser(),u.value=null}catch(c){v(c,"Failed to initialize authentication",i,e.onError)}finally{s.value=!1,a.value=!1,o.value=!0}},g=async c=>{try{s.value=!0,i.value=null,await n.signinRedirect({state:c})}catch(l){v(l,"Sign in failed",i,e.onError)}finally{s.value=!1}},B=async c=>{try{s.value=!0,i.value=null,u.value=null,await n.signoutRedirect({state:c})}catch(l){v(l,"Sign out failed",i,e.onError)}finally{s.value=!1}},x=async()=>{try{s.value=!0,i.value=null;const c=await n.signinSilent();u.value=c}catch(c){throw v(c,"Silent renewal failed",i,e.onError)}finally{s.value=!1}},O=()=>{i.value=null},K=(c,l)=>{const{userManager:S,user:U,error:D,eventCallbacks:y}=c;y.userLoaded=d=>{var C;U.value=d,(C=l.onUserLoaded)==null||C.call(l,d)},y.userUnloaded=()=>{var d;U.value=null,(d=l.onUserUnloaded)==null||d.call(l)},y.accessTokenExpired=()=>{var d;(d=l.onAccessTokenExpired)==null||d.call(l)},y.accessTokenExpiring=()=>{var d;(d=l.onAccessTokenExpiring)==null||d.call(l)},y.silentRenewError=async d=>{console.warn("Silent renewal failed:",d);try{await S.removeUser(),U.value=null}catch(C){console.error("Failed to remove user after silent renewal error:",C)}v(d,"Silent renewal failed",D,l.onError)},S.events.addUserLoaded(y.userLoaded),S.events.addUserUnloaded(y.userUnloaded),S.events.addAccessTokenExpired(y.accessTokenExpired),S.events.addAccessTokenExpiring(y.accessTokenExpiring),S.events.addSilentRenewError(y.silentRenewError)},j=()=>{L(r),f.delete(p)};return!o.value&&!a.value&&(h(),K(r,e)),{user:u,isAuthenticated:k,isLoading:s,error:i,accessToken:E,isExpired:w,signIn:g,signOut:B,silentRenew:x,clearError:O,cleanup:j}},M=()=>{const e=_();if(!e)throw new Error("Authentication not initialized. Make sure useAuth() is called in a parent component first.");return{processCallback:async()=>{await b(e);const a=await e.userManager.signinCallback();if(!a)throw new Error("Authentication callback failed: no user returned");return{user:a,state:a.state}},processLogoutCallback:async()=>{await b(e);const a=await e.userManager.signoutCallback();return{state:a==null?void 0:a.state}},processSilentCallback:async()=>{await b(e),await e.userManager.signinCallback()},isInitialized:e.isInitialized,isInitializing:e.isInitializing}},P=t.defineComponent({__name:"AuthCallback",props:{onSuccess:{type:Function},onError:{type:Function}},emits:["success","error"],setup(e,{emit:r}){const n=e,o=r,{processCallback:a,isInitializing:u}=M(),s=t.ref(!0),i=t.ref(null),k=async()=>{var E,w;try{const p=await a();(E=n.onSuccess)==null||E.call(n,p.user,p.state),o("success",p.user,p.state)}catch(p){const h=p instanceof Error?p:new Error("Callback processing failed");i.value=h,(w=n.onError)==null||w.call(n,h),o("error",h)}finally{s.value=!1}};return t.onMounted(()=>{k()}),(E,w)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[(t.unref(u)||s.value)&&!i.value?t.renderSlot(E.$slots,"default",{key:0},()=>[w[0]||(w[0]=t.createElementVNode("p",null,"Processing authentication...",-1))]):t.createCommentVNode("",!0),i.value?t.renderSlot(E.$slots,"error",{key:1,error:i.value},()=>[t.createElementVNode("div",null,[w[1]||(w[1]=t.createElementVNode("h2",null,"Authentication Error",-1)),t.createElementVNode("p",null,t.toDisplayString(i.value.message),1)])]):t.createCommentVNode("",!0)],64))}}),q=t.defineComponent({__name:"SilentCallback",props:{onError:{type:Function}},setup(e){const r=e,{processSilentCallback:n,isInitializing:o}=M(),a=t.ref(null),u=async()=>{var s;try{await n()}catch(i){const k=i instanceof Error?i:new Error("Silent callback processing failed");a.value=k,(s=r.onError)==null||s.call(r,k),console.error("Silent callback error:",k)}};return t.onMounted(()=>{u()}),(s,i)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.unref(o)&&!a.value?t.renderSlot(s.$slots,"default",{key:0},()=>[i[0]||(i[0]=t.createElementVNode("p",null,"Processing silent renewal...",-1))]):t.createCommentVNode("",!0),a.value?t.renderSlot(s.$slots,"error",{key:1,error:a.value},()=>[t.createElementVNode("p",null,"Silent renewal error: "+t.toDisplayString(a.value.message),1)]):t.createCommentVNode("",!0)],64))}});m.AuthCallback=P,m.SilentCallback=q,m.useAuth=F,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
1
+ (function(k,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("oidc-client-ts")):typeof define=="function"&&define.amd?define(["exports","vue","oidc-client-ts"],t):(k=typeof globalThis<"u"?globalThis:k||self,t(k.Vuethenticate={},k.Vue,k.OidcClientTs))})(this,function(k,t,I){"use strict";function L(e){const n=typeof window<"u"?window.location.origin:"";return{authority:e.authority,client_id:e.clientId,client_secret:e.clientSecret,client_authentication:e.clientAuthentication,redirect_uri:e.redirectUri??`${n}/auth/callback`,scope:e.scope??"openid profile",response_type:e.responseType??"code",userStore:e.storage?new I.WebStorageStateStore({store:R(e.storage)}):void 0,automaticSilentRenew:e.automaticSilentRenew??!0,silent_redirect_uri:e.silentRedirectUri??`${n}/auth/silent-callback`,post_logout_redirect_uri:e.postLogoutRedirectUri??`${n}/auth/logout-callback`,includeIdTokenInSilentRenew:!0,accessTokenExpiringNotificationTimeInSeconds:60}}function R(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:n=>e.get(n)??null,setItem:(n,r)=>e.set(n,r),removeItem:n=>e.delete(n),clear:()=>e.clear(),get length(){return e.size},key:n=>Array.from(e.keys())[n]??null}}const g=new Map,V=e=>{try{const{userManager:n,eventCallbacks:r}=e;r.userLoaded&&n.events.removeUserLoaded(r.userLoaded),r.userUnloaded&&n.events.removeUserUnloaded(r.userUnloaded),r.accessTokenExpired&&n.events.removeAccessTokenExpired(r.accessTokenExpired),r.accessTokenExpiring&&n.events.removeAccessTokenExpiring(r.accessTokenExpiring),r.silentRenewError&&n.events.removeSilentRenewError(r.silentRenewError),n.stopSilentRenew(),n.clearStaleState()}catch(n){console.warn("Error during UserManager cleanup:",n)}},T=e=>`${e.authority}_${e.clientId}`,x=()=>g.size===0?null:(g.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(g.values())[0]||null),N=e=>{const n=T(e),r=g.get(n);if(r)return r;const i=$(e),a=t.ref(!1),d=t.ref(!1),l=t.ref(null),s=t.ref(!1),E=t.ref(null),m=t.computed(()=>!!l.value&&!l.value.expired),o=t.computed(()=>{var h;return((h=l.value)==null?void 0:h.access_token)||null}),u=t.computed(()=>{var h;return!!((h=l.value)!=null&&h.expired)}),p={userManager:i,isInitialized:a,isInitializing:d,user:l,isLoading:s,error:E,isAuthenticated:m,accessToken:o,isExpired:u,eventCallbacks:{}};return g.set(n,p),p},$=e=>{const n=L(e);return new I.UserManager(n)},b=(e,n,r,i)=>{const a=e instanceof Error?e:new Error(n);return r.value=a,i==null||i(a),a},_=e=>{var n,r;if(!((n=e.authority)!=null&&n.trim()))throw new Error("AuthConfig: authority is required");if(!((r=e.clientId)!=null&&r.trim()))throw new Error("AuthConfig: clientId is required");try{new URL(e.authority)}catch{throw new Error("AuthConfig: authority must be a valid URL")}},v=async(e,n=1e4)=>{if(!e.isInitialized.value)return new Promise((r,i)=>{const a=setTimeout(()=>{i(new Error("Authentication initialization timeout"))},n),d=t.watch(e.isInitialized,l=>{l&&(clearTimeout(a),d(),r())},{immediate:!0})})},F=e=>{_(e);const n=N(e),{userManager:r,isInitialized:i,isInitializing:a,user:d,isLoading:l,error:s,isAuthenticated:E,accessToken:m,isExpired:o}=n,u=T(e),p=async()=>{if(!(a.value||i.value))try{a.value=!0,l.value=!0,s.value=null;const w=await r.getUser();if(w)if(!w.expired)d.value=w;else if(e.automaticSilentRenew!==!1)try{await z()}catch(c){console.warn("Silent renewal failed during initialization:",c),await r.removeUser(),d.value=null}else await r.removeUser(),d.value=null}catch(w){b(w,"Failed to initialize authentication",s,e.onError)}finally{l.value=!1,a.value=!1,i.value=!0}},h=async w=>{try{l.value=!0,s.value=null,await r.signinRedirect({state:w})}catch(c){b(c,"Sign in failed",s,e.onError)}finally{l.value=!1}},O=async w=>{try{l.value=!0,s.value=null,d.value=null,await r.signoutRedirect({state:w})}catch(c){b(c,"Sign out failed",s,e.onError)}finally{l.value=!1}},z=async()=>{try{l.value=!0,s.value=null;const w=await r.signinSilent();d.value=w}catch(w){throw b(w,"Silent renewal failed",s,e.onError)}finally{l.value=!1}},D=()=>{s.value=null},K=(w,c)=>{const{userManager:S,user:A,error:W,eventCallbacks:f}=w;f.userLoaded=y=>{var C;A.value=y,(C=c.onUserLoaded)==null||C.call(c,y)},f.userUnloaded=()=>{var y;A.value=null,(y=c.onUserUnloaded)==null||y.call(c)},f.accessTokenExpired=()=>{var y;(y=c.onAccessTokenExpired)==null||y.call(c)},f.accessTokenExpiring=()=>{var y;(y=c.onAccessTokenExpiring)==null||y.call(c)},f.silentRenewError=async y=>{console.warn("Silent renewal failed:",y);try{await S.removeUser(),A.value=null}catch(C){console.error("Failed to remove user after silent renewal error:",C)}b(y,"Silent renewal failed",W,c.onError)},S.events.addUserLoaded(f.userLoaded),S.events.addUserUnloaded(f.userUnloaded),S.events.addAccessTokenExpired(f.accessTokenExpired),S.events.addAccessTokenExpiring(f.accessTokenExpiring),S.events.addSilentRenewError(f.silentRenewError)},j=()=>{V(n),g.delete(u)};return!i.value&&!a.value&&(p(),K(n,e)),{user:d,isAuthenticated:E,isLoading:l,error:s,accessToken:m,isExpired:o,signIn:h,signOut:O,silentRenew:z,clearError:D,cleanup:j}},U=()=>{const e=x();if(!e)throw new Error("Authentication not initialized. Make sure useAuth() is called in a parent component first.");return{processCallback:async()=>{await v(e);const a=await e.userManager.signinCallback();if(!a)throw new Error("Authentication callback failed: no user returned");return{user:a,state:a.state}},processLogoutCallback:async()=>{await v(e);const a=await e.userManager.signoutCallback();return{state:a==null?void 0:a.state}},processSilentCallback:async()=>{await v(e),await e.userManager.signinCallback()},isInitialized:e.isInitialized,isInitializing:e.isInitializing}},P=t.defineComponent({__name:"AuthCallback",props:{onSuccess:{type:Function},onError:{type:Function}},emits:["success","error"],setup(e,{emit:n}){const r=e,i=n,{processCallback:a,isInitializing:d}=U(),l=t.ref(!0),s=t.ref(null),E=async()=>{var m,o;try{const u=await a();(m=r.onSuccess)==null||m.call(r,u.user,u.state),i("success",u.user,u.state)}catch(u){const p=u instanceof Error?u:new Error("Callback processing failed");s.value=p,(o=r.onError)==null||o.call(r,p),i("error",p)}finally{l.value=!1}};return t.onMounted(()=>{E()}),(m,o)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[(t.unref(d)||l.value)&&!s.value?t.renderSlot(m.$slots,"default",{key:0},()=>[o[0]||(o[0]=t.createElementVNode("p",null,"Processing authentication...",-1))]):t.createCommentVNode("",!0),s.value?t.renderSlot(m.$slots,"error",{key:1,error:s.value},()=>[t.createElementVNode("div",null,[o[1]||(o[1]=t.createElementVNode("h2",null,"Authentication Error",-1)),t.createElementVNode("p",null,t.toDisplayString(s.value.message),1)])]):t.createCommentVNode("",!0)],64))}}),q=t.defineComponent({__name:"LogoutCallback",props:{onSuccess:{type:Function},onError:{type:Function}},emits:["success","error"],setup(e,{emit:n}){const r=e,i=n,{processLogoutCallback:a,isInitializing:d}=U(),l=t.ref(!0),s=t.ref(null),E=async()=>{var m,o;try{const u=await a();(m=r.onSuccess)==null||m.call(r,u.state),i("success",u.state)}catch(u){const p=u instanceof Error?u:new Error("Logout callback processing failed");s.value=p,(o=r.onError)==null||o.call(r,p),i("error",p)}finally{l.value=!1}};return t.onMounted(()=>{E()}),(m,o)=>(t.unref(d)||l.value)&&!s.value?t.renderSlot(m.$slots,"default",{key:0},()=>[o[0]||(o[0]=t.createElementVNode("p",null,"Processing logout...",-1))]):s.value?t.renderSlot(m.$slots,"error",{key:1,error:s.value},()=>[t.createElementVNode("div",null,[o[1]||(o[1]=t.createElementVNode("h2",null,"Logout Error",-1)),t.createElementVNode("p",null,t.toDisplayString(s.value.message),1)])]):t.renderSlot(m.$slots,"success",{key:2},()=>[o[2]||(o[2]=t.createElementVNode("div",null,[t.createElementVNode("h2",null,"Logout Successful"),t.createElementVNode("p",null,"You have been logged out successfully.")],-1))])}}),B=t.defineComponent({__name:"SilentCallback",props:{onError:{type:Function}},setup(e){const n=e,{processSilentCallback:r,isInitializing:i}=U(),a=t.ref(null),d=async()=>{var l;try{await r()}catch(s){const E=s instanceof Error?s:new Error("Silent callback processing failed");a.value=E,(l=n.onError)==null||l.call(n,E),console.error("Silent callback error:",E)}};return t.onMounted(()=>{d()}),(l,s)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.unref(i)&&!a.value?t.renderSlot(l.$slots,"default",{key:0},()=>[s[0]||(s[0]=t.createElementVNode("p",null,"Processing silent renewal...",-1))]):t.createCommentVNode("",!0),a.value?t.renderSlot(l.$slots,"error",{key:1,error:a.value},()=>[t.createElementVNode("p",null,"Silent renewal error: "+t.toDisplayString(a.value.message),1)]):t.createCommentVNode("",!0)],64))}});k.AuthCallback=P,k.LogoutCallback=q,k.SilentCallback=B,k.useAuth=F,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
@@ -48,7 +48,7 @@ export interface AuthCallbackProps<TState = unknown> {
48
48
  export interface SilentCallbackProps {
49
49
  onError?: (error: Error) => void;
50
50
  }
51
- export interface SignoutCallbackProps<TState = unknown> {
51
+ export interface LogoutCallbackProps<TState = unknown> {
52
52
  onSuccess?: (state?: TState) => void;
53
53
  onError?: (error: Error) => void;
54
54
  }
@@ -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,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,cAAc,GAAG,gBAAgB,GAAG,QAAQ,CAAC;IACvD,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACpC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,IAAI,CAAC;IAClC,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,SAAS;IACtB,IAAI,EAAE,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IACvB,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACxB,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,IAA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,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.5",
3
+ "version": "0.1.6",
4
4
  "description": "A Vue 3 authentication state management library using oidc-client-ts",
5
5
  "keywords": [
6
6
  "vue",