vuethenticate 0.1.4 → 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.
- package/README.md +75 -0
- package/dist/components/AuthCallback.vue.d.ts.map +1 -1
- package/dist/components/LogoutCallback.vue.d.ts +24 -0
- package/dist/components/LogoutCallback.vue.d.ts.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/composables/useAuth.d.ts +3 -0
- package/dist/composables/useAuth.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +222 -175
- package/dist/index.umd.js +1 -1
- package/dist/types/auth.d.ts +8 -4
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/utils/configHelpers.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -98,6 +98,7 @@ function onError(error) {
|
|
98
98
|
// router.js
|
99
99
|
import { createRouter, createWebHistory } from 'vue-router'
|
100
100
|
import CallbackPage from './CallbackPage.vue'
|
101
|
+
import LogoutCallbackPage from './LogoutCallbackPage.vue'
|
101
102
|
import SilentCallbackPage from './SilentCallbackPage.vue'
|
102
103
|
|
103
104
|
const routes = [
|
@@ -105,6 +106,10 @@ const routes = [
|
|
105
106
|
path: '/auth/callback',
|
106
107
|
component: CallbackPage
|
107
108
|
},
|
109
|
+
{
|
110
|
+
path: '/auth/logout-callback',
|
111
|
+
component: LogoutCallbackPage
|
112
|
+
},
|
108
113
|
{
|
109
114
|
path: '/auth/silent-callback',
|
110
115
|
component: SilentCallbackPage
|
@@ -264,6 +269,76 @@ Component for handling OAuth callback. **Note**: This component requires `useAut
|
|
264
269
|
| `success` | `User, state?: TState` | Emitted on successful authentication with typed state |
|
265
270
|
| `error` | `Error` | Emitted on authentication error |
|
266
271
|
|
272
|
+
### `<LogoutCallback>`
|
273
|
+
|
274
|
+
Component for handling OAuth logout callback. **Note**: This component requires `useAuth()` to be called in a parent component first.
|
275
|
+
|
276
|
+
#### Props
|
277
|
+
|
278
|
+
| Property | Type | Required | Description |
|
279
|
+
|----------|------|----------|-------------|
|
280
|
+
| `onSuccess` | `(state?: TState) => void` | | Success callback with typed state |
|
281
|
+
| `onError` | `(error: Error) => void` | | Error callback |
|
282
|
+
|
283
|
+
#### Slots
|
284
|
+
|
285
|
+
| Slot | Props | Description |
|
286
|
+
|------|-------|-------------|
|
287
|
+
| `default` | - | Loading content |
|
288
|
+
| `error` | `{ error: Error }` | Error content |
|
289
|
+
| `success` | - | Success content |
|
290
|
+
|
291
|
+
#### Events
|
292
|
+
|
293
|
+
| Event | Payload | Description |
|
294
|
+
|-------|---------|-------------|
|
295
|
+
| `success` | `state?: TState` | Emitted on successful logout with typed state |
|
296
|
+
| `error` | `Error` | Emitted on logout error |
|
297
|
+
|
298
|
+
#### Usage
|
299
|
+
|
300
|
+
```vue
|
301
|
+
<!-- LogoutCallbackPage.vue -->
|
302
|
+
<script setup>
|
303
|
+
import { LogoutCallback } from 'vuethenticate'
|
304
|
+
|
305
|
+
function onSuccess(state) {
|
306
|
+
console.log('Logout successful:', state)
|
307
|
+
// Redirect to home or show success message
|
308
|
+
window.location.href = '/'
|
309
|
+
}
|
310
|
+
|
311
|
+
function onError(error) {
|
312
|
+
console.error('Logout failed:', error)
|
313
|
+
// Handle error - redirect or show error
|
314
|
+
window.location.href = '/error'
|
315
|
+
}
|
316
|
+
</script>
|
317
|
+
|
318
|
+
<template>
|
319
|
+
<LogoutCallback
|
320
|
+
:onSuccess="onSuccess"
|
321
|
+
:onError="onError"
|
322
|
+
>
|
323
|
+
<div>Processing logout...</div>
|
324
|
+
|
325
|
+
<template #error="{ error }">
|
326
|
+
<div>
|
327
|
+
<h2>Logout Failed</h2>
|
328
|
+
<p>{{ error.message }}</p>
|
329
|
+
</div>
|
330
|
+
</template>
|
331
|
+
|
332
|
+
<template #success>
|
333
|
+
<div>
|
334
|
+
<h2>Logout Successful</h2>
|
335
|
+
<p>You have been logged out successfully.</p>
|
336
|
+
</div>
|
337
|
+
</template>
|
338
|
+
</LogoutCallback>
|
339
|
+
</template>
|
340
|
+
```
|
341
|
+
|
267
342
|
### `<SilentCallback>`
|
268
343
|
|
269
344
|
Component for handling silent token renewal callbacks. This component should be mounted on a separate route (typically `/auth/silent-callback`) and is used internally by the library for automatic token refresh. **Note**: This component requires `useAuth()` to be called in a parent component first.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AuthCallback.vue.d.ts","sourceRoot":"","sources":["../../src/components/AuthCallback.vue"],"names":[],"mappings":"AAgBA;
|
1
|
+
{"version":3,"file":"AuthCallback.vue.d.ts","sourceRoot":"","sources":["../../src/components/AuthCallback.vue"],"names":[],"mappings":"AAgBA;AAyEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;yBAG1B,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;WAiHO,mBAAmB,CAAC;;;uLAAkE,CAAC,4BAA2B;oBACzG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;yBAhCkB,GAAG;;;YACL,GAAG;;;EAmC1B,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AA5HzE,wBA4H4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
|
@@ -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 +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"}
|
@@ -17,6 +17,9 @@ export declare const useAuthCallbacks: <TState = unknown>() => {
|
|
17
17
|
user: User;
|
18
18
|
state?: TState;
|
19
19
|
}>;
|
20
|
+
processLogoutCallback: () => Promise<{
|
21
|
+
state?: TState;
|
22
|
+
}>;
|
20
23
|
processSilentCallback: () => Promise<void>;
|
21
24
|
isInitialized: Ref<boolean, boolean>;
|
22
25
|
isInitializing: Ref<boolean, boolean>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/composables/useAuth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAoB,KAAK,GAAG,EAAwB,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,KAAK,IAAI,EAAe,MAAM,gBAAgB,CAAC;AAwNxD;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,MAAM,GAAG,OAAO,EACpC,QAAQ,UAAU,KACnB,aAAa,CAAC,MAAM,CAsNtB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,GAAG,OAAO;2BAaX,OAAO,CAAC;QACtC,IAAI,EAAE,IAAI,CAAC;QACX,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/composables/useAuth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAoB,KAAK,GAAG,EAAwB,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,KAAK,IAAI,EAAe,MAAM,gBAAgB,CAAC;AAwNxD;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,MAAM,GAAG,OAAO,EACpC,QAAQ,UAAU,KACnB,aAAa,CAAC,MAAM,CAsNtB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,GAAG,OAAO;2BAaX,OAAO,CAAC;QACtC,IAAI,EAAE,IAAI,CAAC;QACX,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;iCAkBsC,OAAO,CAAC;QAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;iCAYsC,OAAO,CAAC,IAAI,CAAC;;;CAaxD,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
|
package/dist/index.d.ts.map
CHANGED
@@ -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;
|
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,245 +1,245 @@
|
|
1
|
-
import { ref as m, computed as I, watch as W, defineComponent as M, onMounted as
|
2
|
-
import { WebStorageStateStore as
|
3
|
-
function
|
4
|
-
const
|
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 ?? `${
|
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
|
13
|
+
userStore: e.storage ? new Y({ store: H(e.storage) }) : void 0,
|
14
14
|
automaticSilentRenew: e.automaticSilentRenew ?? !0,
|
15
|
-
silent_redirect_uri: e.silentRedirectUri ?? `${
|
16
|
-
post_logout_redirect_uri: e.postLogoutRedirectUri ??
|
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
|
21
|
+
function H(e) {
|
22
22
|
if (typeof window > "u")
|
23
|
-
return
|
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
|
30
|
+
return _();
|
31
31
|
default:
|
32
32
|
return window.localStorage;
|
33
33
|
}
|
34
34
|
}
|
35
|
-
function
|
35
|
+
function _() {
|
36
36
|
const e = /* @__PURE__ */ new Map();
|
37
37
|
return {
|
38
|
-
getItem: (
|
39
|
-
setItem: (
|
40
|
-
removeItem: (
|
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: (
|
45
|
+
key: (t) => Array.from(e.keys())[t] ?? null
|
46
46
|
};
|
47
47
|
}
|
48
|
-
const h = /* @__PURE__ */ new Map(),
|
48
|
+
const h = /* @__PURE__ */ new Map(), J = (e) => {
|
49
49
|
try {
|
50
|
-
const { userManager:
|
51
|
-
|
52
|
-
|
53
|
-
),
|
54
|
-
|
55
|
-
),
|
56
|
-
|
57
|
-
),
|
58
|
-
} catch (
|
59
|
-
console.warn("Error during UserManager cleanup:",
|
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
|
-
},
|
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(h.values())[0] || null),
|
64
|
-
const
|
65
|
-
if (
|
66
|
-
return
|
67
|
-
const
|
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
68
|
var E;
|
69
|
-
return ((E =
|
70
|
-
}),
|
69
|
+
return ((E = s.value) == null ? void 0 : E.access_token) || null;
|
70
|
+
}), u = I(() => {
|
71
71
|
var E;
|
72
|
-
return !!((E =
|
72
|
+
return !!((E = s.value) != null && E.expired);
|
73
73
|
}), k = {
|
74
|
-
userManager:
|
75
|
-
isInitialized:
|
76
|
-
isInitializing:
|
77
|
-
user:
|
74
|
+
userManager: o,
|
75
|
+
isInitialized: n,
|
76
|
+
isInitializing: c,
|
77
|
+
user: s,
|
78
78
|
isLoading: a,
|
79
79
|
error: p,
|
80
|
-
isAuthenticated:
|
81
|
-
accessToken:
|
82
|
-
isExpired:
|
80
|
+
isAuthenticated: d,
|
81
|
+
accessToken: l,
|
82
|
+
isExpired: u,
|
83
83
|
eventCallbacks: {}
|
84
84
|
};
|
85
|
-
return h.set(
|
85
|
+
return h.set(t, k), k;
|
86
86
|
}, Z = (e) => {
|
87
|
-
const
|
88
|
-
return new
|
89
|
-
},
|
90
|
-
const
|
91
|
-
return
|
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
|
94
|
-
if (!((
|
93
|
+
var t, r;
|
94
|
+
if (!((t = e.authority) != null && t.trim()))
|
95
95
|
throw new Error("AuthConfig: authority is required");
|
96
|
-
if (!((
|
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
|
-
}, z = async (e,
|
103
|
+
}, z = async (e, t = 1e4) => {
|
104
104
|
if (!e.isInitialized.value)
|
105
|
-
return new Promise((
|
106
|
-
const
|
107
|
-
|
108
|
-
},
|
105
|
+
return new Promise((r, o) => {
|
106
|
+
const n = setTimeout(() => {
|
107
|
+
o(new Error("Authentication initialization timeout"));
|
108
|
+
}, t), c = W(
|
109
109
|
e.isInitialized,
|
110
|
-
(
|
111
|
-
|
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
|
119
|
-
userManager:
|
120
|
-
isInitialized:
|
121
|
-
isInitializing:
|
122
|
-
user:
|
123
|
-
isLoading:
|
118
|
+
const t = X(e), {
|
119
|
+
userManager: r,
|
120
|
+
isInitialized: o,
|
121
|
+
isInitializing: n,
|
122
|
+
user: c,
|
123
|
+
isLoading: s,
|
124
124
|
error: a,
|
125
125
|
isAuthenticated: p,
|
126
|
-
accessToken:
|
127
|
-
isExpired:
|
128
|
-
} =
|
129
|
-
if (!(
|
126
|
+
accessToken: d,
|
127
|
+
isExpired: l
|
128
|
+
} = t, u = N(e), k = async () => {
|
129
|
+
if (!(n.value || o.value))
|
130
130
|
try {
|
131
|
-
|
132
|
-
const
|
133
|
-
if (
|
134
|
-
if (!
|
135
|
-
|
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
|
139
|
-
} catch (
|
138
|
+
await $();
|
139
|
+
} catch (i) {
|
140
140
|
console.warn(
|
141
141
|
"Silent renewal failed during initialization:",
|
142
|
-
|
143
|
-
), await
|
142
|
+
i
|
143
|
+
), await r.removeUser(), c.value = null;
|
144
144
|
}
|
145
145
|
else
|
146
|
-
await
|
147
|
-
} catch (
|
148
|
-
|
149
|
-
|
146
|
+
await r.removeUser(), c.value = null;
|
147
|
+
} catch (v) {
|
148
|
+
b(
|
149
|
+
v,
|
150
150
|
"Failed to initialize authentication",
|
151
151
|
a,
|
152
152
|
e.onError
|
153
153
|
);
|
154
154
|
} finally {
|
155
|
-
|
155
|
+
s.value = !1, n.value = !1, o.value = !0;
|
156
156
|
}
|
157
|
-
}, E = async (
|
157
|
+
}, E = async (v) => {
|
158
158
|
try {
|
159
|
-
|
160
|
-
} catch (
|
161
|
-
|
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
|
-
|
163
|
+
s.value = !1;
|
164
164
|
}
|
165
|
-
}, q = async (
|
165
|
+
}, q = async (v) => {
|
166
166
|
try {
|
167
|
-
|
168
|
-
} catch (
|
169
|
-
|
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
|
-
|
171
|
+
s.value = !1;
|
172
172
|
}
|
173
|
-
},
|
173
|
+
}, $ = async () => {
|
174
174
|
try {
|
175
|
-
|
176
|
-
const
|
177
|
-
|
178
|
-
} catch (
|
179
|
-
throw
|
180
|
-
|
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
182
|
a,
|
183
183
|
e.onError
|
184
184
|
);
|
185
185
|
} finally {
|
186
|
-
|
186
|
+
s.value = !1;
|
187
187
|
}
|
188
188
|
}, B = () => {
|
189
189
|
a.value = null;
|
190
|
-
}, O = (
|
191
|
-
const { userManager:
|
192
|
-
|
193
|
-
var
|
194
|
-
A.value =
|
195
|
-
},
|
196
|
-
var
|
197
|
-
A.value = null, (
|
198
|
-
},
|
199
|
-
var
|
200
|
-
(
|
201
|
-
},
|
202
|
-
var
|
203
|
-
(
|
204
|
-
},
|
205
|
-
console.warn("Silent renewal failed:",
|
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
|
208
|
-
} catch (
|
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
|
-
|
211
|
+
C
|
212
212
|
);
|
213
213
|
}
|
214
|
-
|
215
|
-
|
214
|
+
b(
|
215
|
+
w,
|
216
216
|
"Silent renewal failed",
|
217
217
|
D,
|
218
|
-
|
218
|
+
i.onError
|
219
219
|
);
|
220
|
-
},
|
221
|
-
|
222
|
-
),
|
223
|
-
|
224
|
-
),
|
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
|
-
|
226
|
+
J(t), h.delete(u);
|
227
227
|
};
|
228
|
-
return !
|
229
|
-
user:
|
228
|
+
return !o.value && !n.value && (k(), O(t, e)), {
|
229
|
+
user: c,
|
230
230
|
isAuthenticated: p,
|
231
|
-
isLoading:
|
231
|
+
isLoading: s,
|
232
232
|
error: a,
|
233
|
-
accessToken:
|
234
|
-
isExpired:
|
233
|
+
accessToken: d,
|
234
|
+
isExpired: l,
|
235
235
|
signIn: E,
|
236
236
|
signOut: q,
|
237
|
-
silentRenew:
|
237
|
+
silentRenew: $,
|
238
238
|
clearError: B,
|
239
239
|
cleanup: V
|
240
240
|
};
|
241
|
-
},
|
242
|
-
const e =
|
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."
|
@@ -247,12 +247,19 @@ const h = /* @__PURE__ */ new Map(), Q = (e) => {
|
|
247
247
|
return {
|
248
248
|
processCallback: async () => {
|
249
249
|
await z(e);
|
250
|
-
const
|
251
|
-
if (!
|
250
|
+
const n = await e.userManager.signinCallback();
|
251
|
+
if (!n)
|
252
252
|
throw new Error("Authentication callback failed: no user returned");
|
253
253
|
return {
|
254
|
-
user:
|
255
|
-
state:
|
254
|
+
user: n,
|
255
|
+
state: n.state
|
256
|
+
};
|
257
|
+
},
|
258
|
+
processLogoutCallback: async () => {
|
259
|
+
await z(e);
|
260
|
+
const n = await e.userManager.signoutCallback();
|
261
|
+
return {
|
262
|
+
state: n == null ? void 0 : n.state
|
256
263
|
};
|
257
264
|
},
|
258
265
|
processSilentCallback: async () => {
|
@@ -268,68 +275,108 @@ const h = /* @__PURE__ */ new Map(), Q = (e) => {
|
|
268
275
|
onError: { type: Function }
|
269
276
|
},
|
270
277
|
emits: ["success", "error"],
|
271
|
-
setup(e, { emit:
|
272
|
-
const
|
273
|
-
var
|
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;
|
274
281
|
try {
|
275
|
-
const
|
276
|
-
(
|
277
|
-
} catch (
|
278
|
-
const k =
|
279
|
-
a.value = 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);
|
280
287
|
} finally {
|
281
|
-
|
288
|
+
s.value = !1;
|
282
289
|
}
|
283
290
|
};
|
284
|
-
return
|
291
|
+
return T(() => {
|
285
292
|
p();
|
286
|
-
}), (
|
287
|
-
(
|
288
|
-
|
289
|
-
]) :
|
290
|
-
a.value ?
|
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
|
+
]) : U("", !0),
|
297
|
+
a.value ? S(d.$slots, "error", {
|
291
298
|
key: 1,
|
292
299
|
error: a.value
|
293
300
|
}, () => [
|
294
|
-
|
295
|
-
|
296
|
-
|
301
|
+
y("div", null, [
|
302
|
+
l[1] || (l[1] = y("h2", null, "Authentication Error", -1)),
|
303
|
+
y("p", null, x(a.value.message), 1)
|
297
304
|
])
|
298
|
-
]) :
|
305
|
+
]) : U("", !0)
|
299
306
|
], 64));
|
300
307
|
}
|
301
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({
|
302
348
|
__name: "SilentCallback",
|
303
349
|
props: {
|
304
350
|
onError: { type: Function }
|
305
351
|
},
|
306
352
|
setup(e) {
|
307
|
-
const
|
308
|
-
var
|
353
|
+
const t = e, { processSilentCallback: r, isInitializing: o } = R(), n = m(null), c = async () => {
|
354
|
+
var s;
|
309
355
|
try {
|
310
|
-
await
|
356
|
+
await r();
|
311
357
|
} catch (a) {
|
312
358
|
const p = a instanceof Error ? a : new Error("Silent callback processing failed");
|
313
|
-
|
359
|
+
n.value = p, (s = t.onError) == null || s.call(t, p), console.error("Silent callback error:", p);
|
314
360
|
}
|
315
361
|
};
|
316
|
-
return
|
317
|
-
|
318
|
-
}), (
|
319
|
-
|
320
|
-
a[0] || (a[0] =
|
321
|
-
]) :
|
322
|
-
|
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))
|
367
|
+
]) : U("", !0),
|
368
|
+
n.value ? S(s.$slots, "error", {
|
323
369
|
key: 1,
|
324
|
-
error:
|
370
|
+
error: n.value
|
325
371
|
}, () => [
|
326
|
-
|
327
|
-
]) :
|
372
|
+
y("p", null, "Silent renewal error: " + x(n.value.message), 1)
|
373
|
+
]) : U("", !0)
|
328
374
|
], 64));
|
329
375
|
}
|
330
376
|
});
|
331
377
|
export {
|
332
378
|
ae as AuthCallback,
|
333
|
-
se as
|
379
|
+
se as LogoutCallback,
|
380
|
+
le as SilentCallback,
|
334
381
|
ne as useAuth
|
335
382
|
};
|
package/dist/index.umd.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
(function(
|
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"})});
|
package/dist/types/auth.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Ref } from 'vue';
|
1
|
+
import { ComputedRef, Ref } from 'vue';
|
2
2
|
import { User } from 'oidc-client-ts';
|
3
3
|
export interface AuthConfig {
|
4
4
|
authority: string;
|
@@ -20,11 +20,11 @@ export interface AuthConfig {
|
|
20
20
|
}
|
21
21
|
export interface AuthState {
|
22
22
|
user: Ref<User | null>;
|
23
|
-
isAuthenticated: Ref<boolean>;
|
24
23
|
isLoading: Ref<boolean>;
|
25
24
|
error: Ref<Error | null>;
|
26
|
-
|
27
|
-
|
25
|
+
isAuthenticated: ComputedRef<boolean>;
|
26
|
+
accessToken: ComputedRef<string | null>;
|
27
|
+
isExpired: ComputedRef<boolean>;
|
28
28
|
}
|
29
29
|
export interface AuthMethods<TState = unknown> {
|
30
30
|
signIn: (state?: TState) => Promise<void>;
|
@@ -48,5 +48,9 @@ export interface AuthCallbackProps<TState = unknown> {
|
|
48
48
|
export interface SilentCallbackProps {
|
49
49
|
onError?: (error: Error) => void;
|
50
50
|
}
|
51
|
+
export interface LogoutCallbackProps<TState = unknown> {
|
52
|
+
onSuccess?: (state?: TState) => void;
|
53
|
+
onError?: (error: Error) => void;
|
54
|
+
}
|
51
55
|
export { User } from 'oidc-client-ts';
|
52
56
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/types/auth.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/types/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/types/auth.ts"],"names":[],"mappings":"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"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"configHelpers.d.ts","sourceRoot":"","sources":["../../src/utils/configHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAG1D;;;;GAIG;AACH,wBAAgB,yBAAyB,CACrC,MAAM,EAAE,UAAU,GACnB,mBAAmB,
|
1
|
+
{"version":3,"file":"configHelpers.d.ts","sourceRoot":"","sources":["../../src/utils/configHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAG1D;;;;GAIG;AACH,wBAAgB,yBAAyB,CACrC,MAAM,EAAE,UAAU,GACnB,mBAAmB,CAsBrB"}
|